Browse Source

Backport commit a4a3c92e9 from Emacs

* lisp/org-agenda.el (org-cmp-ts): Avoid arbitrary limit to
most-positive-fixnum or to most-negative-fixnum.
* lisp/org-footnote.el (org-footnote-new): Simplify.
* lisp/org-element.el (org-element--cache-generate-key):
Document fixnum limitation.

Prune most-positive-fixnum from Lisp source
a4a3c92e9de59bd0251f36326375cce898919edc
Paul Eggert
Wed Aug 22 20:46:08 2018 -0700
Paul Eggert 10 months ago
parent
commit
9a8462771f
3 changed files with 5 additions and 5 deletions
  1. 3 3
      lisp/org-agenda.el
  2. 1 1
      lisp/org-element.el
  3. 1 1
      lisp/org-footnote.el

+ 3 - 3
lisp/org-agenda.el

@@ -7018,15 +7018,15 @@ When TYPE is \"scheduled\", \"deadline\", \"timestamp\" or
 \"timestamp_ia\", compare within each of these type.  When TYPE
 is the empty string, compare all timestamps without respect of
 their type."
-  (let* ((def (if org-sort-agenda-notime-is-late most-positive-fixnum -1))
+  (let* ((def (and (not org-sort-agenda-notime-is-late) -1))
 	 (ta (or (and (string-match type (or (get-text-property 1 'type a) ""))
 		      (get-text-property 1 'ts-date a))
 		 def))
 	 (tb (or (and (string-match type (or (get-text-property 1 'type b) ""))
 		      (get-text-property 1 'ts-date b))
 		 def)))
-    (cond ((< ta tb) -1)
-	  ((< tb ta) +1))))
+    (cond ((if ta (and tb (< ta tb)) tb) -1)
+	  ((if tb (and ta (< tb ta)) ta) +1))))
 
 (defsubst org-cmp-habit-p (a b)
   "Compare the todo states of strings A and B."

+ 1 - 1
lisp/org-element.el

@@ -4906,7 +4906,7 @@ table is cleared once the synchronization is complete."
 (defun org-element--cache-generate-key (lower upper)
   "Generate a key between LOWER and UPPER.
 
-LOWER and UPPER are integers or lists, possibly empty.
+LOWER and UPPER are fixnums or lists of same, possibly empty.
 
 If LOWER and UPPER are equals, return LOWER.  Otherwise, return
 a unique key, as an integer or a list of integers, according to

+ 1 - 1
lisp/org-footnote.el

@@ -654,7 +654,7 @@ or new, let the user edit the definition of the footnote."
   (let* ((all (org-footnote-all-labels))
 	 (label
 	  (if (eq org-footnote-auto-label 'random)
-	      (format "%x" (random most-positive-fixnum))
+	      (format "%x" (abs (random)))
 	    (org-footnote-normalize-label
 	     (let ((propose (org-footnote-unique-label all)))
 	       (if (eq org-footnote-auto-label t) propose