bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23460: 25.1.50; Strange behavior in local variables like start-comme


From: Alan Mackenzie
Subject: bug#23460: 25.1.50; Strange behavior in local variables like start-comment
Date: Fri, 6 May 2016 09:37:37 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

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).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]