aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-09-18 22:50:28 -0700
committerF. Jason Park2023-10-02 17:31:28 -0700
commit8db56235cbcb2afc03a3aa0691cc0795c7da43fb (patch)
tree35f13a4b6522815eb69bcd7164c1e7b725c723de
parent06fb8b76208ad380d7d1e592394d3173249f31df (diff)
downloademacs-8db56235cbcb2afc03a3aa0691cc0795c7da43fb.tar.gz
emacs-8db56235cbcb2afc03a3aa0691cc0795c7da43fb.zip
Prefer ticks/hz pairs for some ERC timestamps on 29+
* lisp/erc/erc-compat.el (erc-compat--current-lisp-time): New macro to prefer ticks/hz pairs on newer Emacs versions because stamps of this form are easier to compare at a glance when used as values for text properties. * lisp/erc/erc-stamp.el (erc-stamp--current-time): Use compat macro. (Bug#60936)
-rw-r--r--lisp/erc/erc-compat.el15
-rw-r--r--lisp/erc/erc-stamp.el2
2 files changed, 16 insertions, 1 deletions
diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el
index 109b5d245ab..4c376cfbc22 100644
--- a/lisp/erc/erc-compat.el
+++ b/lisp/erc/erc-compat.el
@@ -444,6 +444,21 @@ If START or END is negative, it counts from the end."
444 (cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc) 444 (cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc)
445 existing)))))) 445 existing))))))
446 446
447;; We can't store (TICKS . HZ) style timestamps on 27 and 28 because
448;; `time-less-p' and friends do
449;;
450;; message("obsolete timestamp with cdr ...", ...)
451;; decode_lisp_time(_, WARN_OBSOLETE_TIMESTAMPS, ...)
452;; lisp_time_struct(...)
453;; time_cmp(...)
454;;
455;; which spams *Messages* (and stderr when running the test suite).
456(defmacro erc-compat--current-lisp-time ()
457 "Return `current-time' as a (TICKS . HZ) pair on 29+."
458 (if (>= emacs-major-version 29)
459 '(let (current-time-list) (current-time))
460 '(current-time)))
461
447 462
448(provide 'erc-compat) 463(provide 'erc-compat)
449 464
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index f159b6d226f..0f3163bf68d 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -215,7 +215,7 @@ the stamp passed to `erc-insert-timestamp-function'.")
215(cl-defgeneric erc-stamp--current-time () 215(cl-defgeneric erc-stamp--current-time ()
216 "Return a lisp time object to associate with an IRC message. 216 "Return a lisp time object to associate with an IRC message.
217This becomes the message's `erc-timestamp' text property." 217This becomes the message's `erc-timestamp' text property."
218 (let (current-time-list) (current-time))) 218 (erc-compat--current-lisp-time))
219 219
220(cl-defmethod erc-stamp--current-time :around () 220(cl-defmethod erc-stamp--current-time :around ()
221 (or erc-stamp--current-time (cl-call-next-method))) 221 (or erc-stamp--current-time (cl-call-next-method)))