From 32113e49c46b8a0de0f3a9d1666c0a1147d3b2dc Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 31 Jan 2023 02:04:39 -0800 Subject: [PATCH 0/3] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (3): [5.6] Copy over upstream Compat macros to erc-compat [5.6] Don't require erc-goodies in erc.el [5.6] Convert ERC's Imenu integration into proper module lisp/erc/erc-backend.el | 2 +- lisp/erc/erc-common.el | 10 +++++++- lisp/erc/erc-compat.el | 52 +++++++++++++++++++++++++++++++++------- lisp/erc/erc-goodies.el | 31 ++++++++++++++---------- lisp/erc/erc-ibuffer.el | 1 + lisp/erc/erc-imenu.el | 19 +++++++++++++++ lisp/erc/erc-page.el | 3 +++ lisp/erc/erc-speedbar.el | 1 + lisp/erc/erc.el | 14 +++++++---- 9 files changed, 105 insertions(+), 28 deletions(-) Interdiff: diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index fb354a1d3f7..605ee701850 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -41,7 +41,7 @@ ;; ;; BEGIN Compat macros -;;;; Macros for explicit compatibility function calls +;;;; Macros for extended compatibility function calls (defmacro erc-compat-function (fun) "Return compatibility function symbol for FUN. @@ -54,21 +54,24 @@ erc-compat-function functions which implement the behavior and calling convention of Emacs 29.1. -An example is the function `plist-get' which got an additional -predicate argument in Emacs 29. The compatibility function, -which supports this additional argument can be obtained -via (compat-function plist-get) and called with the additional -predicate argument via (compat-call plist-get plist prop -predicate). It is not possible to directly call (plist-get plist -prop predicate), since the function does not yet support the -predicate argument on older Emacs versions and the Compat library -does not override existing functions." +See also `compat-call' to directly call compatibility functions." (let ((compat (intern (format "compat--%s" fun)))) `#',(if (fboundp compat) compat fun))) (defmacro erc-compat-call (fun &rest args) "Call compatibility function or macro FUN with ARGS. -See `compat-function' for details." + +A good example function is `plist-get' which was extended with an +additional predicate argument in Emacs 29.1. The compatibility +function, which supports this additional argument, can be +obtained via (compat-function plist-get) and called +via (compat-call plist-get plist prop predicate). It is not +possible to directly call (plist-get plist prop predicate) on +Emacs older than 29.1, since the original `plist-get' function +does not yet support the predicate argument. Note that the +Compat library never overrides existing functions. + +See also `compat-function' to lookup compatibility functions." (let ((compat (intern (format "compat--%s" fun)))) `(,(if (fboundp compat) compat fun) ,@args))) 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 0d6634d38a9..61adfe2e2ec 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -6851,7 +6851,7 @@ erc-update-mode-line-buffer (?m . ,(erc-format-channel-modes)) (?n . ,(or (erc-current-nick) "")) (?N . ,(erc-format-network)) - (?o . ,(or (and erc-irccontrols-mode + (?o . ,(or (and (bound-and-true-p erc-irccontrols-mode) (erc-controls-strip erc-channel-topic)) "")) (?p . ,(erc-port-to-string erc-session-port)) -- 2.39.1