1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Add erc--skip message property

* lisp/erc/erc-backend.el (erc-server-connect): Add `erc--skip'
property to `erc--msg-prop-overrides' so that timestamps only show up
with the first server-sent message.
(erc-server-PRIVMSG): Move `erc--msg-prop-overrides' declaration to
top-level.
* lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys):
Use `erc--skip' msg prop instead of `erc-stamp--skip' variable.
* lisp/erc/erc-stamp.el (erc-stamp--skip): Remove variable.
(erc-stamp--allow-unmanaged, erc-stamp--allow-unmanaged-p): Rename
former to latter to remain consistent with convention used by other
quasi-internal compatibility-related switches.
(erc-add-timestamp): Check `erc--skip' property instead of deleted
variable `erc-stamp--skip'.
* lisp/erc/erc.el (erc--msg-props): Mention `erc--skip' in doc.
(erc--check-msg-prop): Doc.
(erc--memq-msg-prop): New function.
(erc--ranked-properties): Add `erc--skip'.
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--legacy-date-stamps): Revise to expect
"opening connection.." to appear above first stamp.
* test/lisp/erc/erc-tests.el (erc--memq-msg-prop): New test.
(Bug#60936)
This commit is contained in:
F. Jason Park 2024-04-18 22:18:57 -07:00
parent 86184cba21
commit 6000e48e0d
6 changed files with 39 additions and 19 deletions

View file

@ -181,6 +181,9 @@ as of ERC 5.6:
5.6, a ticks/hertz pair on Emacs 29 and above, and a \"list\"
type otherwise; managed by the `stamp' module
- `erc--skip': list of symbols known to modules that indicate an
intent to skip or simplify module-specific processing
- `erc--ephemeral': a symbol prefixed by or matching a module
name; indicates to other modules and members of modification
hooks that the current message should not affect stateful
@ -3234,13 +3237,20 @@ a full refresh."
(defun erc--check-msg-prop (prop &optional val)
"Return PROP's value in `erc--msg-props' when populated.
If VAL is a list, return non-nil if PROP appears in VAL. If VAL
is otherwise non-nil, return non-nil if VAL compares `eq' to the
stored value. Otherwise, return the stored value."
If VAL is a list, return non-nil if PROP's value appears in VAL. If VAL
is otherwise non-nil, return non-nil if VAL compares `eq' to the stored
value. Otherwise, return the stored value."
(and-let* ((erc--msg-props)
(v (gethash prop erc--msg-props)))
(if (consp val) (memq v val) (if val (eq v val) v))))
(defun erc--memq-msg-prop (prop needle)
"Return non-nil if msg PROP's value is a list containing NEEDLE."
(and-let* ((erc--msg-props)
(haystack (gethash prop erc--msg-props))
((consp haystack)))
(memq needle haystack)))
(defmacro erc--get-inserted-msg-beg-at (point at-start-p)
(macroexp-let2* nil ((point point)
(at-start-p at-start-p))
@ -3684,7 +3694,8 @@ subsequent message."
-1))))))))
(defvar erc--ranked-properties
'(erc--msg erc--spkr erc--ts erc--cmd erc--hide erc--ctcp erc--ephemeral))
'( erc--msg erc--spkr erc--ts erc--skip
erc--cmd erc--hide erc--ctcp erc--ephemeral))
(defun erc--order-text-properties-from-hash (table)
"Return a plist of text props from items in TABLE.