diff options
| author | F. Jason Park | 2022-12-18 19:01:40 -0800 |
|---|---|---|
| committer | F. Jason Park | 2023-04-08 14:23:51 -0700 |
| commit | 8184a815aff52cbf1f1b8680d80af2fbf2dce248 (patch) | |
| tree | f168a082dd2c4f9bfd8f33fa0700ad175a671093 /test/lisp | |
| parent | 1f1cd467c6afc8100a338e9b44bae8cebfa093f6 (diff) | |
| download | emacs-8184a815aff52cbf1f1b8680d80af2fbf2dce248.tar.gz emacs-8184a815aff52cbf1f1b8680d80af2fbf2dce248.zip | |
Add erc-button helper for substituting command keys
* lisp/erc/erc-button.el (erc-button-mode, erc-button-enable): Warn if
`erc-button-alist' contains deprecated FORM field in `nicknames'
entry.
(erc-button-alist): Discourage arbitrary sexp form for third item of
entries and offer more useful bounds-modifying function in its place.
Mention that anything other than `erc-button-buttonize-nicks' is
deprecated as the FORM field in a `nicknames' entry. Bump
package-version even though this doesn't introduce a visible change in
the default value.
(erc-button--maybe-warn-arbitrary-sexp): Add helper for validating
third `erc-button-alist' field.
(erc-button--check-nicknames-entry): Add helper to check for
deprecated items in `erc-button-alist'.
(erc-button--preserve-bounds): Add function to serve as default value
for `erc-button--modify-nick-function).
(erc-button--modify-nick-function): Add new variable to hold a
function that filters nickname bounds when buttonizing.
(erc-button--phantom-users, erc-button--add-phantom-speaker,
erc-button--phantom-users-mode): Add new internal minor mode for
treating unseen speakers of PRIVMSGs as known members of the server
for things like coloring nicks during buffer playback.
(erc-button--get-user-from-speaker-naive): Add temporary utility
function to scrape nick from speaker in narrowed buffer. This will be
replaced by an account-aware version in next major ERC release.
(erc-button-add-nickname-buttons): Accommodate function variant for
"form" field of `erc-button-alist' entries. Minor optimizations.
This function will likely become the primary juncture for applying
text properties that support nickname-related user-intelligence
features.
(erc-button-add-buttons-1): Show warning when arbitrary sexp for third
"form" field encountered. Accommodate binary function instead.
(erc-button--substitute-command-keys-in-region): Add helper function
for applying key substitutions in ERC warning messages.
(erc-button--display-error-notice-with-keys): Add new helper function
for displaying ad hoc warnings that possibly require key substitution.
(erc-button--display-error-notice-with-keys-and-warn): Add variant of
`erc-button--display-error-notice-with-keys' that also emits warnings.
* lisp/erc/erc-networks.el (erc-networks--ensure-announced,
erc-networks--on-MOTD-end): Use new key-substitutions helper from
erc-button.
* test/lisp/erc/erc-tests.el
(erc-button--display-error-notice-with-keys): New test.
* test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld: Add
unknown speaker in channel for phantom store to handle. Currently
requires manual intervention to leverage. (Bug#60933.)
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 61 | ||||
| -rw-r--r-- | test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld | 1 |
2 files changed, 62 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 6e66de53edd..b155f85ab8a 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -1790,4 +1790,65 @@ connection." | |||
| 1790 | (put 'erc-mname-enable 'definition-name 'mname) | 1790 | (put 'erc-mname-enable 'definition-name 'mname) |
| 1791 | (put 'erc-mname-disable 'definition-name 'mname)))))) | 1791 | (put 'erc-mname-disable 'definition-name 'mname)))))) |
| 1792 | 1792 | ||
| 1793 | |||
| 1794 | ;; XXX move erc-button tests to new file if more added. | ||
| 1795 | (require 'erc-button) | ||
| 1796 | |||
| 1797 | ;; See also `erc-scenarios-networks-announced-missing' in | ||
| 1798 | ;; erc-scenarios-misc.el for a more realistic example. | ||
| 1799 | (ert-deftest erc-button--display-error-notice-with-keys () | ||
| 1800 | (with-current-buffer (get-buffer-create "*fake*") | ||
| 1801 | (let ((mode erc-button-mode) | ||
| 1802 | (inhibit-message noninteractive) | ||
| 1803 | erc-modules | ||
| 1804 | erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook) | ||
| 1805 | (erc-mode) | ||
| 1806 | (erc-tests--set-fake-server-process "sleep" "1") | ||
| 1807 | (erc--initialize-markers (point) nil) | ||
| 1808 | (erc-button-mode +1) | ||
| 1809 | (should (equal (erc-button--display-error-notice-with-keys | ||
| 1810 | "If \\[erc-bol] fails, " | ||
| 1811 | "see \\[erc-bug] or `erc-mode-map'.") | ||
| 1812 | "*** If C-a fails, see M-x erc-bug or `erc-mode-map'.")) | ||
| 1813 | (goto-char (point-min)) | ||
| 1814 | |||
| 1815 | (ert-info ("Keymap substitution succeeds") | ||
| 1816 | (erc-button-next) | ||
| 1817 | (should (looking-at "C-a")) | ||
| 1818 | (should (eq (get-text-property (point) 'mouse-face) 'highlight)) | ||
| 1819 | (erc-button-press-button) | ||
| 1820 | (with-current-buffer "*Help*" | ||
| 1821 | (goto-char (point-min)) | ||
| 1822 | (should (search-forward "erc-bol" nil t))) | ||
| 1823 | (erc-button-next) | ||
| 1824 | (erc-button-previous) ; end of interval correct | ||
| 1825 | (should (looking-at "a fails"))) | ||
| 1826 | |||
| 1827 | (ert-info ("Extended command mapping succeeds") | ||
| 1828 | (erc-button-next) | ||
| 1829 | (should (looking-at "M-x erc-bug")) | ||
| 1830 | (erc-button-press-button) | ||
| 1831 | (should (eq (get-text-property (point) 'mouse-face) 'highlight)) | ||
| 1832 | (with-current-buffer "*Help*" | ||
| 1833 | (goto-char (point-min)) | ||
| 1834 | (should (search-forward "erc-bug" nil t)))) | ||
| 1835 | |||
| 1836 | (ert-info ("Symbol-description face preserved") ; mutated by d-e-n-w-k | ||
| 1837 | (erc-button-next) | ||
| 1838 | (should (equal (get-text-property (point) 'font-lock-face) | ||
| 1839 | '(erc-button erc-error-face))) | ||
| 1840 | (should (eq (get-text-property (point) 'mouse-face) 'highlight)) | ||
| 1841 | (should (eq erc-button-face 'erc-button))) ; extent evaporates | ||
| 1842 | |||
| 1843 | (ert-info ("Format when trailing args include non-strings") | ||
| 1844 | (should (equal (erc-button--display-error-notice-with-keys | ||
| 1845 | "abc" " %d def" " 45%s" 123 '\6) | ||
| 1846 | "*** abc 123 def 456"))) | ||
| 1847 | |||
| 1848 | (when noninteractive | ||
| 1849 | (unless mode | ||
| 1850 | (erc-button-mode -1)) | ||
| 1851 | (kill-buffer "*Help*") | ||
| 1852 | (kill-buffer))))) | ||
| 1853 | |||
| 1793 | ;;; erc-tests.el ends here | 1854 | ;;; erc-tests.el ends here |
diff --git a/test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld b/test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld index 58df79e19fa..f34ae02f4e4 100644 --- a/test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld +++ b/test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | (0 ":bob!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:02] alice: Here come the lovers, full of joy and mirth.") | 27 | (0 ":bob!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:02] alice: Here come the lovers, full of joy and mirth.") |
| 28 | (0 ":alice!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:07] bob: According to the fool's bolt, sir, and such dulcet diseases.") | 28 | (0 ":alice!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:07] bob: According to the fool's bolt, sir, and such dulcet diseases.") |
| 29 | (0 ":bob!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:10] alice: And hang himself. I pray you, do my greeting.") | 29 | (0 ":bob!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:10] alice: And hang himself. I pray you, do my greeting.") |
| 30 | (0 ":someone!~u@abcdefg.irc PRIVMSG #chan :[07:04:10] hi everyone.") | ||
| 30 | (0 ":alice!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:18] bob: And you sat smiling at his cruel prey.") | 31 | (0 ":alice!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:18] bob: And you sat smiling at his cruel prey.") |
| 31 | (0 ":bob!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:21] alice: Or never after look me in the face.") | 32 | (0 ":bob!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:21] alice: Or never after look me in the face.") |
| 32 | (0 ":alice!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:25] bob: If that may be, than all is well. Come, sit down, every mother's son, and rehearse your parts. Pyramus, you begin: when you have spoken your speech, enter into that brake; and so every one according to his cue.") | 33 | (0 ":alice!~u@svpn88yjcdj42.irc PRIVMSG #chan :[07:04:25] bob: If that may be, than all is well. Come, sit down, every mother's son, and rehearse your parts. Pyramus, you begin: when you have spoken your speech, enter into that brake; and so every one according to his cue.") |