>From e2766648b737382fc2ed923e13bc9e33f55c0ce9 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 21:07:27 -0800 Subject: [PATCH 3/6] [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: Remove forward declarations. Add minor-mode autoloads for `scrolltobottom', `readonly', `move-to-prompt', `keep-place', `noncommands', `irccontrols', `smiley', and `unmorse'. (erc-irccontrols-mode, erc-irccontrols-enable, erc-irccontrols-disable): Add and remove key for `erc-toggle-interpret-controls' to `erc-mode-map'. (erc--irccontrols-on-major-mode): New helper to add or remove toggle command from local map. * 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. * 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-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. (Bug#60954.) --- 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 | 9 ++++++--- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 05a21019042..a7b296366f6 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -29,23 +29,10 @@ ;;; Code: -;;; Imenu support - (eval-when-compile (require 'cl-lib)) -(require 'erc-common) - (defvar 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) - -(declare-function erc-buffer-list "erc" (&optional predicate proc)) -(declare-function erc-error "erc" (&rest args)) -(declare-function erc-extract-command-from-line "erc" (line)) -(declare-function erc-beg-of-input-line "erc" nil) +(require 'erc) (defun erc-imenu-setup () "Setup Imenu support in an ERC buffer." @@ -65,6 +52,7 @@ erc-input-line-position :group 'erc-display :type '(choice integer (const nil))) +;;;###autoload(autoload 'erc-scrolltobottom-mode "erc-goodies" nil t) (define-erc-module scrolltobottom nil "This mode causes the prompt to stay at the end of the window." ((add-hook 'erc-mode-hook #'erc-add-scroll-to-bottom) @@ -116,6 +104,7 @@ erc-scroll-to-bottom (recenter (or erc-input-line-position -1))))))) ;;; Make read only +;;;###autoload(autoload 'erc-readonly-mode "erc-goodies" nil t) (define-erc-module readonly nil "This mode causes all inserted text to be read-only." ((add-hook 'erc-insert-post-hook #'erc-make-read-only) @@ -131,6 +120,7 @@ erc-make-read-only (put-text-property (point-min) (point-max) 'rear-nonsticky t)) ;;; Move to prompt when typing text +;;;###autoload(autoload 'erc-move-to-prompt-mode "erc-goodies" nil t) (define-erc-module move-to-prompt nil "This mode causes the point to be moved to the prompt when typing text." ((add-hook 'erc-mode-hook #'erc-move-to-prompt-setup) @@ -155,6 +145,7 @@ erc-move-to-prompt-setup (add-hook 'pre-command-hook #'erc-move-to-prompt nil t)) ;;; Keep place in unvisited channels +;;;###autoload(autoload 'erc-keep-place-mode "erc-goodies" nil t) (define-erc-module keep-place nil "Leave point above un-viewed text in other channels." ((add-hook 'erc-insert-pre-hook #'erc-keep-place)) @@ -193,6 +184,7 @@ erc-noncommands-list If a command's function symbol is in this list, the typed command does not appear in the ERC buffer after the user presses ENTER.") +;;;###autoload(autoload 'erc-noncommands-mode "erc-goodies" nil t) (define-erc-module noncommands nil "This mode distinguishes non-commands. Commands listed in `erc-insert-this' know how to display @@ -381,6 +373,7 @@ erc-get-fg-color-face (intern (concat "fg:erc-color-face" (number-to-string n)))) (t (erc-log (format " Wrong color: %s" n)) 'default)))) +;;;###autoload(autoload 'erc-irccontrols-mode "erc-goodies" nil t) (define-erc-module irccontrols nil "This mode enables the interpretation of IRC control chars." ((add-hook 'erc-insert-modify-hook #'erc-controls-highlight) @@ -553,6 +546,7 @@ erc-toggle-interpret-controls (if erc-interpret-controls-p "ON" "OFF"))) ;; Smiley +;;;###autoload(autoload 'erc-smiley-mode "erc-goodies" nil t) (define-erc-module smiley nil "This mode translates text-smileys such as :-) into pictures. This requires the function `smiley-region', which is defined in @@ -569,6 +563,7 @@ erc-smiley (smiley-region (point-min) (point-max)))) ;; Unmorse +;;;###autoload(autoload 'erc-unmorse-mode "erc-goodies" nil t) (define-erc-module unmorse nil "This mode causes morse code in the current channel to be unmorsed." ((add-hook 'erc-insert-modify-hook #'erc-unmorse)) 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 6cba59c6946..a94678e5132 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) @@ -70,6 +72,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 aba96e9a2ab..5786007dbf1 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 @@ -6854,7 +6857,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)) @@ -7392,6 +7397,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