>From f87741ad52ffebe378200ffcd74ad75be680d9a2 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 9 Mar 2023 06:25:15 -0800 Subject: [PATCH 0/8] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (8): [5.6] Refactor marker initialization in erc-open [5.6] Adjust some old text properties in ERC buffers [5.6] Expose insertion time as text prop in erc-stamp [5.6] Make some erc-stamp functions more limber [5.6] Put display properties to better use in erc-stamp [5.6] Convert erc-fill minor mode into a proper module [5.6] Add variant for erc-match invisibility spec [5.6] Add erc-fill style based on visual-line-mode lisp/erc/erc-fill.el | 311 +++++++++++++++-- lisp/erc/erc-match.el | 31 +- lisp/erc/erc-stamp.el | 210 ++++++++++-- lisp/erc/erc.el | 127 ++++--- test/lisp/erc/erc-fill-tests.el | 324 ++++++++++++++++++ .../erc-scenarios-base-local-module-modes.el | 211 ++++++++++++ .../erc/erc-scenarios-base-local-modules.el | 99 ------ test/lisp/erc/erc-stamp-tests.el | 265 ++++++++++++++ test/lisp/erc/erc-tests.el | 79 ++++- .../fill/snapshots/monospace-01-start.eld | 1 + .../fill/snapshots/monospace-02-right.eld | 1 + .../fill/snapshots/monospace-03-left.eld | 1 + .../fill/snapshots/monospace-04-reset.eld | 1 + 13 files changed, 1445 insertions(+), 216 deletions(-) create mode 100644 test/lisp/erc/erc-fill-tests.el create mode 100644 test/lisp/erc/erc-scenarios-base-local-module-modes.el create mode 100644 test/lisp/erc/erc-stamp-tests.el create mode 100644 test/lisp/erc/resources/fill/snapshots/monospace-01-start.eld create mode 100644 test/lisp/erc/resources/fill/snapshots/monospace-02-right.eld create mode 100644 test/lisp/erc/resources/fill/snapshots/monospace-03-left.eld create mode 100644 test/lisp/erc/resources/fill/snapshots/monospace-04-reset.eld Interdiff: diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 7d635e5b1af..5601ede27a5 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -409,63 +409,6 @@ erc-compat--29-browse-url-irc (cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc) existing)))))) -;; FIXME remove these after bumping Compat version to 29 -(defvar erc-compat--29-set-transient-map-timer nil) - -(defun erc-compat--29-set-transient-map - (map &optional keep-pred on-exit message timeout) - (let* ((message - (when message - (let (keys) - (map-keymap (lambda (key cmd) (and cmd (push key keys))) map) - (format-spec - (if (stringp message) message "Repeat with %k") - `((?k . ,(mapconcat - (lambda (key) - (substitute-command-keys - (format "\\`%s'" (key-description (vector key))))) - keys ", "))))))) - (clearfun (make-symbol "clear-transient-map")) - (exitfun (lambda () - (internal-pop-keymap map 'overriding-terminal-local-map) - (remove-hook 'pre-command-hook clearfun) - (when message (message "")) - (when erc-compat--29-set-transient-map-timer - (cancel-timer erc-compat--29-set-transient-map-timer)) - (when on-exit (funcall on-exit))))) - (fset clearfun - (lambda () - (with-demoted-errors "set-transient-map PCH: %S" - (if (cond - ((null keep-pred) nil) - ((and (not (eq map (cadr overriding-terminal-local-map))) - (memq map (cddr overriding-terminal-local-map))) - t) - ((eq t keep-pred) - (let ((mc (lookup-key map (this-command-keys-vector)))) - (when (and mc (symbolp mc)) - (setq mc (or (command-remapping mc) mc))) - (and mc (eq this-command mc)))) - (t (funcall keep-pred))) - (when message (message "%s" message)) - (funcall exitfun))))) - (add-hook 'pre-command-hook clearfun) - (internal-push-keymap map 'overriding-terminal-local-map) - (when timeout - (when erc-compat--29-set-transient-map-timer - (cancel-timer erc-compat--29-set-transient-map-timer)) - (setq erc-compat--29-set-transient-map-timer - (run-with-idle-timer timeout nil exitfun))) - (when message (message "%s" message)) - exitfun)) - -(defmacro erc-compat--set-transient-map (&rest args) - (cons (if (>= emacs-major-version 29) - 'set-transient-map - 'erc-compat--29-set-transient-map) - args)) - - (provide 'erc-compat) ;;; erc-compat.el ends here diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el index 032206b514a..16791277723 100644 --- a/lisp/erc/erc-fill.el +++ b/lisp/erc/erc-fill.el @@ -369,14 +369,12 @@ erc-fill-wrap-nudge Offer to repeat command in a manner similar to `text-scale-adjust'. - \\`+', \\`=' Increase indentation by one column - \\`-' Decrease indentation by one column - \\`0' Reset indentation to the default - \\`C-+', \\`C-=' Shift right margin rightward (shrink it) - by one column - \\`C--' Shift right margin leftward (grow it) by one - column - \\`C-0' Reset the right margin to the default + \\`=' Increase indentation by one column + \\`-' Decrease indentation by one column + \\`0' Reset indentation to the default + \\`+' Shift right margin rightward (shrink) by one column + \\`_' Shift right margin leftward (grow) by one column + \\`)' Reset the right margin to the default Note that misalignment may occur when messages contain decorations applied by third-party modules. See @@ -392,9 +390,10 @@ erc-fill-wrap-nudge (- (window-end nil t) (window-start))))) (when (zerop arg) (setq arg 1)) - (erc-compat--set-transient-map + (erc-compat-call + set-transient-map (let ((map (make-sparse-keymap))) - (dolist (key '(?+ ?= ?- ?0)) + (dolist (key '(?= ?- ?0)) (let ((a (pcase key (?0 0) (?- (- (abs arg))) @@ -403,8 +402,13 @@ erc-fill-wrap-nudge (lambda () (interactive) (cl-incf total (erc-fill--wrap-nudge a)) - (recenter (round (* win-ratio (window-height)))))) - (define-key map (vector (list 'control key)) + (recenter (round (* win-ratio (window-height)))))))) + (dolist (key '(?\) ?_ ?+)) + (let ((a (pcase key + (?\) 0) + (?_ (- (abs arg))) + (?+ (abs arg))))) + (define-key map (vector (list key)) (lambda () (interactive) (erc-stamp--adjust-right-margin (- a)) diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el index a5e9720bad4..c8f6e7c195c 100644 --- a/lisp/erc/erc-match.el +++ b/lisp/erc/erc-match.el @@ -650,6 +650,8 @@ erc-go-to-log-matches-buffer (get-buffer (car buffer-cons)))))) (switch-to-buffer buffer-name))) +(define-key erc-mode-map "\C-c\C-k" #'erc-go-to-log-matches-buffer) + (defvar-local erc-match--hide-fools-offset-bounds nil) (defun erc-hide-fools (match-type _nickuserhost _message) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index f47cca3f109..3d63c927df3 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2873,7 +2873,7 @@ erc-display-message (unless (erc-hide-current-message-p parsed) (erc-put-text-property 0 (length string) 'erc-parsed parsed string) (put-text-property - 0 (length string) 'erc-message + 0 (length string) 'erc-command (erc--get-eq-comparable-cmd (erc-response.command parsed)) string) (when (erc-response.tags parsed) (erc-put-text-property 0 (length string) 'tags (erc-response.tags parsed) diff --git a/test/lisp/erc/erc-fill-tests.el b/test/lisp/erc/erc-fill-tests.el index a254d5bbc73..2a0abf5dc32 100644 --- a/test/lisp/erc/erc-fill-tests.el +++ b/test/lisp/erc/erc-fill-tests.el @@ -182,7 +182,7 @@ erc-fill-wrap--monospace (ert-info ("Shift right by one (plus)") (ert-with-message-capture messages - (execute-kbd-macro (kbd "M-x erc-fill-wrap-nudge RET +")) + (execute-kbd-macro (kbd "M-x erc-fill-wrap-nudge RET =")) (should (string-match (rx "for further adjustment") messages))) (should (= erc-fill--wrap-value 29)) (erc-fill-tests--wrap-check-prefixes) -- 2.39.2