>From 6b32b19a6f9f4e7b30c24cee69e17b3910019b1b Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 21:07:27 -0800 Subject: [PATCH 4/7] [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'. Add Local variables footer with `generated-autoload-file'. (erc-controls-strip): Autoload this function. (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: Remove `require' for `erc-goodies' at end of file and `pp' at top of file because `pp-to-string' is autoloaded on Emacs 27. Also remove `require's for `thingatpt', `time-date', and `iso8601'. They're all used sparingly and the latter two have only been around for one major release, so their removal likely won't cause much churn. And `thingatpt' already has a call-site `require', so the top-level one was redundant. Also wrap local loaddefs `require' call in `eval-and-compile'. (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 | 28 ++++++++++++++-------------- lisp/erc/erc-ibuffer.el | 1 + lisp/erc/erc-page.el | 3 +++ lisp/erc/erc-speedbar.el | 1 + lisp/erc/erc.el | 19 +++++++++---------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 05a21019042..7ca155ef9d0 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) @@ -440,6 +433,7 @@ erc-controls-interpret s)) (t s))))) +;;;###autoload (defun erc-controls-strip (str) "Return a copy of STR with all IRC control characters removed." (when str @@ -553,6 +547,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 +564,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)) @@ -611,3 +607,7 @@ erc-occur (provide 'erc-goodies) ;;; erc-goodies.el ends here + +;; Local Variables: +;; generated-autoload-file: "erc-loaddefs.el" +;; End: 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 9af038b048e..680121657c1 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -58,17 +58,13 @@ ;;; Code: -(load "erc-loaddefs" 'noerror 'nomessage) +(eval-and-compile (load "erc-loaddefs" 'noerror 'nomessage)) (require 'erc-networks) (require 'erc-backend) (require 'cl-lib) (require 'format-spec) -(require 'pp) -(require 'thingatpt) (require 'auth-source) -(require 'time-date) -(require 'iso8601) (eval-when-compile (require 'subr-x) (require 'url-parse)) (defconst erc-version "5.5" @@ -140,6 +136,10 @@ tabbar--local-hlf (defvar motif-version-string) (defvar gtk-version-string) +(declare-function decoded-time-period "time-date" (time)) +(declare-function iso8601-parse-duration "iso8601" (string)) +(declare-function word-at-point "thingatpt" (&optional no-properties)) + ;; tunable connection and authentication parameters (defcustom erc-server nil @@ -3083,6 +3083,8 @@ erc--read-time-period (string-to-number period)) ;; Parse as a time spec. (t + (require 'time-date) + (require 'iso8601) (let ((time (condition-case nil (iso8601-parse-duration (concat (cond @@ -6865,8 +6867,6 @@ erc-format-lag-time (cond (lag (format "lag:%.0f" lag)) (t "")))) -;; erc-goodies is required at end of this file. - ;; TODO when ERC drops Emacs 28, replace the expressions in the format ;; spec below with functions. (defun erc-update-mode-line-buffer (buffer) @@ -6877,7 +6877,8 @@ 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 (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)) @@ -7415,6 +7416,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.2