From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rolf Ade Newsgroups: gmane.emacs.help Subject: Re: Hook doesn't run as expected, if buffer mode is set from major-mode Date: Sat, 09 Jan 2016 01:15:56 +0100 Organization: Me Message-ID: <87d1tb4ngj.fsf@linux-qg7d.fritz.box> References: <87h9in4zee.fsf@linux-qg7d.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1452298819 9705 80.91.229.3 (9 Jan 2016 00:20:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Jan 2016 00:20:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 09 01:20:18 2016 Return-path: Envelope-to: geh-help-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 1aHhGT-0005WJ-Pb for geh-help-gnu-emacs@m.gmane.org; Sat, 09 Jan 2016 01:20:17 +0100 Original-Received: from localhost ([::1]:38501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHhGS-0001ac-Td for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Jan 2016 19:20:16 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 25 Original-X-Trace: individual.net v1p/hZ0qCLX6PDzuK1wU+A+bHhp84x3QKKen62xa2Xm3/9VF8= Cancel-Lock: sha1:OuzpK+/gjb3sUX3KB1aNllNcKa4= sha1:1uTbEam2tEmahDSv+390G77laLM= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:216375 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108665 Archived-At: Drew Adams writes: >> If the major mode of a new buffer is determined by the variable >> major-mode (nothing from auto-mode-alist et. al matches), then the hooks >> of that major mode doesn't run, as I expect. > > `major-mode' is a buffer-local variable. > It is set by the newly current major mode. > IOW, you cannot use it to set the mode, as the mode sets it. So, what do you think determines the major-mode of a new buffer, if (as I wrote) nothing from auto-mode-alist, interpreter-mode-alist and magic-mode-alist matches? What should I use for that (if I don't want the default fundamental-mode)? It is right, that major-mode is a buffer-local variable. And it is also true, that it is set by the newly current major-mode. But what value does the local variable major-mode have, if there isn't a major-mode, for a new buffer? Right, its default value. And this is a way to set the major mode of a new buffer, if there isn't another known from other sources. Take a look at C-h v major-mode RET. (And, maybe, C-h v default-major-mode RET).