From 3aa1b8b3905b5a3db0304d24d869fe601324df43 Mon Sep 17 00:00:00 2001 From: Lin Sun Date: Wed, 11 Dec 2024 06:51:21 +0000 Subject: [PATCH] Fix bug that semantic did not restore imenu-create-index-function on exiting * lisp/cedet/semantic.el: Restore the imenu-create-index-function on exiting. * lisp/cedet/semantic/bovine/make.el: * lisp/cedet/semantic/bovine/scm.el: * lisp/cedet/semantic/html.el: * lisp/cedet/semantic/texi.el: * lisp/cedet/semantic/wisent/java-tags.el: * lisp/cedet/semantic/wisent/javascript.el: * lisp/cedet/semantic/wisent/python.el: * lisp/cedet/srecode/template.el: Store the original imenu-create-index-function before changing it. --- lisp/cedet/semantic.el | 11 ++++++++++- lisp/cedet/semantic/bovine/make.el | 1 + lisp/cedet/semantic/bovine/scm.el | 1 + lisp/cedet/semantic/html.el | 1 + lisp/cedet/semantic/texi.el | 1 + lisp/cedet/semantic/wisent/java-tags.el | 1 + lisp/cedet/semantic/wisent/javascript.el | 1 + lisp/cedet/semantic/wisent/python.el | 1 + lisp/cedet/srecode/template.el | 1 + 9 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el index 3c3ae2ac160..1b7931f0c35 100644 --- a/lisp/cedet/semantic.el +++ b/lisp/cedet/semantic.el @@ -997,6 +997,9 @@ semantic-default-submodes :type `(set ,@(mapcar (lambda (c) (list 'const c)) semantic-submode-list))) +(defvar-local semantic--create-index-function-origin nil + "The original `imenu-create-index-function' before semantic.") + ;;;###autoload (define-minor-mode semantic-mode "Toggle parser features (Semantic mode). @@ -1070,7 +1073,13 @@ semantic-mode (setq semantic--buffer-cache nil) ;; Make sure we run the setup function if Semantic gets ;; re-activated. - (setq semantic-new-buffer-fcn-was-run nil))) + (setq semantic-new-buffer-fcn-was-run nil) + ;; restore the original `imenu-create-index-function' + (unless (eq semantic--create-index-function-origin + imenu-create-index-function) + (setq imenu-create-index-function + (or semantic--create-index-function-origin + (default-value 'imenu-create-index-function)))))) ;;; Autoload some functions that are not in semantic/loaddefs diff --git a/lisp/cedet/semantic/bovine/make.el b/lisp/cedet/semantic/bovine/make.el index a95f7da27cf..b8f31d21028 100644 --- a/lisp/cedet/semantic/bovine/make.el +++ b/lisp/cedet/semantic/bovine/make.el @@ -226,6 +226,7 @@ semantic-default-make-setup (?+ ".") (?\\ ".") ) + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index ) (setq semantic-lex-analyzer #'semantic-make-lexer) diff --git a/lisp/cedet/semantic/bovine/scm.el b/lisp/cedet/semantic/bovine/scm.el index 6d19acf0282..e31019e8bf2 100644 --- a/lisp/cedet/semantic/bovine/scm.el +++ b/lisp/cedet/semantic/bovine/scm.el @@ -102,6 +102,7 @@ semantic-default-scheme-setup (function . "Functions") (include . "Loads") (package . "DefineModule")) + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index ) (setq semantic-lex-analyzer #'semantic-scheme-lexer) diff --git a/lisp/cedet/semantic/html.el b/lisp/cedet/semantic/html.el index 120b2108709..d00d5633e2c 100644 --- a/lisp/cedet/semantic/html.el +++ b/lisp/cedet/semantic/html.el @@ -238,6 +238,7 @@ semantic-default-html-setup ;; This will use our parser. (setq semantic-parser-name "HTML" semantic--parse-table t + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index semantic-command-separation-character ">" semantic-type-relation-separator-character '(":") diff --git a/lisp/cedet/semantic/texi.el b/lisp/cedet/semantic/texi.el index 6374d995d0a..2b341249a54 100644 --- a/lisp/cedet/semantic/texi.el +++ b/lisp/cedet/semantic/texi.el @@ -445,6 +445,7 @@ semantic-default-texi-setup (setq semantic-parser-name "TEXI" ;; Setup a dummy parser table to enable parsing! semantic--parse-table t + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index semantic-command-separation-character "@" semantic-type-relation-separator-character '(":") diff --git a/lisp/cedet/semantic/wisent/java-tags.el b/lisp/cedet/semantic/wisent/java-tags.el index ed62d2c3a9c..ebb899221cc 100644 --- a/lisp/cedet/semantic/wisent/java-tags.el +++ b/lisp/cedet/semantic/wisent/java-tags.el @@ -113,6 +113,7 @@ wisent-java-default-setup semantic-tag-expand-function #'semantic-java-expand-tag ;; Environment semantic-imenu-summary-function #'semantic-format-tag-prototype + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index semantic-type-relation-separator-character '(".") semantic-command-separation-character ";" diff --git a/lisp/cedet/semantic/wisent/javascript.el b/lisp/cedet/semantic/wisent/javascript.el index 7a1a8637aae..9420323c7e1 100644 --- a/lisp/cedet/semantic/wisent/javascript.el +++ b/lisp/cedet/semantic/wisent/javascript.el @@ -135,6 +135,7 @@ wisent-javascript-setup-parser semantic-tag-expand-function #'wisent-javascript-jv-expand-tag ;; Environment semantic-imenu-summary-function #'semantic-format-tag-name + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index semantic-command-separation-character ";" )) diff --git a/lisp/cedet/semantic/wisent/python.el b/lisp/cedet/semantic/wisent/python.el index 73f08beaa28..a4205bede50 100644 --- a/lisp/cedet/semantic/wisent/python.el +++ b/lisp/cedet/semantic/wisent/python.el @@ -514,6 +514,7 @@ wisent-python-default-setup ;; Semantic to take over from the one provided by python. ;; The python one, if it uses the senator advice, will hang ;; Emacs unrecoverably. + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index ;; I need a python guru to update this list: diff --git a/lisp/cedet/srecode/template.el b/lisp/cedet/srecode/template.el index 2417f1f7ef6..8b7fbf73979 100644 --- a/lisp/cedet/srecode/template.el +++ b/lisp/cedet/srecode/template.el @@ -53,6 +53,7 @@ srecode-template-setup-parser ;; Parsing ;; Environment semantic-imenu-summary-function #'semantic-format-tag-name + semantic--create-index-function-origin imenu-create-index-function imenu-create-index-function #'semantic-create-imenu-index semantic-command-separation-character "\n" semantic-lex-comment-regex ";;" -- 2.34.1