diff options
| author | F. Jason Park | 2024-01-03 23:10:55 -0800 |
|---|---|---|
| committer | F. Jason Park | 2024-01-07 15:11:26 -0800 |
| commit | 37e87bc3eeb8e62e2900d73cf4dd9fc9e942d66d (patch) | |
| tree | 520859a64dbb82b243e53680553712f623a2ddaf /lisp/erc | |
| parent | d6f9379d1c708dddc0543bf7242ba1ec6aee9746 (diff) | |
| download | emacs-37e87bc3eeb8e62e2900d73cf4dd9fc9e942d66d.tar.gz emacs-37e87bc3eeb8e62e2900d73cf4dd9fc9e942d66d.zip | |
Make ERC's format catalogs more extensible
* lisp/erc/erc-common.el (erc--define-catalog): Accept a `:parent'
keyword to allow for extending an existing catalog by overriding some
subset of defined entries.
(erc-define-message-format-catalog): Add edebug spec.
* lisp/erc/erc.el (erc-retrieve-catalog-entry): Check parent for
definition before looking to `default-toplevel-value'.
* test/lisp/erc/erc-tests.el (erc-retrieve-catalog-entry): Add test
case for inheritance.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-pp-propertized-parts): Fix bug in convenience
command. (Bug#67677)
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-common.el | 17 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 6 |
2 files changed, 21 insertions, 2 deletions
diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index b8ba0673355..2581e40f850 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el | |||
| @@ -554,9 +554,21 @@ See `erc-define-message-format-catalog' for the meaning of | |||
| 554 | ENTRIES, an alist, and `erc-tests-common-pp-propertized-parts' in | 554 | ENTRIES, an alist, and `erc-tests-common-pp-propertized-parts' in |
| 555 | tests/lisp/erc/erc-tests.el for a convenience command to convert | 555 | tests/lisp/erc/erc-tests.el for a convenience command to convert |
| 556 | a literal string into a sequence of `propertize' forms, which are | 556 | a literal string into a sequence of `propertize' forms, which are |
| 557 | much easier to review and edit." | 557 | much easier to review and edit. When ENTRIES begins with a |
| 558 | sequence of keyword-value pairs remove them and consider their | ||
| 559 | evaluated values before processing the alist proper. | ||
| 560 | |||
| 561 | Currently, the only recognized keyword is `:parent', which tells | ||
| 562 | ERC to search recursively for a given template key using the | ||
| 563 | keyword's associated value, another catalog symbol, if not found | ||
| 564 | in catalog NAME." | ||
| 558 | (declare (indent 1)) | 565 | (declare (indent 1)) |
| 559 | (let (out) | 566 | (let (out) |
| 567 | (while (keywordp (car entries)) | ||
| 568 | (push (pcase-exhaustive (pop entries) | ||
| 569 | (:parent `(put ',name 'erc--base-format-catalog | ||
| 570 | ,(pop entries)))) | ||
| 571 | out)) | ||
| 560 | (dolist (e entries (cons 'progn (nreverse out))) | 572 | (dolist (e entries (cons 'progn (nreverse out))) |
| 561 | (push `(defvar ,(intern (format "erc-message-%s-%s" name (car e))) | 573 | (push `(defvar ,(intern (format "erc-message-%s-%s" name (car e))) |
| 562 | ,(cdr e) | 574 | ,(cdr e) |
| @@ -575,7 +587,8 @@ symbol, and FORMAT evaluates to a format string compatible with | |||
| 575 | `format-spec'. Expect modules that only define a handful of | 587 | `format-spec'. Expect modules that only define a handful of |
| 576 | entries to do so manually, instead of using this macro, so that | 588 | entries to do so manually, instead of using this macro, so that |
| 577 | the resulting variables will end up with more useful doc strings." | 589 | the resulting variables will end up with more useful doc strings." |
| 578 | (declare (indent 1)) | 590 | (declare (indent 1) |
| 591 | (debug (symbolp [&rest [keywordp form]] &rest (symbolp . form)))) | ||
| 579 | `(erc--define-catalog ,language ,entries)) | 592 | `(erc--define-catalog ,language ,entries)) |
| 580 | 593 | ||
| 581 | (defmacro erc--doarray (spec &rest body) | 594 | (defmacro erc--doarray (spec &rest body) |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index d0c43134f9d..478683a77f5 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -9320,6 +9320,12 @@ if yet untried." | |||
| 9320 | (unless catalog (setq catalog erc-current-message-catalog)) | 9320 | (unless catalog (setq catalog erc-current-message-catalog)) |
| 9321 | (symbol-value | 9321 | (symbol-value |
| 9322 | (or (erc--make-message-variable-name catalog key 'softp) | 9322 | (or (erc--make-message-variable-name catalog key 'softp) |
| 9323 | (let ((parent catalog) | ||
| 9324 | last) | ||
| 9325 | (while (and (setq parent (get parent 'erc--base-format-catalog)) | ||
| 9326 | (not (setq last (erc--make-message-variable-name | ||
| 9327 | parent key 'softp))))) | ||
| 9328 | last) | ||
| 9323 | (let ((default (default-toplevel-value 'erc-current-message-catalog))) | 9329 | (let ((default (default-toplevel-value 'erc-current-message-catalog))) |
| 9324 | (or (and (not (eq default catalog)) | 9330 | (or (and (not (eq default catalog)) |
| 9325 | (erc--make-message-variable-name default key 'softp)) | 9331 | (erc--make-message-variable-name default key 'softp)) |