]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org.el
Merge Org 8.2.4
[gnu-emacs] / lisp / org / org.el
index 50d3842e03dd4a82f0e5c5e574a24e629ac42f3c..adaabebc6a536b7c645acc70a9b2e302d17dae0c 100644 (file)
@@ -309,7 +309,7 @@ When MESSAGE is non-nil, display a message with the version."
        (if here
            (insert version)
          (message version))
-      (if message (message _version))
+      (if message (message version1))
       version1)))
 
 (defconst org-version (org-version))
@@ -654,11 +654,17 @@ the following lines anywhere in the buffer:
 
 (defcustom org-use-sub-superscripts t
   "Non-nil means interpret \"_\" and \"^\" for display.
-When this option is turned on, you can use TeX-like syntax for sub- and
-superscripts.  Several characters after \"_\" or \"^\" will be
-considered as a single item - so grouping with {} is normally not
-needed.  For example, the following things will be parsed as single
-sub- or superscripts.
+
+If you want to control how Org exports those characters, see
+`org-export-with-sub-superscripts'.  `org-use-sub-superscripts'
+used to be an alias for `org-export-with-sub-superscripts' in
+Org <8.0, it is not anymore.
+
+When this option is turned on, you can use TeX-like syntax for
+sub- and superscripts within the buffer.  Several characters after
+\"_\" or \"^\" will be considered as a single item - so grouping
+with {} is normally not needed.  For example, the following things
+will be parsed as single sub- or superscripts:
 
  10^24   or   10^tau     several digits will be considered 1 item.
  10^-12  or   10^-tau    a leading sign with digits or a word
@@ -666,13 +672,14 @@ sub- or superscripts.
                         terminated by almost any nonword/nondigit char.
  x_{i^2} or   x^(2-i)    braces or parenthesis do grouping.
 
-Still, ambiguity is possible - so when in doubt use {} to enclose
-the sub/superscript.  If you set this variable to the symbol
-`{}', the braces are *required* in order to trigger
-interpretations as sub/superscript.  This can be helpful in
-documents that need \"_\" frequently in plain text."
+Still, ambiguity is possible.  So when in doubt, use {} to enclose
+the sub/superscript.  If you set this variable to the symbol `{}',
+the braces are *required* in order to trigger interpretations as
+sub/superscript.  This can be helpful in documents that need \"_\"
+frequently in plain text."
   :group 'org-startup
-  :version "24.1"
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type '(choice
          (const :tag "Always interpret" t)
          (const :tag "Only with braces" {})
@@ -1731,7 +1738,12 @@ In tables, the special behavior of RET has precedence."
 A longer mouse click will still set point.  Does not work on XEmacs.
 Needs to be set before org.el is loaded."
   :group 'org-link-follow
-  :type 'boolean)
+  :version "24.4"
+  :package-version '(Org . "8.3")
+  :type '(choice
+         (const :tag "A double click follows the link" 'double)
+         (const :tag "Unconditionally follow the link with mouse-1" t)
+         (integer :tag "mouse-1 click does not follow the link if longer than N ms" 450)))
 
 (defcustom org-mark-ring-length 4
   "Number of different positions to be recorded in the ring.
@@ -2663,12 +2675,12 @@ agenda log mode depends on the format of these entries."
                            "Heading when changing todo state (todo sequence only)"
                            state) string)
               (cons (const :tag "Heading when just taking a note" note) string)
-              (cons (const :tag "Heading when clocking out" clock-out) string)
-              (cons (const :tag "Heading when an item is no longer scheduled" delschedule) string)
               (cons (const :tag "Heading when rescheduling" reschedule) string)
+              (cons (const :tag "Heading when an item is no longer scheduled" delschedule) string)
               (cons (const :tag "Heading when changing deadline"  redeadline) string)
               (cons (const :tag "Heading when deleting a deadline" deldeadline) string)
-              (cons (const :tag "Heading when refiling" refile) string)))
+              (cons (const :tag "Heading when refiling" refile) string)
+              (cons (const :tag "Heading when clocking out" clock-out) string)))
 
 (unless (assq 'note org-log-note-headings)
   (push '(note . "%t") org-log-note-headings))
@@ -4242,12 +4254,6 @@ Normal means, no org-mode-specific context."
   "Detect the first line outside a table when searching from within it.
 This works for both table types.")
 
-;; Autoload the functions in org-table.el that are needed by functions here.
-
-(eval-and-compile
-  (org-autoload "org-table"
-               '(org-table-begin org-table-blank-field org-table-end)))
-
 (defconst org-TBLFM-regexp "^[ \t]*#\\+TBLFM: "
   "Detect a #+TBLFM line.")
 
@@ -4328,12 +4334,6 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
        (re-search-forward org-table-any-border-regexp nil 1))))
   (unless quietly (message "Mapping tables: done")))
 
-;; Declare and autoload functions from org-agenda.el
-
-(eval-and-compile
-  (org-autoload "org-agenda"
-               '(org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))
-
 (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" (beg end))
 (declare-function org-clock-update-mode-line "org-clock" ())
 (declare-function org-resolve-clocks "org-clock"
@@ -4359,11 +4359,6 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
 Return nil if no clock is running."
   (marker-buffer org-clock-marker))
 
-(eval-and-compile
-  (org-autoload "org-clock" '(org-clock-remove-overlays
-                             org-clock-update-time-maybe
-                             org-clocktable-shift)))
-
 (defun org-check-running-clock ()
   "Check if the current buffer contains the running clock.
 If yes, offer to stop it and to save the buffer with the changes."
@@ -4563,33 +4558,18 @@ Otherwise, these types are allowed:
 
 (defalias 'org-advertized-archive-subtree 'org-archive-subtree)
 
-(eval-and-compile
-  (org-autoload "org-archive"
-               '(org-add-archive-files)))
-
-;; Autoload Column View Code
+;; Declare Column View Code
 
 (declare-function org-columns-number-to-string "org-colview" (n fmt &optional printf))
 (declare-function org-columns-get-format-and-top-level "org-colview" ())
 (declare-function org-columns-compute "org-colview" (property))
 
-(org-autoload (if (featurep 'xemacs) "org-colview-xemacs" "org-colview")
-             '(org-columns-number-to-string
-               org-columns-get-format-and-top-level
-               org-columns-compute
-               org-columns-remove-overlays))
-
-;; Autoload ID code
+;; Declare ID code
 
 (declare-function org-id-store-link "org-id")
 (declare-function org-id-locations-load "org-id")
 (declare-function org-id-locations-save "org-id")
 (defvar org-id-track-globally)
-(org-autoload "org-id"
-             '(org-id-new
-               org-id-copy
-               org-id-get-with-outline-path-completion
-               org-id-get-with-outline-drilling))
 
 ;;; Variables for pre-computed regular expressions, all buffer local
 
@@ -8850,13 +8830,13 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 ;; command.  There might be problems if any of the keys is otherwise
 ;; used as a prefix key.
 
-(defcustom orgstruct-heading-prefix-regexp nil
+(defcustom orgstruct-heading-prefix-regexp ""
   "Regexp that matches the custom prefix of Org headlines in
 orgstruct(++)-mode."
   :group 'org
   :version "24.4"
-  :package-version '(Org . "8.0")
-  :type 'string)
+  :package-version '(Org . "8.3")
+  :type 'regexp)
 ;;;###autoload(put 'orgstruct-heading-prefix-regexp 'safe-local-variable 'stringp)
 
 (defcustom orgstruct-setup-hook nil
@@ -9017,8 +8997,8 @@ buffer.  It will also recognize item context in multiline items."
   "Create a function for binding in the structure minor mode.
 FUN is the command to call inside a table.  KEY is the key that
 should be checked in for a command to execute outside of tables.
-Non-nil DISABLE-WHEN-HEADING-PREFIX means to disable the command
-if `orgstruct-heading-prefix-regexp' is non-nil."
+Non-nil `disable-when-heading-prefix' means to disable the command
+if `orgstruct-heading-prefix-regexp' is not empty."
   (let ((name (concat "orgstruct-hijacker-" (symbol-name fun))))
     (let ((nname name)
          (i 0))
@@ -9044,14 +9024,13 @@ if `orgstruct-heading-prefix-regexp' is non-nil."
                   (key-description key) "'."
                   (when disable-when-heading-prefix
                     (concat
-                     "\nIf `orgstruct-heading-prefix-regexp' is non-nil, this command will always fall\n"
+                     "\nIf `orgstruct-heading-prefix-regexp' is not empty, this command will always fall\n"
                      "back to the default binding due to limitations of Org's implementation of\n"
                      "`" (symbol-name fun) "'.")))
          (interactive "p")
          (let* ((disable
-                 ,(when disable-when-heading-prefix
-                    '(and orgstruct-heading-prefix-regexp
-                          (not (string= orgstruct-heading-prefix-regexp "")))))
+                 ,(and disable-when-heading-prefix
+                       '(not (string= orgstruct-heading-prefix-regexp ""))))
                 (fallback
                  (or disable
                      (not
@@ -15204,103 +15183,102 @@ is a string only get exactly this property.  SPECIFIC can be a string, the
 specific property we are interested in.  Specifying it can speed
 things up because then unnecessary parsing is avoided."
   (setq which (or which 'all))
-  (org-with-point-at pom
-    (let ((clockstr (substring org-clock-string 0 -1))
-         (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED"))
-         (case-fold-search nil)
-         beg end range props sum-props key key1 value string clocksum clocksumt)
-      (save-excursion
-       (when (condition-case nil
-                 (and (derived-mode-p 'org-mode) (org-back-to-heading t))
-               (error nil))
-         (setq beg (point))
-         (setq sum-props (get-text-property (point) 'org-summaries))
-         (setq clocksum (get-text-property (point) :org-clock-minutes)
-               clocksumt (get-text-property (point) :org-clock-minutes-today))
-         (outline-next-heading)
-         (setq end (point))
-         (when (memq which '(all special))
-           ;; Get the special properties, like TODO and tags
-           (goto-char beg)
-           (when (and (or (not specific) (string= specific "TODO"))
-                      (looking-at org-todo-line-regexp) (match-end 2))
-             (push (cons "TODO" (org-match-string-no-properties 2)) props))
-           (when (and (or (not specific) (string= specific "PRIORITY"))
-                      (looking-at org-priority-regexp))
-             (push (cons "PRIORITY" (org-match-string-no-properties 2)) props))
-           (when (or (not specific) (string= specific "FILE"))
-             (push (cons "FILE" buffer-file-name) props))
-           (when (and (or (not specific) (string= specific "TAGS"))
-                      (setq value (org-get-tags-string))
-                      (string-match "\\S-" value))
-             (push (cons "TAGS" value) props))
-           (when (and (or (not specific) (string= specific "ALLTAGS"))
-                      (setq value (org-get-tags-at)))
-             (push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":")
-                                           ":"))
-                   props))
-           (when (or (not specific) (string= specific "BLOCKED"))
-             (push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props))
-           (when (or (not specific)
-                     (member specific
-                             '("SCHEDULED" "DEADLINE" "CLOCK" "CLOSED"
-                               "TIMESTAMP" "TIMESTAMP_IA")))
-             (catch 'match
-               (while (re-search-forward org-maybe-keyword-time-regexp end t)
-                 (setq key (if (match-end 1)
-                               (substring (org-match-string-no-properties 1)
-                                          0 -1))
-                       string (if (equal key clockstr)
-                                  (org-trim
-                                   (buffer-substring-no-properties
-                                    (match-beginning 3) (goto-char
-                                                         (point-at-eol))))
-                                (substring (org-match-string-no-properties 3)
-                                           1 -1)))
-                 ;; Get the correct property name from the key.  This is
-                 ;; necessary if the user has configured time keywords.
-                 (setq key1 (concat key ":"))
-                 (cond
-                  ((not key)
-                   (setq key
-                         (if (= (char-after (match-beginning 3)) ?\[)
-                             "TIMESTAMP_IA" "TIMESTAMP")))
-                  ((equal key1 org-scheduled-string) (setq key "SCHEDULED"))
-                  ((equal key1 org-deadline-string)  (setq key "DEADLINE"))
-                  ((equal key1 org-closed-string)    (setq key "CLOSED"))
-                  ((equal key1 org-clock-string)     (setq key "CLOCK")))
-                 (if (and specific (equal key specific) (not (equal key "CLOCK")))
-                     (progn
-                       (push (cons key string) props)
-                       ;; no need to search further if match is found
-                       (throw 'match t))
-                   (when (or (equal key "CLOCK") (not (assoc key props)))
-                     (push (cons key string) props)))))))
-
-         (when (memq which '(all standard))
-           ;; Get the standard properties, like :PROP: ...
-           (setq range (org-get-property-block beg end))
-           (when range
-             (goto-char (car range))
-             (while (re-search-forward org-property-re
-                     (cdr range) t)
-               (setq key (org-match-string-no-properties 2)
-                     value (org-trim (or (org-match-string-no-properties 3) "")))
-               (unless (member key excluded)
-                 (push (cons key (or value "")) props)))))
-         (if clocksum
-             (push (cons "CLOCKSUM"
-                         (org-columns-number-to-string (/ (float clocksum) 60.)
-                                                       'add_times))
-                   props))
-         (if clocksumt
-             (push (cons "CLOCKSUM_T"
-                         (org-columns-number-to-string (/ (float clocksumt) 60.)
-                                                       'add_times))
-                   props))
-         (unless (assoc "CATEGORY" props)
-           (push (cons "CATEGORY" (org-get-category)) props))
-         (append sum-props (nreverse props)))))))
+  (org-with-wide-buffer
+   (org-with-point-at pom
+     (let ((clockstr (substring org-clock-string 0 -1))
+          (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED"))
+          (case-fold-search nil)
+          beg end range props sum-props key key1 value string clocksum clocksumt)
+       (when (and (derived-mode-p 'org-mode)
+                 (ignore-errors (org-back-to-heading t)))
+        (setq beg (point))
+        (setq sum-props (get-text-property (point) 'org-summaries))
+        (setq clocksum (get-text-property (point) :org-clock-minutes)
+              clocksumt (get-text-property (point) :org-clock-minutes-today))
+        (outline-next-heading)
+        (setq end (point))
+        (when (memq which '(all special))
+          ;; Get the special properties, like TODO and tags
+          (goto-char beg)
+          (when (and (or (not specific) (string= specific "TODO"))
+                     (looking-at org-todo-line-regexp) (match-end 2))
+            (push (cons "TODO" (org-match-string-no-properties 2)) props))
+          (when (and (or (not specific) (string= specific "PRIORITY"))
+                     (looking-at org-priority-regexp))
+            (push (cons "PRIORITY" (org-match-string-no-properties 2)) props))
+          (when (or (not specific) (string= specific "FILE"))
+            (push (cons "FILE" buffer-file-name) props))
+          (when (and (or (not specific) (string= specific "TAGS"))
+                     (setq value (org-get-tags-string))
+                     (string-match "\\S-" value))
+            (push (cons "TAGS" value) props))
+          (when (and (or (not specific) (string= specific "ALLTAGS"))
+                     (setq value (org-get-tags-at)))
+            (push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":")
+                                          ":"))
+                  props))
+          (when (or (not specific) (string= specific "BLOCKED"))
+            (push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props))
+          (when (or (not specific)
+                    (member specific
+                            '("SCHEDULED" "DEADLINE" "CLOCK" "CLOSED"
+                              "TIMESTAMP" "TIMESTAMP_IA")))
+            (catch 'match
+              (while (re-search-forward org-maybe-keyword-time-regexp end t)
+                (setq key (if (match-end 1)
+                              (substring (org-match-string-no-properties 1)
+                                         0 -1))
+                      string (if (equal key clockstr)
+                                 (org-trim
+                                  (buffer-substring-no-properties
+                                   (match-beginning 3) (goto-char
+                                                        (point-at-eol))))
+                               (substring (org-match-string-no-properties 3)
+                                          1 -1)))
+                ;; Get the correct property name from the key.  This is
+                ;; necessary if the user has configured time keywords.
+                (setq key1 (concat key ":"))
+                (cond
+                 ((not key)
+                  (setq key
+                        (if (= (char-after (match-beginning 3)) ?\[)
+                            "TIMESTAMP_IA" "TIMESTAMP")))
+                 ((equal key1 org-scheduled-string) (setq key "SCHEDULED"))
+                 ((equal key1 org-deadline-string)  (setq key "DEADLINE"))
+                 ((equal key1 org-closed-string)    (setq key "CLOSED"))
+                 ((equal key1 org-clock-string)     (setq key "CLOCK")))
+                (if (and specific (equal key specific) (not (equal key "CLOCK")))
+                    (progn
+                      (push (cons key string) props)
+                      ;; no need to search further if match is found
+                      (throw 'match t))
+                  (when (or (equal key "CLOCK") (not (assoc key props)))
+                    (push (cons key string) props)))))))
+
+        (when (memq which '(all standard))
+          ;; Get the standard properties, like :PROP: ...
+          (setq range (org-get-property-block beg end))
+          (when range
+            (goto-char (car range))
+            (while (re-search-forward org-property-re
+                                      (cdr range) t)
+              (setq key (org-match-string-no-properties 2)
+                    value (org-trim (or (org-match-string-no-properties 3) "")))
+              (unless (member key excluded)
+                (push (cons key (or value "")) props)))))
+        (if clocksum
+            (push (cons "CLOCKSUM"
+                        (org-columns-number-to-string (/ (float clocksum) 60.)
+                                                      'add_times))
+                  props))
+        (if clocksumt
+            (push (cons "CLOCKSUM_T"
+                        (org-columns-number-to-string (/ (float clocksumt) 60.)
+                                                      'add_times))
+                  props))
+        (unless (assoc "CATEGORY" props)
+          (push (cons "CATEGORY" (org-get-category)) props))
+        (append sum-props (nreverse props)))))))
 
 (defun org-entry-get (pom property &optional inherit literal-nil)
   "Get value of PROPERTY for entry or content at point-or-marker POM.
@@ -15320,30 +15298,32 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
                       t))
        (org-entry-get-with-inheritance property literal-nil)
       (if (member property org-special-properties)
-         ;; We need a special property.  Use `org-entry-properties' to
-         ;; retrieve it, but specify the wanted property
+         ;; We need a special property.  Use `org-entry-properties'
+         ;; to retrieve it, but specify the wanted property
          (cdr (assoc property (org-entry-properties nil 'special property)))
-       (let ((range (org-get-property-block)))
-         (when (and range (not (eq (car range) (cdr range))))
-           (let* ((props (list (or (assoc property org-file-properties)
-                                   (assoc property org-global-properties)
-                                   (assoc property org-global-properties-fixed))))
-                  (ap (lambda (key)
-                        (when (re-search-forward
-                               (org-re-property key) (cdr range) t)
-                          (setq props
-                                (org-update-property-plist
-                                 key
-                                 (if (match-end 3)
-                                     (org-match-string-no-properties 3) "")
-                                 props)))))
-                  val)
-             (goto-char (car range))
-             (funcall ap property)
-             (goto-char (car range))
-             (while (funcall ap (concat property "+")))
-             (setq val (cdr (assoc property props)))
-             (when val (if literal-nil val (org-not-nil val))))))))))
+       (org-with-wide-buffer
+        (let ((range (org-get-property-block)))
+          (when (and range (not (eq (car range) (cdr range))))
+            (let* ((props
+                    (list (or (assoc property org-file-properties)
+                              (assoc property org-global-properties)
+                              (assoc property org-global-properties-fixed))))
+                   (ap (lambda (key)
+                         (when (re-search-forward
+                                (org-re-property key) (cdr range) t)
+                           (setq props
+                                 (org-update-property-plist
+                                  key
+                                  (if (match-end 3)
+                                      (org-match-string-no-properties 3) "")
+                                  props)))))
+                   val)
+              (goto-char (car range))
+              (funcall ap property)
+              (goto-char (car range))
+              (while (funcall ap (concat property "+")))
+              (setq val (cdr (assoc property props)))
+              (when val (if literal-nil val (org-not-nil val)))))))))))
 
 (defun org-property-or-variable-value (var &optional inherit)
   "Check if there is a property fixing the value of VAR.
@@ -19525,9 +19505,6 @@ because, in this case the deletion might narrow the column."
 (put 'org-self-insert-command 'pabbrev-expand-after-command t)
 (put 'orgtbl-self-insert-command 'pabbrev-expand-after-command t)
 
-;; How to do this: Measure non-white length of current string
-;; If equal to column width, we should realign.
-
 (defun org-remap (map &rest commands)
   "In MAP, remap the functions given in COMMANDS.
 COMMANDS is a list of alternating OLDDEF NEWDEF command names."
@@ -20237,10 +20214,17 @@ This command does many different things, depending on context:
       (if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
          (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
              (user-error "C-c C-c can do nothing useful at this location"))
-       ;; When at a link, act according to the parent instead.
-       (when (eq type 'link)
-         (setq context (org-element-property :parent context))
-         (setq type (org-element-type context)))
+       (case type
+         ;; When at a link, act according to the parent instead.
+         (link (setq context (org-element-property :parent context))
+               (setq type (org-element-type context)))
+         ;; Unsupported object types: check parent element instead.
+         ((bold code entity export-snippet inline-babel-call inline-src-block
+                italic latex-fragment line-break macro strike-through subscript
+                superscript underline verbatim)
+          (while (and (setq context (org-element-property :parent context))
+                      (not (memq (setq type (org-element-type context))
+                                 '(paragraph verse-block)))))))
        ;; For convenience: at the first line of a paragraph on the
        ;; same line as an item, apply function on that item instead.
        (when (eq type 'paragraph)