* bug#74803: 31.0.50; [PATCH] Fix bug that semantic did not restore imenu-create-index-function on exiting
@ 2024-12-11 22:30 Lin Sun
2024-12-14 10:40 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Lin Sun @ 2024-12-11 22:30 UTC (permalink / raw)
To: 74803
[-- Attachment #1: Type: text/plain, Size: 736 bytes --]
The semantic minor mode changed the value of imenu-create-index-function on its startup, but does not restore the original value on its exiting.
Here are the steps to reproduce the issue:
1. Start the emacs and open a python script, now the imenu-create-index-function will be the `python-imenu-create-index'
$ emacs -nw -q ~/a.py
2. Turn-on the semantic by "M-x semantic-mode", then the imenu-create-index-function will be the `semantic-create-imenu-index'
3. Turn-off the semantic by "M-x semantic-mode", imenu-create-index-function is still the semantic one.
This patch will store the original imenu-create-index-function before changing it, and restore the original value when turn-off the semantic-mode.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-bug-that-semantic-did-not-restore-imenu-create-i.patch --]
[-- Type: text/x-patch; name="0001-Fix-bug-that-semantic-did-not-restore-imenu-create-i.patch", Size: 7222 bytes --]
From 3aa1b8b3905b5a3db0304d24d869fe601324df43 Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#74803: 31.0.50; [PATCH] Fix bug that semantic did not restore imenu-create-index-function on exiting
2024-12-11 22:30 bug#74803: 31.0.50; [PATCH] Fix bug that semantic did not restore imenu-create-index-function on exiting Lin Sun
@ 2024-12-14 10:40 ` Eli Zaretskii
2024-12-14 17:01 ` Lin Sun
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-12-14 10:40 UTC (permalink / raw)
To: Lin Sun; +Cc: 74803-done
> From: Lin Sun <sunlin7@hotmail.com>
> Date: Wed, 11 Dec 2024 22:30:02 +0000
>
> The semantic minor mode changed the value of imenu-create-index-function on its startup, but does not restore the original value on its exiting.
>
> Here are the steps to reproduce the issue:
>
> 1. Start the emacs and open a python script, now the imenu-create-index-function will be the `python-imenu-create-index'
>
> $ emacs -nw -q ~/a.py
>
> 2. Turn-on the semantic by "M-x semantic-mode", then the imenu-create-index-function will be the `semantic-create-imenu-index'
>
> 3. Turn-off the semantic by "M-x semantic-mode", imenu-create-index-function is still the semantic one.
>
> This patch will store the original imenu-create-index-function before changing it, and restore the original value when turn-off the semantic-mode.
Thanks, installed on the master branch, and closing the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-14 17:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 22:30 bug#74803: 31.0.50; [PATCH] Fix bug that semantic did not restore imenu-create-index-function on exiting Lin Sun
2024-12-14 10:40 ` Eli Zaretskii
2024-12-14 17:01 ` Lin Sun
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.