aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-01-19 21:07:27 -0800
committerF. Jason Park2023-04-08 14:23:51 -0700
commit2d876a4ca94d7c74339eb18ca98528d017cab2a8 (patch)
treecea0227030b11d1b79086864a5bb27367332bee0
parent22104de5daa12e82bb6a246f05f4cd2927eb37a3 (diff)
downloademacs-2d876a4ca94d7c74339eb18ca98528d017cab2a8.tar.gz
emacs-2d876a4ca94d7c74339eb18ca98528d017cab2a8.zip
Convert ERC's Imenu integration into proper module
* lisp/erc/erc-goodies.el: Don't add Imenu hooks to `erc-mode-hook' at top level. Remove autoload for `erc-create-imenu-index' because it already exists in the `erc-imenu' library. (erc-imenu-setup): Move to the erc-imenu library. * lisp/erc/erc-imenu.el (erc-unfill-notice): Allow modifications to read-only text. Thanks to Yusef Aslam for reporting this bug. (erc-imenu-setup): Move here from goodies. (erc-imenu--create-index-function): New helper var to hold previous local value of `imenu-create-index-function'. Perhaps advice should be used instead, but a cursory search of the Emacs code base reveals no such usage. (erc-imenu-mode, erc-imenu-enable, erc-imenu-disable): Create "new" ERC module for Imenu integration. * lisp/erc/erc.el (erc-modules): Add `imenu' to default value and create widget menu item. Update package-version. * test/lisp/erc/erc-tests.el (erc-tests--modules): Add `imenu'. (Bug#60954)
-rw-r--r--lisp/erc/erc-goodies.el6
-rw-r--r--lisp/erc/erc-imenu.el23
-rw-r--r--lisp/erc/erc.el4
-rw-r--r--test/lisp/erc/erc-tests.el2
4 files changed, 26 insertions, 9 deletions
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 5ddacb643fd..7ea6c42ec65 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -32,12 +32,6 @@
32(eval-when-compile (require 'cl-lib)) 32(eval-when-compile (require 'cl-lib))
33(require 'erc) 33(require 'erc)
34 34
35(defun erc-imenu-setup ()
36 "Setup Imenu support in an ERC buffer."
37 (setq-local imenu-create-index-function #'erc-create-imenu-index))
38
39(add-hook 'erc-mode-hook #'erc-imenu-setup)
40(autoload 'erc-create-imenu-index "erc-imenu" "Imenu index creation function")
41 35
42;;; Automatically scroll to bottom 36;;; Automatically scroll to bottom
43(defcustom erc-input-line-position nil 37(defcustom erc-input-line-position nil
diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el
index 6223cd3d06f..526afd32249 100644
--- a/lisp/erc/erc-imenu.el
+++ b/lisp/erc/erc-imenu.el
@@ -52,7 +52,8 @@ Don't rely on this function, read it first!"
52 (forward-line 1) 52 (forward-line 1)
53 (looking-at " ")) 53 (looking-at " "))
54 (forward-line 1)) 54 (forward-line 1))
55 (end-of-line) (point))))) 55 (end-of-line) (point))))
56 (inhibit-read-only t))
56 (with-temp-buffer 57 (with-temp-buffer
57 (insert str) 58 (insert str)
58 (goto-char (point-min)) 59 (goto-char (point-min))
@@ -124,6 +125,26 @@ Don't rely on this function, read it first!"
124 index-alist)) 125 index-alist))
125 index-alist)) 126 index-alist))
126 127
128(defvar-local erc-imenu--create-index-function nil
129 "Previous local value of `imenu-create-index-function', if any.")
130
131(defun erc-imenu-setup ()
132 "Wire up support for Imenu in an ERC buffer."
133 (when (and (local-variable-p 'imenu-create-index-function)
134 imenu-create-index-function)
135 (setq erc-imenu--create-index-function imenu-create-index-function))
136 (setq imenu-create-index-function #'erc-create-imenu-index))
137
138;;;###autoload(autoload 'erc-imenu-mode "erc-imenu" nil t)
139(define-erc-module imenu nil
140 "Simple Imenu integration for ERC."
141 ((add-hook 'erc-mode-hook #'erc-imenu-setup))
142 ((remove-hook 'erc-mode-hook #'erc-imenu-setup)
143 (erc-with-all-buffers-of-server erc-server-process nil
144 (when erc-imenu--create-index-function
145 (setq imenu-create-index-function erc-imenu--create-index-function)
146 (kill-local-variable 'erc-imenu--create-index-function)))))
147
127(provide 'erc-imenu) 148(provide 'erc-imenu)
128 149
129;;; erc-imenu.el ends here 150;;; erc-imenu.el ends here
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 60fe0480412..cc5cac87da8 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1852,7 +1852,7 @@ buffer rather than a server buffer.")
1852 ;; each item is in the format '(old . new) 1852 ;; each item is in the format '(old . new)
1853 (delete-dups (mapcar #'erc--normalize-module-symbol mods))) 1853 (delete-dups (mapcar #'erc--normalize-module-symbol mods)))
1854 1854
1855(defcustom erc-modules '( autojoin button completion fill irccontrols 1855(defcustom erc-modules '( autojoin button completion fill imenu irccontrols
1856 list match menu move-to-prompt netsplit 1856 list match menu move-to-prompt netsplit
1857 networks noncommands readonly ring stamp track) 1857 networks noncommands readonly ring stamp track)
1858 "A list of modules which ERC should enable. 1858 "A list of modules which ERC should enable.
@@ -1912,6 +1912,7 @@ removed from the list will be disabled."
1912 (const :tag "dcc: Provide Direct Client-to-Client support" dcc) 1912 (const :tag "dcc: Provide Direct Client-to-Client support" dcc)
1913 (const :tag "fill: Wrap long lines" fill) 1913 (const :tag "fill: Wrap long lines" fill)
1914 (const :tag "identd: Launch an identd server on port 8113" identd) 1914 (const :tag "identd: Launch an identd server on port 8113" identd)
1915 (const :tag "imenu: A simple Imenu integration" imenu)
1915 (const :tag "irccontrols: Highlight or remove IRC control characters" 1916 (const :tag "irccontrols: Highlight or remove IRC control characters"
1916 irccontrols) 1917 irccontrols)
1917 (const :tag "keep-place: Leave point above un-viewed text" keep-place) 1918 (const :tag "keep-place: Leave point above un-viewed text" keep-place)
@@ -1949,6 +1950,7 @@ removed from the list will be disabled."
1949 (const :tag "unmorse: Translate morse code in messages" unmorse) 1950 (const :tag "unmorse: Translate morse code in messages" unmorse)
1950 (const :tag "xdcc: Act as an XDCC file-server" xdcc) 1951 (const :tag "xdcc: Act as an XDCC file-server" xdcc)
1951 (repeat :tag "Others" :inline t symbol)) 1952 (repeat :tag "Others" :inline t symbol))
1953 :package-version '(ERC . "5.6") ; FIXME sync on release
1952 :group 'erc) 1954 :group 'erc)
1953 1955
1954(defun erc-update-modules () 1956(defun erc-update-modules ()
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 0c7b06da436..acd470a1e17 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1270,7 +1270,7 @@
1270 1270
1271(defconst erc-tests--modules 1271(defconst erc-tests--modules
1272 '( autoaway autojoin button capab-identify completion dcc fill identd 1272 '( autoaway autojoin button capab-identify completion dcc fill identd
1273 irccontrols keep-place list log match menu move-to-prompt netsplit 1273 imenu irccontrols keep-place list log match menu move-to-prompt netsplit
1274 networks noncommands notifications notify page readonly 1274 networks noncommands notifications notify page readonly
1275 replace ring sasl scrolltobottom services smiley sound 1275 replace ring sasl scrolltobottom services smiley sound
1276 spelling stamp track truncate unmorse xdcc)) 1276 spelling stamp track truncate unmorse xdcc))