From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Can one modify a variable definition in a major mode depending on buffer name? Date: Sat, 30 Jul 2016 13:37:28 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1469900322 27288 80.91.229.8 (30 Jul 2016 17:38:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Jul 2016 17:38:42 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 30 19:38:28 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTYDL-0006y2-Kk for geh-help-gnu-emacs@m.gmane.org; Sat, 30 Jul 2016 19:38:19 +0200 Original-Received: from localhost ([::1]:36577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTYDH-0002Ud-PJ for geh-help-gnu-emacs@m.gmane.org; Sat, 30 Jul 2016 13:38:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTYCt-0002Ju-Ic for help-gnu-emacs@gnu.org; Sat, 30 Jul 2016 13:37:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTYCp-0005Mu-Ct for help-gnu-emacs@gnu.org; Sat, 30 Jul 2016 13:37:50 -0400 Original-Received: from blaine.gmane.org ([80.91.229.8]:52787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTYCp-0005Mi-6B for help-gnu-emacs@gnu.org; Sat, 30 Jul 2016 13:37:47 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1bTYCi-0006j8-L0 for help-gnu-emacs@gnu.org; Sat, 30 Jul 2016 19:37:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 15 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:CTvi123YOvFi7Rv/bu2XOxEgWJk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.91.229.8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:111026 Archived-At: > My use case is modifying our perl6-mode for the slight difference in > allowable identifiers between Perl 6 and NQP (Not Quite Perl). By > convention, nqp files end in ".nqp" so that the buffer name should be a > good way to automatically change the single regex bound to a var name in > the mode file. That would save having to write another major mode just for > such a small change. (add-to-list 'auto-mode-alist '("\\.nqp\\'" . nqp-mode)) (define-derived-mode nqp-mode perl-mode "NQP" "Major mode for NQP's subset of Perl 6." (setq-local the-var-i-need-to-change the-new-value)) -- Stefan