summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-fill.el
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2023-04-10 17:58:05 -0700
committerF. Jason Park <jp@neverwas.me>2023-05-05 17:18:01 -0700
commit2e18ba6302f3e4aa5485eeaca39c747beb55ca8f (patch)
treee8d2172243a5e3f03d70f11e428a893fbbaf5687 /lisp/erc/erc-fill.el
parent2641dfd4b4334942282358b50d74f75424ebf4fa (diff)
downloademacs-2e18ba6302f3e4aa5485eeaca39c747beb55ca8f.tar.gz
emacs-2e18ba6302f3e4aa5485eeaca39c747beb55ca8f.tar.bz2
emacs-2e18ba6302f3e4aa5485eeaca39c747beb55ca8f.zip
Simplify erc-button movement commands
* etc/ERC-NEWS: Mention TAB being bound to new command `erc-tab' and `erc-previous-button' now stopping at the start of buttons. * lisp/erc/erc-button.el (erc-button-mode, erc-button-enable, erc-button-disable): Add and remove `erc-button-next' to `erc--tab-functions' hook, which is tantamount to binding the command in the read-only area of an ERC buffer. (erc-button-next-function): Deprecate and remove from client code path because this module doesn't concern itself with prompt input and thus no longer needs to conform to the `completion-at-point-functions' interface. (erc-button--prev-next-predicate-functions): New variable, a hook to determine whether to continue searching for a button. Other modules should utilize this as needed. (erc-button--end-of-button-p): Add function to serve as default value for `erc-button--continue-predicate'. (erc--button-next): Add generalized button-movement function. (erc-button-next, erc-button-previous): Make `erc-button-previous' behave more predictably by having it land at the beginning of buttons. And remove roundabout appeal to HOF in `erc-button-next'. (erc-button-previous-of-nick): New command to jump to previous appearance of nick at point. * lisp/erc/erc-fill.el (erc-fill-wrap, erc-fill-wrap-enable, erc-fill-wrap-disable): Add and remove merge-related hookee from `erc-button--prev-next-predicate-functions'. (erc-fill--wrap-merged-button-p): New function to detect redundant speakers. * lisp/erc/erc.el (erc-complete-functions): Quote TAB in doc string. (erc-mode-map): Bind `erc-tab' to TAB. (erc--tab-functions, erc-tab): Add new command and hook to serve as unified dispatch for TAB-related operations. It calls `c-a-p' in the input area and defers to module code in the read-only message area. * test/lisp/erc/erc-button-tests.el: New file. * test/lisp/erc/erc-fill-tests.el (erc-fill-tests--wrap-populate): Run finalizer for transient keymap timer. * test/lisp/erc/erc-tests.el (erc-button--display-error-notice-with-keys): Move to new dedicated test file for erc-button and fix expected behavior of `erc-button-previous'. (Bug#62834)
Diffstat (limited to 'lisp/erc/erc-fill.el')
-rw-r--r--lisp/erc/erc-fill.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el
index a56134d8188..bf995a5a5e6 100644
--- a/lisp/erc/erc-fill.el
+++ b/lisp/erc/erc-fill.el
@@ -300,7 +300,9 @@ of the minor-mode toggles as usual."
(setq msg (concat msg (and msg " ")
(erc-fill--make-module-dependency-msg "button"))))
(erc-with-server-buffer
- (erc-button-mode +1))))
+ (erc-button-mode +1)))
+ (add-hook 'erc-button--prev-next-predicate-functions
+ #'erc-fill--wrap-merged-button-p nil t))
;; Set local value of user option (can we avoid this somehow?)
(unless (eq erc-fill-function #'erc-fill-wrap)
(setq-local erc-fill-function #'erc-fill-wrap))
@@ -328,6 +330,8 @@ of the minor-mode toggles as usual."
(kill-local-variable 'erc-fill--wrap-value)
(kill-local-variable 'erc-fill-function)
(kill-local-variable 'erc-fill--wrap-visual-keys)
+ (remove-hook 'erc-button--prev-next-predicate-functions
+ #'erc-fill--wrap-merged-button-p t)
(remove-function (local 'erc-stamp--insert-date-function)
#'erc-fill--wrap-stamp-insert-prefixed-date)
(visual-line-mode -1))
@@ -414,6 +418,10 @@ See `erc-fill-wrap-mode' for details."
`((space :width (- erc-fill--wrap-value ,len))
(space :width erc-fill--wrap-value))))))
+;; FIXME use own text property to avoid false positives.
+(defun erc-fill--wrap-merged-button-p (point)
+ (equal "" (get-text-property point 'display)))
+
;; This is an experimental helper for third-party modules. You could,
;; for example, use this to automatically resize the prefix to a
;; fraction of the window's width on some event change. Another use