Ver código fonte

Prune Emacs 25.1 compatibility kludges

* lisp/oc-basic.el (org-cite-basic--field-less-p):
* lisp/ol-eww.el (org-eww-store-link):
* lisp/org-agenda.el (org-agenda-check-clock-gap):
* lisp/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve-clock, org-clock-resolve)
(org-resolve-clocks, (org-resolve-clocks-if-idle)
(org-clock-in, org-clock-sum): Drop now unnecessary use of
compatibility functions.

* lisp/org-compat.el (org-string-collate-lessp, org-decode-time)
(org-format-time-string, org-link-escape-browser, org-time-add)
(org-time-subtract, org-time-since, org-time-less-p): Mark as
obsolete.

The 9.5 release declared Emacs 25.1 as the minimum version.
Kyle Meyer 3 anos atrás
pai
commit
cc2490a706

+ 1 - 1
lisp/oc-basic.el

@@ -535,7 +535,7 @@ INFO is the export state as a property list."
 INFO is the export state, as a property list."
   (and field
        (lambda (a b)
-         (org-string-collate-lessp
+         (string-collate-lessp
           (org-cite-basic--get-field field a info 'raw)
           (org-cite-basic--get-field field b info 'raw)
           nil t))))

+ 3 - 11
lisp/ol-eww.el

@@ -48,10 +48,6 @@
 (require 'cl-lib)
 (require 'eww)
 
-;; For Emacsen < 25.
-(defvar eww-current-title)
-(defvar eww-current-url)
-
 
 ;; Store Org link in Eww mode buffer
 (org-link-set-parameters "eww"
@@ -67,14 +63,10 @@
   (when (eq major-mode 'eww-mode)
     (org-link-store-props
      :type "eww"
-     :link (if (< emacs-major-version 25)
-	       eww-current-url
-	     (eww-current-url))
+     :link (eww-current-url)
      :url (url-view-url t)
-     :description (if (< emacs-major-version 25)
-		      (or eww-current-title eww-current-url)
-		    (or (plist-get eww-data :title)
-			(eww-current-url))))))
+     :description (or (plist-get eww-data :title)
+                      (eww-current-url)))))
 
 
 ;; Some auxiliary functions concerning links in Eww buffers

+ 2 - 2
lisp/org-agenda.el

@@ -6147,8 +6147,8 @@ See also the user option `org-agenda-clock-consistency-checks'."
       (throw 'exit t))
     ;; We have a shorter gap.
     ;; Now we have to get the minute of the day when these times are
-    (let* ((t1dec (org-decode-time t1))
-	   (t2dec (org-decode-time t2))
+    (let* ((t1dec (decode-time t1))
+	   (t2dec (decode-time t2))
 	   ;; compute the minute on the day
 	   (min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec))))
 	   (min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec)))))

+ 12 - 12
lisp/org-clock.el

@@ -770,7 +770,7 @@ The time returned includes the time spent on this task in
 previous clocking intervals."
   (let ((currently-clocked-time
 	 (floor (org-time-convert-to-integer
-		 (org-time-since org-clock-start-time))
+		 (time-since org-clock-start-time))
 		60)))
     (+ currently-clocked-time (or org-clock-total-time 0))))
 
@@ -1000,7 +1000,7 @@ CLOCK is a cons cell of the form (MARKER START-TIME)."
 	 (org-clock-clock-out clock fail-quietly))
 	((org-is-active-clock clock) nil)
 	(t (org-clock-clock-in clock t))))
-      ((pred (org-time-less-p nil))
+      ((pred (time-less-p nil))
        (error "RESOLVE-TO must refer to a time in the past"))
       (_
        (when restart (error "RESTART is not valid here"))
@@ -1102,7 +1102,7 @@ to be CLOCKED OUT."))))
 				   nil 45)))
 		(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
 	 (default
-	   (floor (org-time-convert-to-integer (org-time-since last-valid))
+	   (floor (org-time-convert-to-integer (time-since last-valid))
 		  60))
 	 (keep
 	  (or (and (memq ch '(?k ?K))
@@ -1110,14 +1110,14 @@ to be CLOCKED OUT."))))
 	      (and (memq ch '(?t ?T))
 		   (floor
 		    (/ (float-time
-			(org-time-subtract (org-read-date t t) last-valid))
+			(time-subtract (org-read-date t t) last-valid))
 		       60)))))
 	 (gotback
 	  (and (memq ch '(?g ?G))
 	       (read-number "Got back how many minutes ago? " default)))
 	 (subtractp (memq ch '(?s ?S)))
-	 (barely-started-p (org-time-less-p
-			    (org-time-subtract last-valid (cdr clock))
+	 (barely-started-p (time-less-p
+			    (time-subtract last-valid (cdr clock))
 			    45))
 	 (start-over (and subtractp barely-started-p)))
     (cond
@@ -1144,9 +1144,9 @@ to be CLOCKED OUT."))))
 		   (and gotback (= gotback default)))
 	       'now)
 	      (keep
-	       (org-time-add last-valid (* 60 keep)))
+	       (time-add last-valid (* 60 keep)))
 	      (gotback
-	       (org-time-since (* 60 gotback)))
+	       (time-since (* 60 gotback)))
 	      (t
 	       (error "Unexpected, please report this as a bug")))
        (and gotback last-valid)
@@ -1176,7 +1176,7 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
 			 (format
 			  "Dangling clock started %d mins ago"
 			  (floor (org-time-convert-to-integer
-				  (org-time-since (cdr clock)))
+				  (time-since (cdr clock)))
 				 60))))
 		   (or last-valid
 		       (cdr clock)))))))))))
@@ -1227,7 +1227,7 @@ so long."
 	     org-clock-marker (marker-buffer org-clock-marker))
     (let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
 	   (org-clock-user-idle-start
-	    (org-time-since org-clock-user-idle-seconds))
+	    (time-since org-clock-user-idle-seconds))
 	   (org-clock-resolving-clocks-due-to-idleness t))
       (if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
 	  (org-clock-resolve
@@ -1388,7 +1388,7 @@ the default behavior."
 			   (format
 			    "You stopped another clock %d mins ago; start this one from then? "
 			    (/ (org-time-convert-to-integer
-				(org-time-subtract
+				(time-subtract
 				 (org-current-time org-clock-rounding-minutes t)
 				 leftover))
 			       60)))
@@ -1928,7 +1928,7 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
 		       (>= (float-time org-clock-start-time) tstart)
 		       (<= (float-time org-clock-start-time) tend))
 	      (let ((time (floor (org-time-convert-to-integer
-				  (org-time-since org-clock-start-time))
+				  (time-since org-clock-start-time))
 				 60)))
 		(setq t1 (+ t1 time))))
 	    (let* ((headline-forced

+ 8 - 64
lisp/org-compat.el

@@ -180,70 +180,6 @@ as (current-time)."
 This is a floating point number if the size is too large for an integer."
     (nth 7 attributes)))
 
-
-;;; Emacs < 25.1 compatibility
-
-(when (< emacs-major-version 25)
-  (defalias 'outline-hide-entry 'hide-entry)
-  (defalias 'outline-hide-sublevels 'hide-sublevels)
-  (defalias 'outline-hide-subtree 'hide-subtree)
-  (defalias 'outline-show-branches 'show-branches)
-  (defalias 'outline-show-children 'show-children)
-  (defalias 'outline-show-entry 'show-entry)
-  (defalias 'outline-show-subtree 'show-subtree)
-  (defalias 'xref-find-definitions 'find-tag)
-  (defalias 'format-message 'format)
-  (defalias 'gui-get-selection 'x-get-selection))
-
-(unless (fboundp 'directory-name-p)
-  (defun directory-name-p (name)
-    "Return non-nil if NAME ends with a directory separator character."
-    (let ((len (length name))
-	  (lastc ?.))
-      (if (> len 0)
-	  (setq lastc (aref name (1- len))))
-      (or (= lastc ?/)
-	  (and (memq system-type '(windows-nt ms-dos))
-	       (= lastc ?\\))))))
-
-;; `string-collate-lessp' is new in Emacs 25.
-(if (fboundp 'string-collate-lessp)
-    (defalias 'org-string-collate-lessp
-      'string-collate-lessp)
-  (defun org-string-collate-lessp (s1 s2 &rest _)
-    "Return non-nil if STRING1 is less than STRING2 in lexicographic order.
-Case is significant."
-    (string< s1 s2)))
-
-;; The time- functions below translate nil to 'current-time' and
-;; accept an integer as of Emacs 25.  'decode-time' and
-;; 'format-time-string' accept nil on Emacs 24 but don't accept an
-;; integer until Emacs 25.
-(if (< emacs-major-version 25)
-    (let ((convert
-           (lambda (time)
-             (cond ((not time) (current-time))
-                   ((numberp time) (seconds-to-time time))
-                   (t time)))))
-      (defun org-decode-time (&optional time)
-        (decode-time (funcall convert time)))
-      (defun org-format-time-string (format-string &optional time universal)
-        (format-time-string format-string (funcall convert time) universal))
-      (defun org-time-add (a b)
-        (time-add (funcall convert a) (funcall convert b)))
-      (defun org-time-subtract (a b)
-        (time-subtract (funcall convert a) (funcall convert b)))
-      (defun org-time-since (time)
-        (time-since (funcall convert time)))
-      (defun org-time-less-p (t1 t2)
-        (time-less-p (funcall convert t1) (funcall convert t2))))
-  (defalias 'org-decode-time 'decode-time)
-  (defalias 'org-format-time-string 'format-time-string)
-  (defalias 'org-time-add 'time-add)
-  (defalias 'org-time-subtract 'time-subtract)
-  (defalias 'org-time-since 'time-since)
-  (defalias 'org-time-less-p 'time-less-p))
-
 
 ;;; Obsolete aliases (remove them after the next major release).
 
@@ -289,6 +225,14 @@ Counting starts at 1."
                "use cl-subseq (note the 0-based counting)."
                "9.0")
 
+;;;; Functions available since Emacs 25.1
+(define-obsolete-function-alias 'org-string-collate-lessp 'string-collate-lessp "9.6")
+(define-obsolete-function-alias 'org-decode-time 'decode-time "9.6")
+(define-obsolete-function-alias 'org-format-time-string 'format-time-string "9.6")
+(define-obsolete-function-alias 'org-time-add 'time-add "9.6")
+(define-obsolete-function-alias 'org-time-subtract 'time-subtract "9.6")
+(define-obsolete-function-alias 'org-time-since 'time-since "9.6")
+(define-obsolete-function-alias 'org-time-less-p 'time-less-p "9.6")
 
 ;;;; Functions available since Emacs 24.3
 (define-obsolete-function-alias 'org-buffer-narrowed-p 'buffer-narrowed-p "9.0")

+ 3 - 4
lisp/org-element.el

@@ -5336,7 +5336,7 @@ Assume ELEMENT belongs to cache and that a cache is active."
   (setq org-element--cache-sync-timer
 	(run-with-idle-timer
 	 (let ((idle (current-idle-time)))
-	   (if idle (org-time-add idle org-element-cache-sync-break)
+	   (if idle (time-add idle org-element-cache-sync-break)
 	     org-element-cache-sync-idle-time))
 	 nil
 	 #'org-element--cache-sync
@@ -5347,7 +5347,7 @@ Assume ELEMENT belongs to cache and that a cache is active."
 TIME-LIMIT is a time value or nil."
   (and time-limit
        (or (input-pending-p)
-	   (org-time-less-p time-limit nil))))
+	   (time-less-p time-limit nil))))
 
 (defsubst org-element--cache-shift-positions (element offset &optional props)
   "Shift ELEMENT properties relative to buffer positions by OFFSET.
@@ -5401,8 +5401,7 @@ updated before current modification are actually submitted."
 	     (and next (aref next 0))
 	     threshold
 	     (and (not threshold)
-		  (org-time-add nil
-				org-element-cache-sync-duration))
+		  (time-add nil org-element-cache-sync-duration))
 	     future-change)
 	    ;; Request processed.  Merge current and next offsets and
 	    ;; transfer ending position.

+ 1 - 2
lisp/org-habit.el

@@ -423,8 +423,7 @@ current time."
   "Insert consistency graph for any habitual tasks."
   (let ((inhibit-read-only t)
 	(buffer-invisibility-spec '(org-link))
-	(moment (org-time-subtract nil
-				   (* 3600 org-extend-today-until))))
+	(moment (time-subtract nil (* 3600 org-extend-today-until))))
     (save-excursion
       (goto-char (if line (point-at-bol) (point-min)))
       (while (not (eobp))

+ 2 - 2
lisp/org-indent.el

@@ -330,7 +330,7 @@ stopped."
      (let* ((case-fold-search t)
 	    (limited-re (org-get-limited-outline-regexp))
 	    (level (or (org-current-level) 0))
-	    (time-limit (and delay (org-time-add nil delay))))
+	    (time-limit (and delay (time-add nil delay))))
        ;; For each line, set `line-prefix' and `wrap-prefix'
        ;; properties depending on the type of line (headline, inline
        ;; task, item or other).
@@ -343,7 +343,7 @@ stopped."
 	    ;; In asynchronous mode, take a break of
 	    ;; `org-indent-agent-resume-delay' every DELAY to avoid
 	    ;; blocking any other idle timer or process output.
-	    ((and delay (org-time-less-p time-limit nil))
+	    ((and delay (time-less-p time-limit nil))
 	     (setq org-indent-agent-resume-timer
 		   (run-with-idle-timer
 		    (time-add (current-idle-time) org-indent-agent-resume-delay)

+ 1 - 1
lisp/org-list.el

@@ -2910,7 +2910,7 @@ function is being called interactively."
 		   (error "Missing key extractor"))))
 	 (sort-func
 	  (cond
-	   ((= dcst ?a) #'org-string-collate-lessp)
+	   ((= dcst ?a) #'string-collate-lessp)
 	   ((= dcst ?f)
 	    (or compare-func
 		(and interactive?

+ 5 - 5
lisp/org-macs.el

@@ -36,7 +36,7 @@
 
 (declare-function org-mode "org" ())
 (declare-function org-show-context "org" (&optional key))
-(declare-function org-string-collate-lessp "org-compat" (s1 s2 &optional locale ignore-case))
+(declare-function string-collate-lessp "org-compat" (s1 s2 &optional locale ignore-case))
 
 (defvar org-ts-regexp0)
 (defvar ffap-url-regexp)
@@ -825,17 +825,17 @@ return nil."
 ;;; String manipulation
 
 (defun org-string< (a b)
-  (org-string-collate-lessp a b))
+  (string-collate-lessp a b))
 
 (defun org-string<= (a b)
-  (or (string= a b) (org-string-collate-lessp a b)))
+  (or (string= a b) (string-collate-lessp a b)))
 
 (defun org-string>= (a b)
-  (not (org-string-collate-lessp a b)))
+  (not (string-collate-lessp a b)))
 
 (defun org-string> (a b)
   (and (not (string= a b))
-       (not (org-string-collate-lessp a b))))
+       (not (string-collate-lessp a b))))
 
 (defun org-string<> (a b)
   (not (string= a b)))

+ 3 - 3
lisp/org-table.el

@@ -2868,7 +2868,7 @@ ARGS are passed as arguments to the `message' function.  Returns
 current time if a message is printed, otherwise returns T1.  If
 T1 is nil, always messages."
   (let ((curtime (current-time)))
-    (if (or (not t1) (org-time-less-p 1 (org-time-subtract curtime t1)))
+    (if (or (not t1) (time-less-p 1 (time-subtract curtime t1)))
 	(progn (apply 'message args)
 	       curtime)
       t1)))
@@ -4562,8 +4562,8 @@ function is being called interactively."
 	     (predicate
 	      (cl-case sorting-type
 		((?n ?N ?t ?T) #'<)
-		((?a ?A) (if with-case #'org-string-collate-lessp
-			   (lambda (s1 s2) (org-string-collate-lessp s1 s2 nil t))))
+		((?a ?A) (if with-case #'string-collate-lessp
+			   (lambda (s1 s2) (string-collate-lessp s1 s2 nil t))))
 		((?f ?F)
 		 (or compare-func
 		     (and interactive?

+ 5 - 5
lisp/org-timer.el

@@ -139,7 +139,7 @@ the region 0:00:00."
 		   (format "Restart timer with offset [%s]: " def)))
 	  (unless (string-match "\\S-" s) (setq s def))
 	  (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s)))))
-	(setq org-timer-start-time (org-time-since delta)))
+	(setq org-timer-start-time (time-since delta)))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (message "Timer start time set to %s, current value is %s"
@@ -163,9 +163,9 @@ With prefix arg STOP, stop it entirely."
 	    (setq org-timer-countdown-timer
 		  (org-timer--run-countdown-timer
 		   new-secs org-timer-countdown-timer-title))
-	    (setq org-timer-start-time (org-time-add nil new-secs)))
+	    (setq org-timer-start-time (time-add nil new-secs)))
 	(setq org-timer-start-time
-	      (org-time-since (- pause-secs start-secs))))
+	      (time-since (- pause-secs start-secs))))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (run-hooks 'org-timer-continue-hook)
@@ -387,7 +387,7 @@ VALUE can be `on', `off', or `paused'."
       ;; Note: Once our minimal require is Emacs 27, we can drop this
       ;; org-time-convert-to-integer call.
       (org-time-convert-to-integer
-       (org-time-subtract (timer--time org-timer-countdown-timer) nil))))))
+       (time-subtract (timer--time org-timer-countdown-timer) nil))))))
 
 ;;;###autoload
 (defun org-timer-set-timer (&optional opt)
@@ -448,7 +448,7 @@ using three \\[universal-argument] prefix arguments."
 		(org-timer--run-countdown-timer
 		 secs org-timer-countdown-timer-title))
 	  (run-hooks 'org-timer-set-hook)
-	  (setq org-timer-start-time (org-time-add nil secs))
+	  (setq org-timer-start-time (time-add nil secs))
 	  (setq org-timer-pause-time nil)
 	  (org-timer-set-mode-line 'on))))))
 

+ 7 - 7
lisp/org.el

@@ -2974,7 +2974,7 @@ is better to limit inheritance to certain tags using the variables
   :group 'org-tags
   :type '(choice
 	  (const :tag "No sorting" nil)
-	  (const :tag "Alphabetical" org-string-collate-lessp)
+	  (const :tag "Alphabetical" string-collate-lessp)
 	  (const :tag "Reverse alphabetical" org-string-collate-greaterp)
 	  (function :tag "Custom function" nil)))
 
@@ -5019,14 +5019,14 @@ the rounding returns a past time."
       (let* ((time (decode-time now))
 	     (res (apply #'encode-time 0 (* r (round (nth 1 time) r))
 			 (nthcdr 2 time))))
-	(if (or (not past) (org-time-less-p res now))
+	(if (or (not past) (time-less-p res now))
 	    res
-	  (org-time-subtract res (* r 60)))))))
+	  (time-subtract res (* r 60)))))))
 
 (defun org-today ()
   "Return today date, considering `org-extend-today-until'."
   (time-to-days
-   (org-time-since (* 3600 org-extend-today-until))))
+   (time-since (* 3600 org-extend-today-until))))
 
 ;;;; Font-Lock stuff, including the activators
 
@@ -8430,7 +8430,7 @@ function is being called interactively."
 	     (t (error "Invalid sorting type `%c'" sorting-type))))
 	  nil
 	  (cond
-	   ((= dcst ?a) 'org-string-collate-lessp)
+	   ((= dcst ?a) 'string-collate-lessp)
 	   ((= dcst ?f)
 	    (or compare-func
 		(and interactive?
@@ -8530,7 +8530,7 @@ definitions."
 ;; string-collate-greaterp in Emacs.
 (defun org-string-collate-greaterp (s1 s2)
   "Return non-nil if S1 is greater than S2 in collation order."
-  (not (org-string-collate-lessp s1 s2)))
+  (not (string-collate-lessp s1 s2)))
 
 ;;;###autoload
 (defun org-run-like-in-org-mode (cmd)
@@ -10542,7 +10542,7 @@ This function is run automatically after each state change to a DONE state."
 		      (let ((nshiftmax 10)
 			    (nshift 0))
 			(while (or (= nshift 0)
-				   (not (org-time-less-p nil time)))
+				   (not (time-less-p nil time)))
 			  (when (= nshiftmax (cl-incf nshift))
 			    (or (y-or-n-p
 				 (format "%d repeater intervals were not \

+ 7 - 7
testing/lisp/test-org-macs.el

@@ -111,25 +111,25 @@
   (let ((system-time-locale "en_US"))
     (org-test-at-time "<2021-01-11 Mon 13:00>"
       (should (equal (list 0 0 13 11 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<now>"))
+                     (butlast (decode-time (org-matcher-time "<now>"))
                               3)))
       (should (equal (list 0 0 0 14 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<+3d>"))
+                     (butlast (decode-time (org-matcher-time "<+3d>"))
                               3)))
       (should (equal (list 0 0 0 9 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<-2d>"))
+                     (butlast (decode-time (org-matcher-time "<-2d>"))
                               3)))
       (should (equal (list 0 0 0 18 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<+1w>"))
+                     (butlast (decode-time (org-matcher-time "<+1w>"))
                               3)))
       (should (equal (list 0 0 17 11 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<+4h>"))
+                     (butlast (decode-time (org-matcher-time "<+4h>"))
                               3)))
       (should (equal (list 0 0 11 11 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<-2h>"))
+                     (butlast (decode-time (org-matcher-time "<-2h>"))
                               3)))
       (should (equal (list 0 0 3 12 1 2021)
-                     (butlast (org-decode-time (org-matcher-time "<+14h>"))
+                     (butlast (decode-time (org-matcher-time "<+14h>"))
                               3))))))
 
 (provide 'test-org-macs)