Subject: bug#76815: closed (Re: bug#76815: 31.0.50; [PATCH] Turning off semantic-mode should apply to each buffer))

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 07 Jun 2025 07:38:02 +0000

Your bug report

#76815: 31.0.50; [PATCH] Turning off semantic-mode should apply to each buffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
76815: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76815
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#76815: 31.0.50; [PATCH] Turning off semantic-mode should apply to each buffer)
From: Eli Zaretskii <[email-masked]>
To: Lin Sun <[email-masked]>
Cc: [email-masked]
Date: Sat, 07 Jun 2025 10:37:38 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Lin Sun <[email-masked]>
> Date: Sat, 10 May 2025 05:15:17 +0000
> msip_labels:
> 
> Hi Eli, Please help review the patch, thank you!
> 
> From: Lin Sun
> > There is a bug that turn off semantic-mode it only restores current buffer's imenu-create-index-function but actually turning on semantic-mode had changed each buffer's variable.
> > Reproduce steps:
> > 1) Open two files (eg /tmp/a.c, /tmp/b.c) in two buffers;
> > 2) Turn on semantic-mode, it will change the imenu-create-index-function value for each buffer;
> > 3) Turn off semantic-mode, it will restore current buffer's value (eg: b.c), but another one (eg: a.c) won't restored.
> >
> > When turning on semantic-mode, it applies changes to each buffer,
> >  1048         (dolist (b (buffer-list))
> >  1049           (with-current-buffer b
> >  1050             (semantic-new-buffer-fcn))))
> >
> > But turning off semantic does not restore the var for each buffer, only restores current buffer.
> >
> > This patch will fix the issue. Please help review it. Thanks.

Thanks, installed on the master branch, and closing the bug.

Subject: 31.0.50; [PATCH] Turning off semantic-mode should apply to each buffer
From: Lin Sun <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Fri, 7 Mar 2025 17:22:16 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,
There is a bug that turn off semantic-mode it only restores current buffer's imenu-create-index-function but actually turning on semantic-mode had changed each buffer's variable.
Reproduce steps:
1) Open two files (eg /tmp/a.c, /tmp/b.c) in two buffers; 
2) Turn on semantic-mode, it will change the imenu-create-index-function value for each buffer;
3) Turn off semantic-mode, it will restore current buffer's value (eg: b.c), but another one (eg: a.c) won't restored.

When turning on semantic-mode, it applies changes to each buffer, 
 1048         (dolist (b (buffer-list))
 1049           (with-current-buffer b
 1050             (semantic-new-buffer-fcn))))

But turning off semantic does not restore the var for each buffer, only restores current buffer.

This patch will fix the issue. Please help review it. Thanks.
Best Regards, Lin

From 9da3e3d627260d7f1e830db016a70b79a3a68b01 Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Fri, 7 Mar 2025 06:50:17 +0000
Subject: [PATCH] * lisp/cedet/semantic.el: Turning off semantic-mode applies
 to each buffer

---
 lisp/cedet/semantic.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index c0caa342865..542fea3df2a 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -1075,11 +1075,13 @@ semantic-mode
     ;; re-activated.
     (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))))))
+    (dolist (b (buffer-list))
+      (with-current-buffer b
+        (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
 
-- 
2.34.1