emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8db56235cbc 5/7: Prefer ticks/hz pairs for some ERC timestamps on


From: F. Jason Park
Subject: master 8db56235cbc 5/7: Prefer ticks/hz pairs for some ERC timestamps on 29+
Date: Mon, 2 Oct 2023 20:38:28 -0400 (EDT)

branch: master
commit 8db56235cbcb2afc03a3aa0691cc0795c7da43fb
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>

    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)
---
 lisp/erc/erc-compat.el | 15 +++++++++++++++
 lisp/erc/erc-stamp.el  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

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."
                  (cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc)
                        existing))))))
 
+;; We can't store (TICKS . HZ) style timestamps on 27 and 28 because
+;; `time-less-p' and friends do
+;;
+;;   message("obsolete timestamp with cdr ...", ...)
+;;   decode_lisp_time(_, WARN_OBSOLETE_TIMESTAMPS, ...)
+;;   lisp_time_struct(...)
+;;   time_cmp(...)
+;;
+;; which spams *Messages* (and stderr when running the test suite).
+(defmacro erc-compat--current-lisp-time ()
+  "Return `current-time' as a (TICKS . HZ) pair on 29+."
+  (if (>= emacs-major-version 29)
+      '(let (current-time-list) (current-time))
+    '(current-time)))
+
 
 (provide 'erc-compat)
 
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'.")
 (cl-defgeneric erc-stamp--current-time ()
   "Return a lisp time object to associate with an IRC message.
 This becomes the message's `erc-timestamp' text property."
-  (let (current-time-list) (current-time)))
+  (erc-compat--current-lisp-time))
 
 (cl-defmethod erc-stamp--current-time :around ()
   (or erc-stamp--current-time (cl-call-next-method)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]