>From ecd3e3da9349202cc59b7d9981fc7aa67def89e8 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 21:07:27 -0800 Subject: [PATCH 2/3] [5.6] Don't require erc-goodies in erc.el * lisp/erc/erc-common.el: (erc--features-to-modules): Add mappings from erc-goodies. * lisp/erc/erc-goodies.el: Sort `defvar' forward declarations for maintainability. * lisp/erc/erc-ibuffer.el: Require `erc-goodies' for `erc-control-interpret'. The justification for the blanket `require' is this module isn't a member of `erc-modules' by default. * lisp/erc/erc-page.el: (erc-ctcp-query-PAGE): Require `erc-goodies' and put forward declaration for `erc-control-interpret' atop file. * lisp/erc/erc-speedbar.el: Require `erc-goodies' for the same reason in erc-ibuffer.el. (erc-irccontrols-mode, erc-enable-irccontrols, erc-disable-irccontrols): Add and remove key for `erc-toggle-interpret-controls' to `erc-mode-map'. * lisp/erc/erc.el: Add some forward declarations from `erc-goodies' and remove the `require' call for `erc-goodies' at the end of the file. (erc-mode-map): Remove C-c C-c binding for `erc-toggle-interpret-controls'. (erc-update-mode-line-buffer): Only strip control chars when `erc-irccontrols-mode' is active. This is arguably a minor breaking change perhaps deserving of a NEWS entry. --- lisp/erc/erc-common.el | 10 +++++++++- lisp/erc/erc-goodies.el | 23 +++++++++++++++++++---- lisp/erc/erc-ibuffer.el | 1 + lisp/erc/erc-page.el | 3 +++ lisp/erc/erc-speedbar.el | 1 + lisp/erc/erc.el | 10 ++++++---- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index 994555acecf..e567a108191 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -96,7 +96,15 @@ erc--features-to-modules (erc-page page ctcp-page) (erc-sound sound ctcp-sound) (erc-stamp stamp timestamp) - (erc-services services nickserv)) + (erc-services services nickserv) + (erc-goodies scrolltobottom) + (erc-goodies readonly) + (erc-goodies move-to-prompt) + (erc-goodies keep-place) + (erc-goodies noncommands) + (erc-goodies irccontrols) + (erc-goodies smiley) + (erc-goodies unmorse)) "Migration alist mapping a library feature to module names. Keys need not be unique: a library may define more than one module. Sometimes a module's downcased alias will be its diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 05a21019042..801c3276499 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -38,9 +38,10 @@ erc-controls-highlight-regexp (defvar erc-controls-remove-regexp) (defvar erc-input-marker) (defvar erc-insert-marker) -(defvar erc-server-process) -(defvar erc-modules) (defvar erc-log-p) +(defvar erc-mode-map) +(defvar erc-modules) +(defvar erc-server-process) (declare-function erc-buffer-list "erc" (&optional predicate proc)) (declare-function erc-error "erc" (&rest args)) @@ -384,9 +385,23 @@ erc-get-fg-color-face (define-erc-module irccontrols nil "This mode enables the interpretation of IRC control chars." ((add-hook 'erc-insert-modify-hook #'erc-controls-highlight) - (add-hook 'erc-send-modify-hook #'erc-controls-highlight)) + (add-hook 'erc-send-modify-hook #'erc-controls-highlight) + (add-hook 'erc-mode-hook #'erc--irccontrols-on-major-mode)) ((remove-hook 'erc-insert-modify-hook #'erc-controls-highlight) - (remove-hook 'erc-send-modify-hook #'erc-controls-highlight))) + (remove-hook 'erc-send-modify-hook #'erc-controls-highlight) + (remove-hook 'erc-mode-hook #'erc--irccontrols-on-major-mode) + (erc-with-all-buffers-of-server nil nil + (erc--irccontrols-on-major-mode)))) + +(defun erc--irccontrols-on-major-mode () + ;; FIXME all these keymap-* functions require Compat 29 + (if erc-irccontrols-mode + ;; Interrogate composed view of local map and `erc-mode-map' + (unless (keymap-lookup (current-local-map) "C-c C-c") + (keymap-local-set "C-c C-c" #'erc-toggle-interpret-controls)) + (when (eq (keymap-local-lookup "C-c C-c") + #'erc-toggle-interpret-controls) + (keymap-local-unset "C-c C-c" t)))) (defun erc-controls-interpret (str) "Return a copy of STR after dealing with IRC control characters. diff --git a/lisp/erc/erc-ibuffer.el b/lisp/erc/erc-ibuffer.el index 6699afe36a0..612814ac6da 100644 --- a/lisp/erc/erc-ibuffer.el +++ b/lisp/erc/erc-ibuffer.el @@ -32,6 +32,7 @@ (require 'ibuffer) (require 'ibuf-ext) (require 'erc) +(require 'erc-goodies) ; `erc-controls-interpret' (defgroup erc-ibuffer nil "The Ibuffer group for ERC." diff --git a/lisp/erc/erc-page.el b/lisp/erc/erc-page.el index 308b3784ca5..8eb558ecda7 100644 --- a/lisp/erc/erc-page.el +++ b/lisp/erc/erc-page.el @@ -30,6 +30,8 @@ (require 'erc) +(declare-function erc-controls-interpret "erc-goodies" (str)) + (defgroup erc-page nil "React to CTCP PAGE messages." :group 'erc) @@ -69,6 +71,7 @@ erc-ctcp-query-PAGE This will call `erc-page-function', if defined, or it will just print a message and `beep'. In addition to that, the page message is also inserted into the server buffer." + (require 'erc-goodies) ; for `erc-controls-interpret' (when (and erc-page-mode (string-match "PAGE\\(\\s-+.*\\)?$" msg)) (let* ((m (match-string 1 msg)) diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el index 5fca14e2365..a9443e0ea17 100644 --- a/lisp/erc/erc-speedbar.el +++ b/lisp/erc/erc-speedbar.el @@ -36,6 +36,7 @@ ;;; Code: (require 'erc) +(require 'erc-goodies) (require 'speedbar) (condition-case nil (require 'dframe) (error nil)) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index ff1820cfaf2..cc3de26e96e 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -134,11 +134,14 @@ erc-scripts ;; Forward declarations (defvar erc-message-parsed) +(defvar erc-irccontrols-mode) (defvar tabbar--local-hlf) (defvar motif-version-string) (defvar gtk-version-string) +(declare-function erc-controls-strip "erc-goodies" (str)) + ;; tunable connection and authentication parameters (defcustom erc-server nil @@ -1188,7 +1191,6 @@ erc-mode-map (define-key map [home] #'erc-bol) (define-key map "\C-c\C-a" #'erc-bol) (define-key map "\C-c\C-b" #'erc-switch-to-buffer) - (define-key map "\C-c\C-c" #'erc-toggle-interpret-controls) (define-key map "\C-c\C-d" #'erc-input-action) (define-key map "\C-c\C-e" #'erc-toggle-ctcp-autoresponse) (define-key map "\C-c\C-f" #'erc-toggle-flood-control) @@ -6847,7 +6849,9 @@ erc-update-mode-line-buffer (?m . ,(erc-format-channel-modes)) (?n . ,(or (erc-current-nick) "")) (?N . ,(erc-format-network)) - (?o . ,(or (erc-controls-strip erc-channel-topic) "")) + (?o . ,(or (and (bound-and-true-p erc-irccontrols-mode) + (erc-controls-strip erc-channel-topic)) + "")) (?p . ,(erc-port-to-string erc-session-port)) (?s . ,(erc-format-target-and/or-server)) (?S . ,(erc-format-target-and/or-network)) @@ -7385,6 +7389,4 @@ erc-handle-irc-url (provide 'erc) -;; FIXME this is a temporary stopgap for Emacs 29. -(require 'erc-goodies) ;;; erc.el ends here -- 2.39.1