]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org.el
Simplify now that float-time etc. are built-in
[gnu-emacs] / lisp / org / org.el
index 0cc185c0d7509caaa2f0acf1d2e3d5f89e4b1788..e2fbf7bc31437be8ba73aa51bdbc787a92118b75 100644 (file)
@@ -1,7 +1,7 @@
 ;;; org.el --- Outline-based notes management and organizer
 
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
@@ -381,7 +381,7 @@ core modules, nor modules from the CONTRIB directory).  Just add symbols
 to the end of the list.  If the package is called org-xyz.el, then you need
 to add the symbol `xyz', and the package must have a call to:
 
-   \(provide 'org-xyz)
+   (provide \\='org-xyz)
 
 For export specific modules, see also `org-export-backends'."
   :group 'org
@@ -465,26 +465,26 @@ need to make a change while Emacs is running, use the customize
 interface or run the following code, where VAL stands for the new
 value of the variable, after updating it:
 
-  \(progn
-    \(setq org-export--registered-backends
-          \(org-remove-if-not
-           \(lambda (backend)
-             \(let ((name (org-export-backend-name backend)))
-               \(or (memq name val)
-                   \(catch 'parentp
-                     \(dolist (b val)
-                       \(and (org-export-derived-backend-p b name)
-                            \(throw 'parentp t)))))))
+  (progn
+    (setq org-export--registered-backends
+          (org-remove-if-not
+           (lambda (backend)
+             (let ((name (org-export-backend-name backend)))
+               (or (memq name val)
+                   (catch \\='parentp
+                     (dolist (b val)
+                       (and (org-export-derived-backend-p b name)
+                            (throw \\='parentp t)))))))
            org-export--registered-backends))
-    \(let ((new-list (mapcar 'org-export-backend-name
+    (let ((new-list (mapcar \\='org-export-backend-name
                             org-export--registered-backends)))
-      \(dolist (backend val)
-        \(cond
-         \((not (load (format \"ox-%s\" backend) t t))
-          \(message \"Problems while trying to load export back-end `%s'\"
+      (dolist (backend val)
+        (cond
+         ((not (load (format \"ox-%s\" backend) t t))
+          (message \"Problems while trying to load export back-end \\=`%s\\='\"
                    backend))
-         \((not (memq backend new-list)) (push backend new-list))))
-      \(set-default 'org-export-backends new-list)))
+         ((not (memq backend new-list)) (push backend new-list))))
+      (set-default \\='org-export-backends new-list)))
 
 Adding a back-end to this list will also pull the back-end it
 depends on, if any."
@@ -827,7 +827,7 @@ When nil, just use the standard three dots.
 When a string, use that string instead.
 When a face, use the standard 3 dots, but with the specified face.
 The change affects only Org-mode (which will then use its own display table).
-Changing this requires executing `M-x org-mode RET' in a buffer to become
+Changing this requires executing `\\[org-mode]' in a buffer to become
 effective."
   :group 'org-startup
   :type '(choice (const :tag "Default" nil)
@@ -1548,8 +1548,8 @@ links in Org-mode buffers can have an optional tag after a double colon, e.g.
 
      [[linkkey:tag][description]]
 
-The 'linkkey' must be a word word, starting with a letter, followed
-by letters, numbers, '-' or '_'.
+The `linkkey' must be a word word, starting with a letter, followed
+by letters, numbers, `-' or `_'.
 
 If REPLACE is a string, the tag will simply be appended to create the link.
 If the string contains \"%s\", the tag will be inserted there.  If the string
@@ -1982,7 +1982,7 @@ file identifier are
                  filename matches the regexp.  If you want to
                  use groups here, use shy groups.
 
-                 Example: (\"\\.x?html\\'\" . \"firefox %s\")
+                 Example: (\"\\.x?html\\\\='\" . \"firefox %s\")
                           (\"\\(?:xhtml\\|html\\)\" . \"firefox %s\")
                           to open *.html and *.xhtml with firefox.
 
@@ -1998,7 +1998,7 @@ file identifier are
                  In a custom lisp form, you can access the group matches with
                  (match-string n link).
 
-                 Example: (\"\\.pdf::\\(\\d+\\)\\'\" . \"evince -p %1 %s\")
+                 Example: (\"\\.pdf::\\(\\d+\\)\\\\='\" . \"evince -p %1 %s\")
                      to open [[file:document.pdf::5]] with evince at page 5.
 
  `directory'   Matches a directory
@@ -2254,7 +2254,7 @@ fast, while still showing the whole path to the entry."
   :type 'boolean)
 
 (defcustom org-refile-allow-creating-parent-nodes nil
-  "Non-nil means allow to create new nodes as refile targets.
+  "Non-nil means allow the creation of new nodes as refile targets.
 New nodes are then created by adding \"/new node name\" to the completion
 of an existing node.  When the value of this variable is `confirm',
 new node creation must be confirmed by the user (recommended).
@@ -2487,7 +2487,7 @@ TODO state changes
 ------------------
 :type  todo-state-change
 :from  previous state (keyword as a string), or nil, or a symbol
-       'todo' or 'done', to indicate the general type of state.
+       `todo' or `done', to indicate the general type of state.
 :to    new state, like in :from")
 
 (defcustom org-enforce-todo-dependencies nil
@@ -2957,7 +2957,7 @@ its value is 0.
 
 For example,
 
-  \(:days \"%dd\" :hours \"%d\" :require-hours t :minutes \":%02d\"
+   (:days \"%dd\" :hours \"%d\" :require-hours t :minutes \":%02d\"
     :require-minutes t)
 
 means durations longer than a day will be expressed in days,
@@ -2967,7 +2967,7 @@ hour).
 
 The value
 
-  \(:days \"%dd\" :minutes \"%dm\")
+  (:days \"%dd\" :minutes \"%dm\")
 
 means durations longer than a day will be expressed in days and
 minutes, and durations less than a day will be expressed entirely
@@ -3291,10 +3291,10 @@ Instead of customizing this variable directly, you might want to
 set it locally for capture buffers, because there no list of
 tags in that file can be created dynamically (there are none).
 
-  (add-hook 'org-capture-mode-hook
+  (add-hook \\='org-capture-mode-hook
             (lambda ()
               (set (make-local-variable
-                    'org-complete-tags-always-offer-all-agenda-tags)
+                    \\='org-complete-tags-always-offer-all-agenda-tags)
                    t)))"
   :group 'org-tags
   :version "24.1"
@@ -3802,8 +3802,8 @@ images at the same place."
 
 (defcustom org-format-latex-header "\\documentclass{article}
 \\usepackage[usenames]{color}
-\[PACKAGES]
-\[DEFAULT-PACKAGES]
+[PACKAGES]
+[DEFAULT-PACKAGES]
 \\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
@@ -3889,7 +3889,7 @@ a string.
 
 A cell is of the format:
 
-  \( \"options\" \"package\" SNIPPET-FLAG).
+  ( \"options\" \"package\" SNIPPET-FLAG).
 
 If SNIPPET-FLAG is non-nil, the package also needs to be included
 when compiling LaTeX snippets into images for inclusion into
@@ -3917,7 +3917,7 @@ Each element is either a cell or a string.
 
 A cell is of the format:
 
-    \(\"options\" \"package\" SNIPPET-FLAG)
+    (\"options\" \"package\" SNIPPET-FLAG)
 
 SNIPPET-FLAG, when non-nil, indicates that this package is also
 needed when turning LaTeX snippets into images for inclusion into
@@ -3974,7 +3974,7 @@ lines to the buffer:
 
 (defcustom org-hidden-keywords nil
   "List of symbols corresponding to keywords to be hidden the org buffer.
-For example, a value '(title) for this list will make the document's title
+For example, a value \\='(title) for this list will make the document's title
 appear in the buffer without the initial #+TITLE: keyword."
   :group 'org-appearance
   :version "24.1"
@@ -5280,7 +5280,6 @@ This variable is set by `org-before-change-function'.
 
 ;; Other stuff we need.
 (require 'time-date)
-(unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time))
 (require 'easymenu)
 (require 'overlay)
 
@@ -5514,8 +5513,8 @@ the rounding returns a past time."
            (apply 'encode-time
                   (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r)))))
                           (nthcdr 2 time))))
-      (if (and past (< (org-float-time (time-subtract (current-time) res)) 0))
-         (seconds-to-time (- (org-float-time res) (* r 60)))
+      (if (and past (< (float-time (time-subtract (current-time) res)) 0))
+         (seconds-to-time (- (float-time res) (* r 60)))
        res))))
 
 (defun org-today ()
@@ -6629,7 +6628,7 @@ in special contexts.
        ;; Table: enter it or move to the next field.
        ((org-at-table-p 'any)
        (if (org-at-table.el-p)
-           (message "Use C-c ' to edit table.el tables")
+           (message "%s" "Use C-c ' to edit table.el tables")
          (if arg (org-table-edit-field t)
            (org-table-justify-field-maybe)
            (call-interactively 'org-table-next-field))))
@@ -7094,7 +7093,7 @@ open and agenda-wise Org files."
          (org-flag-drawer t))))))
 
 (defun org-cycle-hide-inline-tasks (state)
-  "Re-hide inline tasks when switching to 'contents or 'children
+  "Re-hide inline tasks when switching to `contents' or `children'
 visibility state."
   (case state
     (contents
@@ -7302,7 +7301,7 @@ Optional arguments START and END can be used to limit the range."
 (defconst org-goto-help
   "Browse buffer copy, to find location or copy text.%s
 RET=jump to location             C-g=quit and return to previous location
-\[Up]/[Down]=next/prev headline   TAB=cycle visibility   [/] org-occur")
+[Up]/[Down]=next/prev headline   TAB=cycle visibility   [/] org-occur")
 
 (defvar org-goto-start-pos) ; dynamically scoped parameter
 
@@ -7323,8 +7322,8 @@ returns to the original buffer in which the visibility is still
 unchanged.  After RET it will also jump to the location selected
 in the indirect buffer and expose the headline hierarchy above.
 
-With a prefix argument, use the alternative interface: e.g. if
-`org-goto-interface' is 'outline use 'outline-path-completion."
+With a prefix argument, use the alternative interface: e.g., if
+`org-goto-interface' is `outline' use `outline-path-completion'."
   (interactive "P")
   (org-goto-map)
   (let* ((org-refile-targets `((nil . (:maxlevel . ,org-goto-max-level))))
@@ -7682,7 +7681,7 @@ command."
              (re-search-forward org-outline-regexp-bol)
              (beginning-of-line 0))
            (skip-chars-backward " \r\n")
-           (and (not (looking-back "^\*+" (line-beginning-position)))
+           (and (not (looking-back "^\\*+" (line-beginning-position)))
                 (looking-at "[ \t]+") (replace-match ""))
            (unless (eobp) (forward-char 1))
            (when (looking-at "^\\*")
@@ -8779,24 +8778,24 @@ links."
               (if (or (re-search-forward org-ts-regexp end t)
                       (re-search-forward org-ts-regexp-both end t))
                   (org-time-string-to-seconds (match-string 0))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?c)
             (let ((end (save-excursion (outline-next-heading) (point))))
               (if (re-search-forward
                    (concat "^[ \t]*\\[" org-ts-regexp1 "\\]")
                    end t)
                   (org-time-string-to-seconds (match-string 0))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?s)
             (let ((end (save-excursion (outline-next-heading) (point))))
               (if (re-search-forward org-scheduled-time-regexp end t)
                   (org-time-string-to-seconds (match-string 1))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?d)
             (let ((end (save-excursion (outline-next-heading) (point))))
               (if (re-search-forward org-deadline-time-regexp end t)
                   (org-time-string-to-seconds (match-string 1))
-                (org-float-time now))))
+                (float-time now))))
            ((= dcst ?p)
             (if (re-search-forward org-priority-regexp (point-at-eol) t)
                 (string-to-char (match-string 2))
@@ -8860,7 +8859,7 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
            (lambda (x)
              (if (or (string-match org-ts-regexp x)
                      (string-match org-ts-regexp-both x))
-                 (org-float-time
+                 (float-time
                   (org-time-string-to-time (match-string 0 x)))
                0))
            comparefun (if (= dcst sorting-type) '< '>)))
@@ -11187,7 +11186,7 @@ org-open-file.
 It assumes that is the case when the entry uses a regular
 expression which has at least one grouping construct and the
 action is either a lisp form or a command string containing
-'%1', i.e. using at least one subexpression match as a
+`%1', i.e. using at least one subexpression match as a
 parameter."
   (let ((selector (car entry))
        (action (cdr entry)))
@@ -11389,7 +11388,7 @@ on the system \"/user@host:\"."
                         (setq level (org-reduced-level
                                      (- (match-end 1) (match-beginning 1)))
                               txt (org-link-display-format (match-string 4))
-                              txt (replace-regexp-in-string "\\( *\[[0-9]+/?[0-9]*%?\]\\)+$" "" txt)
+                              txt (replace-regexp-in-string "\\( *[[0-9]+/?[0-9]*%?]\\)+$" "" txt)
                               re (format org-complex-heading-regexp-format
                                          (regexp-quote (match-string 4))))
                         (when org-refile-use-outline-path
@@ -12222,13 +12221,13 @@ With a triple \\[universal-argument] prefix, circumvent any state blocking.
 With a numeric prefix arg of 0, inhibit note taking for the change.
 
 For calling through lisp, arg is also interpreted in the following way:
-'none             -> empty state
-\"\"(empty string)  -> switch to empty state
-'done             -> switch to DONE
-'nextset          -> switch to the next set of keywords
-'previousset      -> switch to the previous set of keywords
-\"WAITING\"         -> switch to the specified keyword, but only if it
-                     really is a member of `org-todo-keywords'."
+`none'             -> empty state
+\"\" (empty string)  -> switch to empty state
+`done'             -> switch to DONE
+`nextset'          -> switch to the next set of keywords
+`previousset'      -> switch to the previous set of keywords
+\"WAITING\"          -> switch to the specified keyword, but only if it
+                      really is a member of `org-todo-keywords'."
   (interactive "P")
   (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
       (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
@@ -15069,7 +15068,7 @@ a *different* entry, you cannot use these techniques."
          (if (not scope)
              (progn
                (org-agenda-prepare-buffers
-                (list (buffer-file-name (current-buffer))))
+                (and buffer-file-name (list buffer-file-name)))
                (setq res (org-scan-tags func matcher todo-only start-level)))
            ;; Get the right scope
            (cond
@@ -15081,7 +15080,7 @@ a *different* entry, you cannot use these techniques."
              (setq scope (org-agenda-files t))
              (setq scope (org-add-archive-files scope)))
             ((eq scope 'file)
-             (setq scope (list (buffer-file-name))))
+             (setq scope (and buffer-file-name (list buffer-file-name))))
             ((eq scope 'file-with-archives)
              (setq scope (org-add-archive-files (list (buffer-file-name))))))
            (org-agenda-prepare-buffers scope)
@@ -16355,7 +16354,7 @@ While prompting, a calendar is popped up - you can also select the
 date with the mouse (button 1).  The calendar shows a period of three
 months.  To scroll it to other months, use the keys `>' and `<'.
 If you don't like the calendar, turn it off with
-       \(setq org-read-date-popup-calendar nil)
+       (setq org-read-date-popup-calendar nil)
 
 With optional argument TO-TIME, the date will immediately be converted
 to an internal time.
@@ -16886,7 +16885,7 @@ Don't touch the rest."
 (defun org-time-stamp-to-now (timestamp-string &optional seconds)
   "Difference between TIMESTAMP-STRING and now in days.
 If SECONDS is non-nil, return the difference in seconds."
-  (let ((fdiff (if seconds 'org-float-time 'time-to-days)))
+  (let ((fdiff (if seconds 'float-time 'time-to-days)))
     (- (funcall fdiff (org-time-string-to-time timestamp-string))
        (funcall fdiff (current-time)))))
 
@@ -17041,8 +17040,8 @@ days in order to avoid rounding problems."
          (match-end (match-end 0))
          (time1 (org-time-string-to-time ts1))
          (time2 (org-time-string-to-time ts2))
-         (t1 (org-float-time time1))
-         (t2 (org-float-time time2))
+         (t1 (float-time time1))
+         (t2 (float-time time2))
          (diff (abs (- t2 t1)))
          (negative (< (- t2 t1) 0))
          ;; (ys (floor (* 365 24 60 60)))
@@ -17102,12 +17101,12 @@ days in order to avoid rounding problems."
     (error (error "Bad timestamp `%s'%s\nError was: %s"
                  s (if (not (and buffer pos))
                        ""
-                     (format " at %d in buffer `%s'" pos buffer))
+                     (format-message " at %d in buffer `%s'" pos buffer))
                  (cdr errdata)))))
 
 (defun org-time-string-to-seconds (s)
   "Convert a timestamp string to a number of seconds."
-  (org-float-time (org-time-string-to-time s)))
+  (float-time (org-time-string-to-time s)))
 
 (defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos)
   "Convert a time stamp to an absolute day number.
@@ -17130,7 +17129,7 @@ The variable `date' is bound by the calendar when this is called."
         (error (error "Bad timestamp `%s'%s\nError was: %s"
                       s (if (not (and buffer pos))
                             ""
-                          (format " at %d in buffer `%s'" pos buffer))
+                          (format-message " at %d in buffer `%s'" pos buffer))
                       (cdr errdata))))))))
 
 (defun org-days-to-iso-week (days)
@@ -17459,8 +17458,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"."
                         (+ (if (eq org-ts-what 'hour) n 0)   (nth 2 time0))
                         (+ (if (eq org-ts-what 'day) n 0)    (nth 3 time0))
                         (+ (if (eq org-ts-what 'month) n 0)  (nth 4 time0))
-                        (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))
-                        (nthcdr 6 time0)))
+                        (+ (if (eq org-ts-what 'year) n 0)   (nth 5 time0))))
       (when (and (member org-ts-what '(hour minute))
                 extra
                 (string-match "-\\([012][0-9]\\):\\([0-5][0-9]\\)" extra))
@@ -17912,7 +17910,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
           ((eq predicate 'files)
            (lambda (b) (with-current-buffer b (derived-mode-p 'org-mode))))
           ((eq predicate 'export)
-           (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
+           (lambda (b) (string-match "\\*Org .*Export" (buffer-name b))))
           ((eq predicate 'agenda)
            (lambda (b)
              (with-current-buffer b
@@ -17921,7 +17919,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
                     (member (file-truename bfn) agenda-files)))))
           (t (lambda (b) (with-current-buffer b
                            (or (derived-mode-p 'org-mode)
-                               (string-match "\*Org .*Export"
+                               (string-match "\\*Org .*Export"
                                              (buffer-name b)))))))))
     (delq nil
          (mapcar
@@ -20446,7 +20444,7 @@ This command does many different things, depending on context:
           ;; a `table.el' type, just give up.  At a table row or
           ;; cell, maybe recalculate line but always align table.
           (if (eq (org-element-property :type context) 'table.el)
-              (message "Use C-c ' to edit table.el tables")
+              (message "%s" "Use C-c ' to edit table.el tables")
             (let ((org-enable-table-editor t))
               (if (or (eq type 'table)
                       ;; Check if point is at a TBLFM line.
@@ -21871,8 +21869,8 @@ for the search purpose."
 
 For example, in this alist:
 
-\(org-uniquify-alist '((a 1) (b 2) (a 3)))
-  => '((a 1 3) (b 2))
+\(org-uniquify-alist \\='((a 1) (b 2) (a 3)))
+  => \\='((a 1 3) (b 2))
 
 merge (a 1) and (a 3) into (a 1 3).
 
@@ -22663,7 +22661,7 @@ contains commented lines.  Otherwise, comment them."
   "Non-nil when TIMESTAMP has a time specified."
   (org-element-property :hour-start timestamp))
 
-(defun org-timestamp-format (timestamp format &optional end utc)
+(defun org-timestamp-format (timestamp format &optional end zone)
   "Format a TIMESTAMP element into a string.
 
 FORMAT is a format specifier to be passed to
@@ -22672,8 +22670,11 @@ FORMAT is a format specifier to be passed to
 When optional argument END is non-nil, use end of date-range or
 time-range, if possible.
 
-When optional argument UTC is non-nil, time will be expressed as
-Universal Time."
+The optional ZONE is omitted or nil for Emacs local time, t for
+Universal Time, `wall' for system wall clock time, or a string as
+in the TZ environment variable.  It can also be a list (as from
+`current-time-zone') or an integer (as from `decode-time')
+applied without consideration for daylight saving time."
   (format-time-string
    format
    (apply 'encode-time
@@ -22683,7 +22684,7 @@ Universal Time."
                  (if end '(:minute-end :hour-end :day-end :month-end :year-end)
                    '(:minute-start :hour-start :day-start :month-start
                                    :year-start)))))
-   utc))
+   zone))
 
 (defun org-timestamp-split-range (timestamp &optional end)
   "Extract a timestamp object from a date or time range.
@@ -23005,7 +23006,7 @@ no special treatment.  In particular, a simple \\[universal-argument] prefix \
 will just
 plainly yank the text as it is.
 
-\[1] The test checks if the first non-white line is a heading
+[1] The test checks if the first non-white line is a heading
     and if there are no other headings with fewer stars."
   (interactive "P")
   (org-yank-generic 'yank arg))