GNU bug report logs - #23460
25.1.50; Strange behavior in local variables like start-comment

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Thu, 5 May 2016 20:37:02 UTC

Severity: normal

Merged with 23463

Found in version 25.1.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 23460 <at> debbugs.gnu.org
Subject: bug#23460: 25.1.50; Strange behavior in local variables like start-comment
Date: Fri, 6 May 2016 09:37:37 +0000
Hello, Kaushal.

On Thu, May 05, 2016 at 10:20:27PM +0000, Kaushal Modi wrote:


> > I'll keep you posted.


> OK, I was able to get a minimum working example sooner than I thought :)

> Please save the below as test.el (or some file name; else revert-buffer
> will not work), open it in emacs -Q and evaluate it.

> ===== test.el =====
> (progn
>   (defun my/print-comment-start-value ()
>     (interactive)
>     (message (format "`comment-start' = `%s'" comment-start)))

>   (defun my/repeat-revert-buffer-noconfirm (count)
>     (interactive "p")
>     (dotimes (i count)
>       (revert-buffer nil :noconfirm)))

>   (add-hook 'outline-minor-mode-hook #'my/print-comment-start-value)
> ;  (remove-hook 'outline-minor-mode-hook #'my/print-comment-start-value)

>   (global-set-key (kbd "<f5>") #'my/repeat-revert-buffer-noconfirm))

> ;; Local Variables:
> ;; eval: (outline-minor-mode 1)
> ;; End:
> =====

> In emacs 25.0.93 (emacs-25 build), after opening test.el, evaluating it and
> hitting F5, I get below (which is good, expected):

> ‘comment-start’ = ‘;’ [2 times]

> But in emacs 25.1.50 (master build), after opening test.el, evaluating it
> and hitting F5, I get:

> ‘comment-start’ = ‘;’
> ‘comment-start’ = ‘nil’ [2 times]
> ‘comment-start’ = ‘;’

> So it looks like the outline-minor-mode-hook is called twice more in the
> master branch and also intermittently, the comment-start loses its buffer
> local value.

> Hope this mini test helps debug this.

Yes, thanks!

I think I've nailed it - normal-mode is calling hack-local-variables
right at the start, when it shouldn't.

Could you please try out the following patch (which I've also posted for
bug #23463):



diff --git a/lisp/files.el b/lisp/files.el
index d89b2f5..21f7bdc 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2316,7 +2316,10 @@ normal-mode
 or from Lisp without specifying the optional argument FIND-FILE;
 in that case, this function acts as if `enable-local-variables' were t."
   (interactive)
-  (fundamental-mode)
+  (kill-all-local-variables)
+  (unless delay-mode-hooks
+    (run-hooks 'change-major-mode-after-body-hook
+               'after-change-major-mode-hook))
   (let ((enable-local-variables (or (not find-file) enable-local-variables)))
     ;; FIXME this is less efficient than it could be, since both
     ;; s-a-m and h-l-v may parse the same regions, looking for "mode:".


> -- 
> Kaushal Modi

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 9 years and 76 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.