]> 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 7a6d6cc1b3fd4af54ac8c7c31b301f737b318a76..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>
@@ -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).
@@ -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 ()
@@ -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
@@ -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))))
@@ -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) '< '>)))
@@ -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)
@@ -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)))
@@ -17107,7 +17106,7 @@ days in order to avoid rounding problems."
 
 (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.
@@ -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))
@@ -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.