Subject: 25.1.50; Strange behavior in local variables like start-comment

From: Kaushal Modi <[email-masked]>
Date: Thu, 05 May 2016 20:35:04 +0000

--text follows this line--

It looks like after the recent commit (
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=25f455815bfaa868dc470d445413df9a7a546c46
),
the buffer local variables like comment-start are behaving strangely. They
commentarily go to a value of nil (or their default value?) and then back
to the buffer local value in the current buffer.

I discovered this issue as I am using outshine package and in one of the
functions in there, a check is put to ensure that comment-start is not nil:
https://github.com/tj64/outshine/blob/73ae2c2ea24001338dbeff5137f09bb5f784f12c/outshine.el#L1105-L1108

Surprisingly, my *Messages* buffer started showing the "Cannot calculate
outcommented outline-regexp without 'comment-start' character defined!"
message. But I was working in a shell-script-mode buffer and comment-start
IS defined: "# ". I even verified doing C-h v comment-start that that
actually was the case.

I then realized that I saw that message each time I reverted the buffer (or
looked like each time the buffer's major mode hook was called (and that's
why I suspect commit 25f4558.. to be the problem; please correct if that's
wrong). I do not see this bug in emacs-25 branch build.

Here is a minimum working example to test this bug behavior in an emacs -Q
session.

(progn
  (defun my/print-comment-start-value ()
    (interactive)
    (let ((filler (if (null comment-start)
      "is undefined, it's value is:"
    "=")))
      (message (format "`comment-start' %s `%s'" filler comment-start))))

    (global-set-key (kbd "<f5>") (lambda () (interactive) (revert-buffer
nil :noconfirm)))
    (global-set-key (kbd "<f6>") #'my/print-comment-start-value)

    (add-hook 'change-major-mode-hook #'my/print-comment-start-value))

(1) Evaluate the above in emacs -Q
(2) You would be in *scratch* buffer and that's alright
(3) Hit F5 couple of times and you should see
     ‘comment-start’ is undefined, it’s value is: ‘nil’
(4) Now hit F6 (which just prints the value of comment-start variable) and
you will see
    ‘comment-start’ = ‘;’
(5) Isn't that strange?!

I have tested this only for comment-start. But I suspect this might affect
buffer local vars in general?

In GNU Emacs 25.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
 of 2016-05-05 built on ...
Repository revision: 67fa7f13d499eb5fc1d697da6c636b20728da22f
Windowing system distributor 'The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Workstation release 6.6
(Santiago)

Configured using:
 'configure --with-modules
 --prefix=/home/kmodi/usr_local/apps/6/emacs/master
 'CPPFLAGS=-fgnu89-inline -I/home/kmodi/usr_local/6/include
 -I/usr/include/freetype2 -I/usr/include' 'CFLAGS=-O2 -march=native'
 'LDFLAGS=-L/home/kmodi/usr_local/6/lib -L/home/kmodi/usr_local/6/lib64'
 PKG_CONFIG_PATH=/home/kmodi/usr_local/6/lib/pkgconfig:/home/kmodi/usr_local/6/lib64/pkgconfig:/cad/adi/apps/gnu/linux/x86_64/6/lib/pkgconfig:/cad/adi/apps/gnu/linux/x86_64/6/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig:/lib64/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
‘comment-start’ is undefined, it’s value is: ‘nil’
‘comment-start’ = ‘;’
‘comment-start’ is undefined, it’s value is: ‘nil’
‘comment-start’ = ‘;’
‘comment-start’ is undefined, it’s value is: ‘nil’
‘comment-start’ = ‘;’ [2 times]
‘comment-start’ is undefined, it’s value is: ‘nil’
‘comment-start’ = ‘;’ [4 times]
‘comment-start’ is undefined, it’s value is: ‘nil’
Mark set [2 times]

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message puny seq byte-opt gv bytecomp
byte-compile cl-extra cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils edmacro kmacro dabbrev thingatpt help-fns
help-mode cl-loaddefs pcase cl-lib misearch multi-isearch vc-git
diff-mode easymenu easy-mmode time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 106397 10580)
 (symbols 48 21437 0)
 (miscs 40 69 299)
 (strings 32 20571 5469)
 (string-bytes 1 636526)
 (vectors 16 14269)
 (vector-slots 8 449017 7199)
 (floats 8 192 484)
 (intervals 56 1492 352)
 (buffers 976 14)
 (heap 1024 17132 609))

-- 

-- 
Kaushal Modi