mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
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)
This commit is contained in:
parent
22104de5da
commit
2d876a4ca9
4 changed files with 26 additions and 9 deletions
|
|
@ -32,12 +32,6 @@
|
|||
(eval-when-compile (require 'cl-lib))
|
||||
(require 'erc)
|
||||
|
||||
(defun erc-imenu-setup ()
|
||||
"Setup Imenu support in an ERC buffer."
|
||||
(setq-local imenu-create-index-function #'erc-create-imenu-index))
|
||||
|
||||
(add-hook 'erc-mode-hook #'erc-imenu-setup)
|
||||
(autoload 'erc-create-imenu-index "erc-imenu" "Imenu index creation function")
|
||||
|
||||
;;; Automatically scroll to bottom
|
||||
(defcustom erc-input-line-position nil
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ Don't rely on this function, read it first!"
|
|||
(forward-line 1)
|
||||
(looking-at " "))
|
||||
(forward-line 1))
|
||||
(end-of-line) (point)))))
|
||||
(end-of-line) (point))))
|
||||
(inhibit-read-only t))
|
||||
(with-temp-buffer
|
||||
(insert str)
|
||||
(goto-char (point-min))
|
||||
|
|
@ -124,6 +125,26 @@ Don't rely on this function, read it first!"
|
|||
index-alist))
|
||||
index-alist))
|
||||
|
||||
(defvar-local erc-imenu--create-index-function nil
|
||||
"Previous local value of `imenu-create-index-function', if any.")
|
||||
|
||||
(defun erc-imenu-setup ()
|
||||
"Wire up support for Imenu in an ERC buffer."
|
||||
(when (and (local-variable-p 'imenu-create-index-function)
|
||||
imenu-create-index-function)
|
||||
(setq erc-imenu--create-index-function imenu-create-index-function))
|
||||
(setq imenu-create-index-function #'erc-create-imenu-index))
|
||||
|
||||
;;;###autoload(autoload 'erc-imenu-mode "erc-imenu" nil t)
|
||||
(define-erc-module imenu nil
|
||||
"Simple Imenu integration for ERC."
|
||||
((add-hook 'erc-mode-hook #'erc-imenu-setup))
|
||||
((remove-hook 'erc-mode-hook #'erc-imenu-setup)
|
||||
(erc-with-all-buffers-of-server erc-server-process nil
|
||||
(when erc-imenu--create-index-function
|
||||
(setq imenu-create-index-function erc-imenu--create-index-function)
|
||||
(kill-local-variable 'erc-imenu--create-index-function)))))
|
||||
|
||||
(provide 'erc-imenu)
|
||||
|
||||
;;; erc-imenu.el ends here
|
||||
|
|
|
|||
|
|
@ -1852,7 +1852,7 @@ buffer rather than a server buffer.")
|
|||
;; each item is in the format '(old . new)
|
||||
(delete-dups (mapcar #'erc--normalize-module-symbol mods)))
|
||||
|
||||
(defcustom erc-modules '( autojoin button completion fill irccontrols
|
||||
(defcustom erc-modules '( autojoin button completion fill imenu irccontrols
|
||||
list match menu move-to-prompt netsplit
|
||||
networks noncommands readonly ring stamp track)
|
||||
"A list of modules which ERC should enable.
|
||||
|
|
@ -1912,6 +1912,7 @@ removed from the list will be disabled."
|
|||
(const :tag "dcc: Provide Direct Client-to-Client support" dcc)
|
||||
(const :tag "fill: Wrap long lines" fill)
|
||||
(const :tag "identd: Launch an identd server on port 8113" identd)
|
||||
(const :tag "imenu: A simple Imenu integration" imenu)
|
||||
(const :tag "irccontrols: Highlight or remove IRC control characters"
|
||||
irccontrols)
|
||||
(const :tag "keep-place: Leave point above un-viewed text" keep-place)
|
||||
|
|
@ -1949,6 +1950,7 @@ removed from the list will be disabled."
|
|||
(const :tag "unmorse: Translate morse code in messages" unmorse)
|
||||
(const :tag "xdcc: Act as an XDCC file-server" xdcc)
|
||||
(repeat :tag "Others" :inline t symbol))
|
||||
:package-version '(ERC . "5.6") ; FIXME sync on release
|
||||
:group 'erc)
|
||||
|
||||
(defun erc-update-modules ()
|
||||
|
|
|
|||
|
|
@ -1270,7 +1270,7 @@
|
|||
|
||||
(defconst erc-tests--modules
|
||||
'( autoaway autojoin button capab-identify completion dcc fill identd
|
||||
irccontrols keep-place list log match menu move-to-prompt netsplit
|
||||
imenu irccontrols keep-place list log match menu move-to-prompt netsplit
|
||||
networks noncommands notifications notify page readonly
|
||||
replace ring sasl scrolltobottom services smiley sound
|
||||
spelling stamp track truncate unmorse xdcc))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue