From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23460: 25.1.50; Strange behavior in local variables like start-comment Date: Thu, 5 May 2016 22:22:11 +0000 Message-ID: <20160505222211.GE1950@acm.fritz.box> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1462487024 26760 80.91.229.3 (5 May 2016 22:23:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 May 2016 22:23:44 +0000 (UTC) Cc: 23460@debbugs.gnu.org To: Kaushal Modi Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 06 00:23:31 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ayRgB-00086e-1i for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 May 2016 00:23:31 +0200 Original-Received: from localhost ([::1]:55618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayRg7-00053d-1Q for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 May 2016 18:23:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayRfx-0004pH-Hp for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 18:23:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayRfl-0006i7-AC for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 18:23:12 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayRfl-0006hJ-73 for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 18:23:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ayRfh-00064n-Rq for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 18:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 May 2016 22:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23460 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23460-submit@debbugs.gnu.org id=B23460.146248693523301 (code B ref 23460); Thu, 05 May 2016 22:23:01 +0000 Original-Received: (at 23460) by debbugs.gnu.org; 5 May 2016 22:22:15 +0000 Original-Received: from localhost ([127.0.0.1]:40882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayRex-00063k-D5 for submit@debbugs.gnu.org; Thu, 05 May 2016 18:22:15 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:51683) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayRev-00063Y-22 for 23460@debbugs.gnu.org; Thu, 05 May 2016 18:22:13 -0400 Original-Received: (qmail 67298 invoked by uid 3782); 5 May 2016 22:22:12 -0000 Original-Received: from acm.muc.de (p548C62E6.dip0.t-ipconnect.de [84.140.98.230]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 06 May 2016 00:22:11 +0200 Original-Received: (qmail 27688 invoked by uid 1000); 5 May 2016 22:22:11 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:117878 Archived-At: Hello, Kaushal. On Thu, May 05, 2016 at 08:35:04PM +0000, Kaushal Modi wrote: > 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. Yes. I think this is intended, and wasn't changed by my recent patch. > 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 I haven't actually looked at that yet. But where, with respect to setting the major mode, does the outshine function look at comment-start? > 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. Were you doing anything involving changing the major mode at the time? (See below.) > 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. Thanks for taking the trouble to create this minimal test code. It makes it so much easier to understand when people do this. :-) > (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 "") (lambda () (interactive) (revert-buffer > nil :noconfirm))) > (global-set-key (kbd "") #'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?! OK. Have a look at the *Messages* buffer. You will see the messages come in pairs: (I actually did this in a C Mode buffer.) `comment-start' = `/* ' `comment-start' is undefined, it's value is: `nil' But in the echo area, you will only see the second one. > I have tested this only for comment-start. But I suspect this might affect > buffer local vars in general? I think so, too. When you visit a buffer, Emacs calls `normal-mode' to determine and set the major mode. The first thing `normal-mode' does is to call `fundamental-mode'. This invokes `change-major-mode-hook', which outputs the first "comment-start" message. Then `fundamental-mode' kills all local variables, including `comment-start'. `normal-mode' then determines the correct major mode, and calls it. This invokes `change-major-mode-hook' again, which outputs the second "comment-start" message with the `nil'. The major mode is then fully set up, including giving a value to `comment-start'. So, this code seems to be working the way it's intended to. What is outshine doing that triggers a problem in this area? Is it doing things with the `change-major-mode-hook' that involve using `comment-start'? Maybe this is the problem. > 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) [ .... ] > 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] > -- > Kaushal Modi -- Alan Mackenzie (Nuremberg, Germany).