From unknown Sat Sep 13 17:18:36 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#9820 <9820@debbugs.gnu.org> To: bug#9820 <9820@debbugs.gnu.org> Subject: Status: 24.0.90; Behaviour of add-file-local-variable Reply-To: bug#9820 <9820@debbugs.gnu.org> Date: Sun, 14 Sep 2025 00:18:36 +0000 retitle 9820 24.0.90; Behaviour of add-file-local-variable reassign 9820 emacs submitter 9820 Jambunathan K severity 9820 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 21 01:13:15 2011 Received: (at submit) by debbugs.gnu.org; 21 Oct 2011 05:13:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RH7Pv-0000yw-Hy for submit@debbugs.gnu.org; Fri, 21 Oct 2011 01:13:15 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RH7Pt-0000yj-J0 for submit@debbugs.gnu.org; Fri, 21 Oct 2011 01:13:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RH7Od-0007wr-1k for submit@debbugs.gnu.org; Fri, 21 Oct 2011 01:11:56 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_WEB, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:44153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RH7Od-0007wn-0A for submit@debbugs.gnu.org; Fri, 21 Oct 2011 01:11:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RH7Ob-00054U-Fw for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2011 01:11:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RH7OZ-0007wY-UZ for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2011 01:11:53 -0400 Received: from mail-yw0-f41.google.com ([209.85.213.41]:40210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RH7OZ-0007wN-Qu for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2011 01:11:51 -0400 Received: by ywa17 with SMTP id 17so579267ywa.0 for ; Thu, 20 Oct 2011 22:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:mime-version:content-type; bh=0JWDBZAgSSng2nwJpmzQYw5/W16yln4hHlQGlKQ8S+I=; b=Ow0FKE/V6gnmWCbG6BAp//oFBC19l9NS5ima1TDs7tNts7s26nvmv39Ru/WZSapC8s v2qyhUGiEDgDVrbTFazGk6LDuX6hv+UFyELs5291ZdQEPxwyqbngOpumSWaPr3K6x9my /+rJcsbKMIdzOQ7o8Lqh4aORCBNiX4h3dKNT4= Received: by 10.68.12.104 with SMTP id x8mr25243714pbb.79.1319173910454; Thu, 20 Oct 2011 22:11:50 -0700 (PDT) Received: from JAMBU-NETBOOK ([115.241.126.50]) by mx.google.com with ESMTPS id x7sm26243875pbf.5.2011.10.20.22.11.46 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Oct 2011 22:11:49 -0700 (PDT) From: Jambunathan K To: bug-gnu-emacs@gnu.org Subject: 24.0.90; Behaviour of add-file-local-variable Date: Fri, 21 Oct 2011 10:41:30 +0530 Message-ID: <8162jjj5dp.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.7 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) --=-=-= Content-Type: text/plain 24.0.90; Behaviour of add-file-local-variable Transcripts of exchanges on emacs-devel. http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00850.html http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00867.html Additional note: All other file-local related commands may have to be audited for the requested behaviour. --=-=-= Content-Type: text/plain Content-Disposition: inline From: Jambunathan K Subject: Re: Behaviour of add-file-local-variable? Newsgroups: gmane.emacs.devel To: Juri Linkov Cc: emacs-devel@gnu.org Date: Thu, 20 Oct 2011 09:51:36 +0530 (1 day, 45 minutes, 50 seconds ago) Message-ID: <81fwioqomn.fsf@gmail.com> Mail-Followup-To: Juri Linkov , emacs-devel@gnu.org Juri Linkov writes: >> Should add-file-local-variable also set the variable immediately rather >> than merely updating the file footer? > While keeping text in the Local Variables section in sync with actual > values looks like the right thing to do, it raises related questions > that are more difficult to decide: If a user adds a file local variable and intends that it take immediately what will he do? I believe he is more likely to revert the file. Does "act-as-though-the-file-were-reverted policy" still very difficult to deal with while applying file local variables? Even if you insist on retaining the existing behaviour, at the minimum I need some warning that the local variable has not kicked in. This could be handled by 1. Updating the docstring of the above commands 2. Prompting the user whether he wants to "apply" the changes (in much the same way that a user is warned of risky or non-safe variables) 3. Provide a prefix modifier to the commands (1) is the easiest way to tackle it. Anyways, I surprised by the current behaviour and it took sometime to figure out what's happening. > Should `M-x add-file-local-variable RET mode RET' also change current mode? > > Should `M-x add-file-local-variable RET coding RET' also change the > current buffer coding? > > Should `M-x add-file-local-variable RET eval RET' evaluate the added expression? > > Should `delete-file-local-variable' return the previous buffer-local value > or revert to the global value? > > Should `add-dir-local-variable' after modifying .dir-locals.el > also update values in all visited file buffers in all subdirectories? -- --=-=-= Content-Type: text/plain Content-Disposition: inline From: Nix Subject: Re: Behaviour of add-file-local-variable? Newsgroups: gmane.emacs.devel To: Stefan Monnier Cc: Juri Linkov , emacs-devel@gnu.org Date: Fri, 21 Oct 2011 01:01:10 +0100 (5 hours, 5 minutes, 8 seconds ago) Message-ID: <87y5wfmcvt.fsf@spindle.srvr.nix> On 20 Oct 2011, Stefan Monnier stated: > I think that add-file-local-variable could simply check if the > variable's value is already the new one and if not output a message > along the lines "Done; revisit the file to make it take effect" (tho > "take effect" doesn't sound right: please native speakers fix it for > me). Your instincts mislead you: it's right. Perhaps a more explicit "Revisit file to make this change take effect" would be better? (But that's style, not grammar.) -- NULL && (void) --=-=-= Content-Type: text/plain In GNU Emacs 24.0.90.1 (i386-mingw-nt5.1.2600) of 2011-10-19 on MARVIN Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (4.6) --no-opt --cflags -I"C:/Program Files (x86)/GnuWin32/include" -ID:/devel/emacs/libXpm-3.5.8/include -ID:/devel/emacs/libXpm-3.5.8/src -ID:/devel/emacs/gnutls-2.10.5-x86/include --ldflags -LD:/devel/emacs/gnutls-2.10.5-x86/lib' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 21 10:12:56 2011 Received: (at 9820) by debbugs.gnu.org; 21 Oct 2011 14:12:56 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHFqA-0006Xx-QX for submit@debbugs.gnu.org; Fri, 21 Oct 2011 10:12:56 -0400 Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHFq5-0006Xh-Di for 9820@debbugs.gnu.org; Fri, 21 Oct 2011 10:12:50 -0400 Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id A559D6E808A; Fri, 21 Oct 2011 07:11:34 -0700 (PDT) Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id CA009451C452; Fri, 21 Oct 2011 07:11:33 -0700 (PDT) From: Juri Linkov To: Jambunathan K Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Organization: JURTA References: <8162jjj5dp.fsf@gmail.com> Date: Fri, 21 Oct 2011 17:06:10 +0300 In-Reply-To: <8162jjj5dp.fsf@gmail.com> (Jambunathan K.'s message of "Fri, 21 Oct 2011 10:41:30 +0530") Message-ID: <87ehy61n79.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 9820 Cc: 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) > Transcripts of exchanges on emacs-devel. > http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00850.html > http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00867.html Thanks for filing the bug report based on that discussion. As suggested, the following patch implements displaying a message. > Additional note: All other file-local related commands may have to be > audited for the requested behaviour. It displays a message only in `add-file-local-variable' and `add-file-local-variable-prop-line'. I have no opinion what other commands might do. === modified file 'lisp/files-x.el' --- lisp/files-x.el 2011-04-19 13:44:55 +0000 +++ lisp/files-x.el 2011-10-21 14:04:22 +0000 @@ -214,7 +214,11 @@ (defun add-file-local-variable (variable (interactive (let ((variable (read-file-local-variable "Add file-local variable"))) (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable variable value 'add-or-replace)) + (modify-file-local-variable variable value 'add-or-replace) + (when (and (called-interactively-p 'interactive) + (symbolp variable) (boundp variable) + (not (equal (symbol-value variable) value))) + (message "Revisit file to make this change take effect"))) ;;;###autoload (defun delete-file-local-variable (variable) @@ -335,7 +339,11 @@ (defun add-file-local-variable-prop-line (interactive (let ((variable (read-file-local-variable "Add -*- file-local variable"))) (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable-prop-line variable value 'add-or-replace)) + (modify-file-local-variable-prop-line variable value 'add-or-replace) + (when (and (called-interactively-p 'interactive) + (symbolp variable) (boundp variable) + (not (equal (symbol-value variable) value))) + (message "Revisit file to make this change take effect"))) ;;;###autoload (defun delete-file-local-variable-prop-line (variable) From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 21 13:41:15 2011 Received: (at 9820) by debbugs.gnu.org; 21 Oct 2011 17:41:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHJ5n-0004K2-Ed for submit@debbugs.gnu.org; Fri, 21 Oct 2011 13:41:15 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHJ5l-0004Jp-3V for 9820@debbugs.gnu.org; Fri, 21 Oct 2011 13:41:13 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EAA2uoU5MCqLO/2dsb2JhbABDpxiCBoEGgW4BAQVWIxALNBIUGA0kvCeIQAShMoRF X-IronPort-AV: E=Sophos;i="4.69,387,1315195200"; d="scan'208";a="143619500" Received: from 76-10-162-206.dsl.teksavvy.com (HELO pastel.home) ([76.10.162.206]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 21 Oct 2011 13:39:52 -0400 Received: by pastel.home (Postfix, from userid 20848) id E1D42591FD; Fri, 21 Oct 2011 13:39:51 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Message-ID: References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> Date: Fri, 21 Oct 2011 13:39:51 -0400 In-Reply-To: <87ehy61n79.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 21 Oct 2011 17:06:10 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9820 Cc: Jambunathan K , 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > === modified file 'lisp/files-x.el' > --- lisp/files-x.el 2011-04-19 13:44:55 +0000 > +++ lisp/files-x.el 2011-10-21 14:04:22 +0000 > @@ -214,7 +214,11 @@ (defun add-file-local-variable (variable > (interactive > (let ((variable (read-file-local-variable "Add file-local variable"))) > (list variable (read-file-local-variable-value variable)))) > - (modify-file-local-variable variable value 'add-or-replace)) > + (modify-file-local-variable variable value 'add-or-replace) > + (when (and (called-interactively-p 'interactive) > + (symbolp variable) (boundp variable) > + (not (equal (symbol-value variable) value))) > + (message "Revisit file to make this change take effect"))) Please pass use an optional `interactive' arg instead of called-interactively-p. You might even want to pass that arg down to modify-file-local-variable so as to avoid duplicating the test and message. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 22 00:59:32 2011 Received: (at 9820) by debbugs.gnu.org; 22 Oct 2011 04:59:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHTgB-0002cz-Rr for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:59:32 -0400 Received: from mail-pz0-f50.google.com ([209.85.210.50]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHTg9-0002cl-EK for 9820@debbugs.gnu.org; Sat, 22 Oct 2011 00:59:30 -0400 Received: by pzk34 with SMTP id 34so11568800pzk.9 for <9820@debbugs.gnu.org>; Fri, 21 Oct 2011 21:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=OK94az/C5qEW7MW01Se0fAkgbh2hPAhdIQmDbUYNgWI=; b=k0DqisjcQH3scYIwR9oxWv3yHWQ769s9wDDgYh10kYrtqXTv8Zzqh2hwG1okx4nbUA 1VOKP9ZKVt+zoQDM81babxnvLSYhS70SGrWe6p/DUNZzboqqcXMqLvoayBGbqmpaJ/yI 3OusOR8h9zdTvLKlFjbYwXmCZ2Bqhsilryw0Q= Received: by 10.68.32.2 with SMTP id e2mr32869061pbi.68.1319259485560; Fri, 21 Oct 2011 21:58:05 -0700 (PDT) Received: from JAMBU-NETBOOK ([115.242.165.74]) by mx.google.com with ESMTPS id z3sm37889951pbu.7.2011.10.21.21.58.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Oct 2011 21:58:04 -0700 (PDT) From: Jambunathan K To: Juri Linkov Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> Date: Sat, 22 Oct 2011 10:27:53 +0530 In-Reply-To: <87ehy61n79.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 21 Oct 2011 17:06:10 +0300") Message-ID: <8139el1v3i.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 9820 Cc: 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) >> Additional note: All other file-local related commands may have to be >> audited for the requested behaviour. > > It displays a message only in `add-file-local-variable' and > `add-file-local-variable-prop-line'. I have no opinion > what other commands might do. Would you like to give me a new patch with the warning message pushed to modify-* routines (as Stefan suggested). This way a (message ...) can be issued as soon as any modifications - add-or-replace or delete - happen on the buffer. I think the extra intelligence of checking for new value against the old value could be dropped altogether. The message is merely meant as a warning, so being paranoid and issuing a warning ALWAYS will also serve the purpose well. > === modified file 'lisp/files-x.el' > --- lisp/files-x.el 2011-04-19 13:44:55 +0000 > +++ lisp/files-x.el 2011-10-21 14:04:22 +0000 > @@ -214,7 +214,11 @@ (defun add-file-local-variable (variable > (interactive > (let ((variable (read-file-local-variable "Add file-local variable"))) > (list variable (read-file-local-variable-value variable)))) > - (modify-file-local-variable variable value 'add-or-replace)) > + (modify-file-local-variable variable value 'add-or-replace) > + (when (and (called-interactively-p 'interactive) > + (symbolp variable) (boundp variable) > + (not (equal (symbol-value variable) value))) > + (message "Revisit file to make this change take effect"))) > > ;;;###autoload > (defun delete-file-local-variable (variable) > @@ -335,7 +339,11 @@ (defun add-file-local-variable-prop-line > (interactive > (let ((variable (read-file-local-variable "Add -*- file-local variable"))) > (list variable (read-file-local-variable-value variable)))) > - (modify-file-local-variable-prop-line variable value 'add-or-replace)) > + (modify-file-local-variable-prop-line variable value 'add-or-replace) > + (when (and (called-interactively-p 'interactive) > + (symbolp variable) (boundp variable) > + (not (equal (symbol-value variable) value))) > + (message "Revisit file to make this change take effect"))) > > ;;;###autoload > (defun delete-file-local-variable-prop-line (variable) From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 22 01:50:32 2011 Received: (at 9820) by debbugs.gnu.org; 22 Oct 2011 05:50:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHUTX-000400-RB for submit@debbugs.gnu.org; Sat, 22 Oct 2011 01:50:32 -0400 Received: from mail-pz0-f50.google.com ([209.85.210.50]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHUTV-0003zk-04 for 9820@debbugs.gnu.org; Sat, 22 Oct 2011 01:50:30 -0400 Received: by pzk34 with SMTP id 34so11644463pzk.9 for <9820@debbugs.gnu.org>; Fri, 21 Oct 2011 22:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=yFby6kqNeXAAtDn0P6Szf9u3CXCXB71YvRWjt+oyTis=; b=Rvc+CJsJIl3F1cZo7HP3mW0zGHeqAd5HWShRNSdEd2E7NezFsVSsymbmjTXlaDgD5X Zh8ks41MHvRaen98KN6f7TCvl//hu6Pz8uSZ6PF880A3uN0CsuG/N2t+2Q1lZaf9dorU /8uDWXTdnASC4BO8PVDG07CLEyyJvF8qEi5X4= Received: by 10.68.73.232 with SMTP id o8mr5845261pbv.82.1319262545128; Fri, 21 Oct 2011 22:49:05 -0700 (PDT) Received: from JAMBU-NETBOOK ([115.242.165.74]) by mx.google.com with ESMTPS id ko15sm38304664pbb.9.2011.10.21.22.49.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Oct 2011 22:49:03 -0700 (PDT) From: Jambunathan K To: Juri Linkov Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> Date: Sat, 22 Oct 2011 11:18:54 +0530 In-Reply-To: <8139el1v3i.fsf@gmail.com> (Jambunathan K.'s message of "Sat, 22 Oct 2011 10:27:53 +0530") Message-ID: <81vcrhzid5.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.9 (---) X-Debbugs-Envelope-To: 9820 Cc: 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.9 (---) > The message is merely meant as a warning, so being paranoid and > issuing a warning ALWAYS will also serve the purpose well. How about - "Local Variables section updated. To update actual variable values, revisit the file" The message is bit longer. However, it captures the spirit of these commands. Jambunathan K. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 22 11:43:47 2011 Received: (at 9820) by debbugs.gnu.org; 22 Oct 2011 15:43:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHdjf-0001IQ-2O for submit@debbugs.gnu.org; Sat, 22 Oct 2011 11:43:47 -0400 Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHdjc-0001IG-O4 for 9820@debbugs.gnu.org; Sat, 22 Oct 2011 11:43:45 -0400 Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id 55AE36E8061; Sat, 22 Oct 2011 08:42:23 -0700 (PDT) Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 34D29451C4E8; Sat, 22 Oct 2011 08:42:21 -0700 (PDT) From: Juri Linkov To: Jambunathan K Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Organization: JURTA References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> Date: Sat, 22 Oct 2011 18:35:47 +0300 In-Reply-To: <81vcrhzid5.fsf@gmail.com> (Jambunathan K.'s message of "Sat, 22 Oct 2011 11:18:54 +0530") Message-ID: <87fwilkqck.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 9820 Cc: 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) > How about - > "Local Variables section updated. That's exactly what these commands purposely do, and users see as a result, so there is no need to reiterate the obvious fact in the message. > To update actual variable values, revisit the file" If it's more clear, we could change: "Revisit file to make this change take effect" to "Revisit file to update actual variable values" > This way a (message ...) can be issued as soon as any modifications - > add-or-replace or delete - happen on the buffer. I think the extra > intelligence of checking for new value against the old value could be > dropped altogether. The message is merely meant as a warning, so being > paranoid and issuing a warning ALWAYS will also serve the purpose well. After moving this message to modify-file-local-variable, checking for new value against the old value really makes less sense because it's unclear what to do for the `delete' operations, so I removed this check below. > Would you like to give me a new patch with the warning message pushed to > modify-* routines (as Stefan suggested). Please try a new patch: === modified file 'lisp/files-x.el' --- lisp/files-x.el 2011-04-19 13:44:55 +0000 +++ lisp/files-x.el 2011-10-22 15:34:12 +0000 @@ -115,7 +115,7 @@ (defun read-file-local-variable-mode () ((and (stringp mode) (fboundp (intern mode))) (intern mode)) (t mode)))) -(defun modify-file-local-variable (variable value op) +(defun modify-file-local-variable (variable value op &optional interactive) "Modify file-local VARIABLE in Local Variables depending on operation OP. If OP is `add-or-replace' then delete all existing settings of @@ -198,10 +198,13 @@ (defun modify-file-local-variable (varia ((eq variable 'mode) (goto-char beg)) ((null replaced-pos) (goto-char end)) (replaced-pos (goto-char replaced-pos))) - (insert (format "%s%S: %S%s\n" prefix variable value suffix))))))) + (insert (format "%s%S: %S%s\n" prefix variable value suffix))) + + (when interactive + (message "Revisit file to make this change take effect")))))) ;;;###autoload -(defun add-file-local-variable (variable value) +(defun add-file-local-variable (variable value &optional interactive) "Add file-local VARIABLE with its VALUE to the Local Variables list. This command deletes all existing settings of VARIABLE (except `mode' @@ -213,17 +216,17 @@ (defun add-file-local-variable (variable `Local Variables:' and the last line containing the string `End:'." (interactive (let ((variable (read-file-local-variable "Add file-local variable"))) - (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable variable value 'add-or-replace)) + (list variable (read-file-local-variable-value variable) t))) + (modify-file-local-variable variable value 'add-or-replace interactive)) ;;;###autoload -(defun delete-file-local-variable (variable) +(defun delete-file-local-variable (variable &optional interactive) "Delete all settings of file-local VARIABLE from the Local Variables list." (interactive - (list (read-file-local-variable "Delete file-local variable"))) - (modify-file-local-variable variable nil 'delete)) + (list (read-file-local-variable "Delete file-local variable") t)) + (modify-file-local-variable variable nil 'delete interactive)) -(defun modify-file-local-variable-prop-line (variable value op) +(defun modify-file-local-variable-prop-line (variable value op &optional interactive) "Modify file-local VARIABLE in the -*- line depending on operation OP. If OP is `add-or-replace' then delete all existing settings of @@ -320,10 +323,13 @@ (defun modify-file-local-variable-prop-l (insert ";")) (unless (eq (char-before) ?\s) (insert " ")) (insert (format "%S: %S;" variable value)) - (unless (eq (char-after) ?\s) (insert " ")))))))) + (unless (eq (char-after) ?\s) (insert " ")))))) + + (when interactive + (message "Revisit file to make this change take effect")))) ;;;###autoload -(defun add-file-local-variable-prop-line (variable value) +(defun add-file-local-variable-prop-line (variable value &optional interactive) "Add file-local VARIABLE with its VALUE to the -*- line. This command deletes all existing settings of VARIABLE (except `mode' @@ -334,15 +340,15 @@ (defun add-file-local-variable-prop-line then this function adds it." (interactive (let ((variable (read-file-local-variable "Add -*- file-local variable"))) - (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable-prop-line variable value 'add-or-replace)) + (list variable (read-file-local-variable-value variable) t))) + (modify-file-local-variable-prop-line variable value 'add-or-replace interactive)) ;;;###autoload -(defun delete-file-local-variable-prop-line (variable) +(defun delete-file-local-variable-prop-line (variable &optional interactive) "Delete all settings of file-local VARIABLE from the -*- line." (interactive - (list (read-file-local-variable "Delete -*- file-local variable"))) - (modify-file-local-variable-prop-line variable nil 'delete)) + (list (read-file-local-variable "Delete -*- file-local variable") t)) + (modify-file-local-variable-prop-line variable nil 'delete interactive)) (defvar auto-insert) ; from autoinsert.el From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 23 14:00:55 2011 Received: (at 9820) by debbugs.gnu.org; 23 Oct 2011 18:00:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RI2Lu-0004BT-To for submit@debbugs.gnu.org; Sun, 23 Oct 2011 14:00:55 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RI2Lt-0004BH-Qc for 9820@debbugs.gnu.org; Sun, 23 Oct 2011 14:00:54 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAM1VpE5MCqLO/2dsb2JhbABDqRGBBoFuAQEEAVYjBQsLNBIUGA0kiBO1AYhABKE7hEU X-IronPort-AV: E=Sophos;i="4.69,394,1315195200"; d="scan'208";a="144006702" Received: from 76-10-162-206.dsl.teksavvy.com (HELO pastel.home) ([76.10.162.206]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 23 Oct 2011 13:59:14 -0400 Received: by pastel.home (Postfix, from userid 20848) id 7437358B4A; Sun, 23 Oct 2011 13:59:14 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Message-ID: References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> <87fwilkqck.fsf@mail.jurta.org> Date: Sun, 23 Oct 2011 13:59:14 -0400 In-Reply-To: <87fwilkqck.fsf@mail.jurta.org> (Juri Linkov's message of "Sat, 22 Oct 2011 18:35:47 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9820 Cc: Jambunathan K , 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > After moving this message to modify-file-local-variable, > checking for new value against the old value really makes less sense > because it's unclear what to do for the `delete' operations, > so I removed this check below. I think it's important to silence the message when we can know that it's not useful (i.e. the variable already has the right value). For `delete', we can test local-variable-p. BTW, I think the message is not yet as good as it should be. E.g. we could either tell the exact command that needs to be used (e.g. M-x revert-buffer), or go the other way and only point out the current situation without indicating how to "fix" it, something like "the change hasn't yet taken effect". Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 15 19:39:30 2013 Received: (at 9820) by debbugs.gnu.org; 15 Jun 2013 23:39:31 +0000 Received: from localhost ([127.0.0.1]:47039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo04A-0003Cu-40 for submit@debbugs.gnu.org; Sat, 15 Jun 2013 19:39:30 -0400 Received: from ps18281.dreamhost.com ([69.163.218.105]:58070 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo046-0003Ch-HJ for 9820@debbugs.gnu.org; Sat, 15 Jun 2013 19:39:28 -0400 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 45447258B9E915; Sat, 15 Jun 2013 16:39:24 -0700 (PDT) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Organization: JURTA References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> <87fwilkqck.fsf@mail.jurta.org> Date: Sun, 16 Jun 2013 01:58:07 +0300 In-Reply-To: (Stefan Monnier's message of "Sun, 23 Oct 2011 13:59:14 -0400") Message-ID: <87ip1fx8sw.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 9820 Cc: Jambunathan K , 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is an old request that I'd like to close now, one way or another. > BTW, I think the message is not yet as good as it should be. E.g. we > could either tell the exact command that needs to be used (e.g. M-x > revert-buffer), or go the other way and only point out the current > situation without indicating how to "fix" it, something like "the change > hasn't yet taken effect". In a similar situation, Dired displays this message: (message "%s" (substitute-command-keys "Directory has changed on disk; type \\[revert-buffer] to update Dired")) So for `add-file-local-variable' it could be: (message "%s" (substitute-command-keys "For this change to take effect revisit file using \\[revert-buffer]")) The following patch displays this message. === modified file 'lisp/files-x.el' --- lisp/files-x.el 2013-06-15 22:44:38 +0000 +++ lisp/files-x.el 2013-06-15 22:57:03 +0000 @@ -115,7 +115,7 @@ (defun read-file-local-variable-mode () ((and (stringp mode) (fboundp (intern mode))) (intern mode)) (t mode)))) -(defun modify-file-local-variable (variable value op) +(defun modify-file-local-variable (variable value op &optional interactive) "Modify file-local VARIABLE in Local Variables depending on operation OP. If OP is `add-or-replace' then delete all existing settings of @@ -198,10 +198,17 @@ (defun modify-file-local-variable (varia ((eq variable 'mode) (goto-char beg)) ((null replaced-pos) (goto-char end)) (replaced-pos (goto-char replaced-pos))) - (insert (format "%s%S: %S%s\n" prefix variable value suffix))))))) + (insert (format "%s%S: %S%s\n" prefix variable value suffix))) + + (when (and interactive + (not (and (symbolp variable) + (boundp variable) + (equal (symbol-value variable) value)))) + (message "%s" (substitute-command-keys + "For this change to take effect revisit file using \\[revert-buffer]")))))))) ;;;###autoload -(defun add-file-local-variable (variable value) +(defun add-file-local-variable (variable value &optional interactive) "Add file-local VARIABLE with its VALUE to the Local Variables list. This command deletes all existing settings of VARIABLE (except `mode' @@ -213,17 +220,17 @@ (defun add-file-local-variable (variable `Local Variables:' and the last line containing the string `End:'." (interactive (let ((variable (read-file-local-variable "Add file-local variable"))) - (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable variable value 'add-or-replace)) + (list variable (read-file-local-variable-value variable) t))) + (modify-file-local-variable variable value 'add-or-replace interactive)) ;;;###autoload -(defun delete-file-local-variable (variable) +(defun delete-file-local-variable (variable &optional interactive) "Delete all settings of file-local VARIABLE from the Local Variables list." (interactive - (list (read-file-local-variable "Delete file-local variable"))) - (modify-file-local-variable variable nil 'delete)) + (list (read-file-local-variable "Delete file-local variable") t)) + (modify-file-local-variable variable nil 'delete interactive)) -(defun modify-file-local-variable-prop-line (variable value op) +(defun modify-file-local-variable-prop-line (variable value op &optional interactive) "Modify file-local VARIABLE in the -*- line depending on operation OP. If OP is `add-or-replace' then delete all existing settings of @@ -341,10 +348,17 @@ (defun modify-file-local-variable-prop-l (insert ";")) (unless (eq (char-before) ?\s) (insert " ")) (insert (format "%S: %S;" variable value)) - (unless (eq (char-after) ?\s) (insert " ")))))))) + (unless (eq (char-after) ?\s) (insert " ")))))) + + (when (and interactive + (not (and (symbolp variable) + (boundp variable) + (equal (symbol-value variable) value)))) + (message "%s" (substitute-command-keys + "For this change to take effect revisit file using \\[revert-buffer]"))))) ;;;###autoload -(defun add-file-local-variable-prop-line (variable value) +(defun add-file-local-variable-prop-line (variable value &optional interactive) "Add file-local VARIABLE with its VALUE to the -*- line. This command deletes all existing settings of VARIABLE (except `mode' @@ -355,15 +369,15 @@ (defun add-file-local-variable-prop-line then this function adds it." (interactive (let ((variable (read-file-local-variable "Add -*- file-local variable"))) - (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable-prop-line variable value 'add-or-replace)) + (list variable (read-file-local-variable-value variable) t))) + (modify-file-local-variable-prop-line variable value 'add-or-replace interactive)) ;;;###autoload -(defun delete-file-local-variable-prop-line (variable) +(defun delete-file-local-variable-prop-line (variable &optional interactive) "Delete all settings of file-local VARIABLE from the -*- line." (interactive - (list (read-file-local-variable "Delete -*- file-local variable"))) - (modify-file-local-variable-prop-line variable nil 'delete)) + (list (read-file-local-variable "Delete -*- file-local variable") t)) + (modify-file-local-variable-prop-line variable nil 'delete interactive)) (defvar auto-insert) ; from autoinsert.el From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 15 20:50:28 2013 Received: (at 9820) by debbugs.gnu.org; 16 Jun 2013 00:50:28 +0000 Received: from localhost ([127.0.0.1]:47141 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo1Aq-0006jO-Cj for submit@debbugs.gnu.org; Sat, 15 Jun 2013 20:50:28 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:9584) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo1An-0006ix-QQ for 9820@debbugs.gnu.org; Sat, 15 Jun 2013 20:50:26 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpZVy/2dsb2JhbABEvw4Xc4IfAQVWIxALNBIUGA0kiCTBLZEKA6R6gV6DEw X-IPAS-Result: Av4EABK/CFFFpZVy/2dsb2JhbABEvw4Xc4IfAQVWIxALNBIUGA0kiCTBLZEKA6R6gV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="16486529" Received: from 69-165-149-114.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.149.114]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 15 Jun 2013 20:50:14 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 7BCC9AE2E2; Sat, 15 Jun 2013 20:50:15 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Message-ID: References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> <87fwilkqck.fsf@mail.jurta.org> <87ip1fx8sw.fsf@mail.jurta.org> Date: Sat, 15 Jun 2013 20:50:15 -0400 In-Reply-To: <87ip1fx8sw.fsf@mail.jurta.org> (Juri Linkov's message of "Sun, 16 Jun 2013 01:58:07 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 9820 Cc: Jambunathan K , 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > - (insert (format "%s%S: %S%s\n" prefix variable value suffix))))))) > + (insert (format "%s%S: %S%s\n" prefix variable value suffix))) > + > + (when (and interactive > + (not (and (symbolp variable) > + (boundp variable) > + (equal (symbol-value variable) value)))) > + (message "%s" (substitute-command-keys > + "For this change to take effect revisit file using \\[revert-buffer]")))))))) Looks good, thanks. > - (unless (eq (char-after) ?\s) (insert " ")))))))) > + (unless (eq (char-after) ?\s) (insert " ")))))) > + > + (when (and interactive > + (not (and (symbolp variable) > + (boundp variable) > + (equal (symbol-value variable) value)))) > + (message "%s" (substitute-command-keys > + "For this change to take effect revisit file using \\[revert-buffer]"))))) But please eliminate this code duplication. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 17 18:39:20 2013 Received: (at 9820) by debbugs.gnu.org; 17 Jun 2013 22:39:20 +0000 Received: from localhost ([127.0.0.1]:51574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uoi51-0003Wt-3J for submit@debbugs.gnu.org; Mon, 17 Jun 2013 18:39:19 -0400 Received: from ps18281.dreamhost.com ([69.163.218.105]:34601 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uoi4x-0003Wh-Gd for 9820@debbugs.gnu.org; Mon, 17 Jun 2013 18:39:16 -0400 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 976AE258B9E915; Mon, 17 Jun 2013 15:39:13 -0700 (PDT) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Organization: JURTA References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> <87fwilkqck.fsf@mail.jurta.org> <87ip1fx8sw.fsf@mail.jurta.org> Date: Tue, 18 Jun 2013 01:35:50 +0300 In-Reply-To: (Stefan Monnier's message of "Sat, 15 Jun 2013 20:50:15 -0400") Message-ID: <87bo74pdq1.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 9820 Cc: Jambunathan K , 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) > But please eliminate this code duplication. Code duplication is eliminated by adding a new function `modify-file-local-variable-message' that now also performs more checks to decide when to display the message: === modified file 'lisp/files-x.el' --- lisp/files-x.el 2013-06-15 22:44:38 +0000 +++ lisp/files-x.el 2013-06-17 22:34:33 +0000 @@ -115,7 +115,38 @@ (defun read-file-local-variable-mode () ((and (stringp mode) (fboundp (intern mode))) (intern mode)) (t mode)))) -(defun modify-file-local-variable (variable value op) +(defun modify-file-local-variable-message (variable value op) + (let* ((not-value (make-symbol "")) + (old-value (cond ((eq variable 'mode) + major-mode) + ((eq variable 'coding) + buffer-file-coding-system) + (t (if (and (symbolp variable) + (boundp variable)) + (symbol-value variable) + not-value)))) + (new-value (if (eq op 'delete) + (cond ((eq variable 'mode) + (default-value 'major-mode)) + ((eq variable 'coding) + (default-value 'buffer-file-coding-system)) + (t (if (and (symbolp variable) + (default-boundp variable)) + (default-value variable) + not-value))) + (cond ((eq variable 'mode) + (let ((string (format "%S" value))) + (if (string-match-p "-mode\\'" string) + value + (intern (concat string "-mode"))))) + (t value))))) + (when (or (eq old-value not-value) + (eq new-value not-value) + (not (equal old-value new-value))) + (message "%s" (substitute-command-keys + "For this change to take effect revisit file using \\[revert-buffer]"))))) + +(defun modify-file-local-variable (variable value op &optional interactive) "Modify file-local VARIABLE in Local Variables depending on operation OP. If OP is `add-or-replace' then delete all existing settings of @@ -198,10 +229,13 @@ (defun modify-file-local-variable (varia ((eq variable 'mode) (goto-char beg)) ((null replaced-pos) (goto-char end)) (replaced-pos (goto-char replaced-pos))) - (insert (format "%s%S: %S%s\n" prefix variable value suffix))))))) + (insert (format "%s%S: %S%s\n" prefix variable value suffix)))) + + (when interactive + (modify-file-local-variable-message variable value op))))) ;;;###autoload -(defun add-file-local-variable (variable value) +(defun add-file-local-variable (variable value &optional interactive) "Add file-local VARIABLE with its VALUE to the Local Variables list. This command deletes all existing settings of VARIABLE (except `mode' @@ -213,17 +247,17 @@ (defun add-file-local-variable (variable `Local Variables:' and the last line containing the string `End:'." (interactive (let ((variable (read-file-local-variable "Add file-local variable"))) - (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable variable value 'add-or-replace)) + (list variable (read-file-local-variable-value variable) t))) + (modify-file-local-variable variable value 'add-or-replace interactive)) ;;;###autoload -(defun delete-file-local-variable (variable) +(defun delete-file-local-variable (variable &optional interactive) "Delete all settings of file-local VARIABLE from the Local Variables list." (interactive - (list (read-file-local-variable "Delete file-local variable"))) - (modify-file-local-variable variable nil 'delete)) + (list (read-file-local-variable "Delete file-local variable") t)) + (modify-file-local-variable variable nil 'delete interactive)) -(defun modify-file-local-variable-prop-line (variable value op) +(defun modify-file-local-variable-prop-line (variable value op &optional interactive) "Modify file-local VARIABLE in the -*- line depending on operation OP. If OP is `add-or-replace' then delete all existing settings of @@ -337,10 +371,13 @@ (defun modify-file-local-variable-prop-l (insert ";")) (unless (eq (char-before) ?\s) (insert " ")) (insert (format "%S: %S;" variable value)) - (unless (eq (char-after) ?\s) (insert " ")))))))) + (unless (eq (char-after) ?\s) (insert " "))))) + + (when interactive + (modify-file-local-variable-message variable value op))))) ;;;###autoload -(defun add-file-local-variable-prop-line (variable value) +(defun add-file-local-variable-prop-line (variable value &optional interactive) "Add file-local VARIABLE with its VALUE to the -*- line. This command deletes all existing settings of VARIABLE (except `mode' @@ -355,15 +394,15 @@ (defun add-file-local-variable-prop-line then this function adds it." (interactive (let ((variable (read-file-local-variable "Add -*- file-local variable"))) - (list variable (read-file-local-variable-value variable)))) - (modify-file-local-variable-prop-line variable value 'add-or-replace)) + (list variable (read-file-local-variable-value variable) t))) + (modify-file-local-variable-prop-line variable value 'add-or-replace interactive)) ;;;###autoload -(defun delete-file-local-variable-prop-line (variable) +(defun delete-file-local-variable-prop-line (variable &optional interactive) "Delete all settings of file-local VARIABLE from the -*- line." (interactive - (list (read-file-local-variable "Delete -*- file-local variable"))) - (modify-file-local-variable-prop-line variable nil 'delete)) + (list (read-file-local-variable "Delete -*- file-local variable") t)) + (modify-file-local-variable-prop-line variable nil 'delete interactive)) (defvar auto-insert) ; from autoinsert.el From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 17 20:53:51 2013 Received: (at 9820) by debbugs.gnu.org; 18 Jun 2013 00:53:51 +0000 Received: from localhost ([127.0.0.1]:51696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UokBC-0000TH-RM for submit@debbugs.gnu.org; Mon, 17 Jun 2013 20:53:51 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:11134) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UokB8-0000Sx-Sh for 9820@debbugs.gnu.org; Mon, 17 Jun 2013 20:53:47 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpZVy/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAs0EhQYDSSIHgbBLZEKA6R6gV6DEw X-IPAS-Result: Av4EABK/CFFFpZVy/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAs0EhQYDSSIHgbBLZEKA6R6gV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="16609268" Received: from 69-165-149-114.dsl.teksavvy.com (HELO pastel.home) ([69.165.149.114]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 17 Jun 2013 20:53:32 -0400 Received: by pastel.home (Postfix, from userid 20848) id 85E8162D01; Mon, 17 Jun 2013 20:53:31 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Message-ID: References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> <87fwilkqck.fsf@mail.jurta.org> <87ip1fx8sw.fsf@mail.jurta.org> <87bo74pdq1.fsf@mail.jurta.org> Date: Mon, 17 Jun 2013 20:53:31 -0400 In-Reply-To: <87bo74pdq1.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 18 Jun 2013 01:35:50 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 9820 Cc: Jambunathan K , 9820@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) >> But please eliminate this code duplication. > Code duplication is eliminated by adding a new function > `modify-file-local-variable-message' that now also performs > more checks to decide when to display the message: Great, thanks, Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 16:41:58 2013 Received: (at control) by debbugs.gnu.org; 18 Jun 2013 20:41:59 +0000 Received: from localhost ([127.0.0.1]:53907 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Up2j0-0001nL-FG for submit@debbugs.gnu.org; Tue, 18 Jun 2013 16:41:58 -0400 Received: from ps18281.dreamhost.com ([69.163.218.105]:54969 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Up2ix-0001nB-QQ for control@debbugs.gnu.org; Tue, 18 Jun 2013 16:41:56 -0400 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 59FB5258B9E915 for ; Tue, 18 Jun 2013 13:41:54 -0700 (PDT) From: Juri Linkov To: control@debbugs.gnu.org Subject: Re: bug#9820: 24.0.90; Behaviour of add-file-local-variable Organization: JURTA References: <8162jjj5dp.fsf@gmail.com> <87ehy61n79.fsf@mail.jurta.org> <8139el1v3i.fsf@gmail.com> <81vcrhzid5.fsf@gmail.com> <87fwilkqck.fsf@mail.jurta.org> <87ip1fx8sw.fsf@mail.jurta.org> <87bo74pdq1.fsf@mail.jurta.org> Date: Tue, 18 Jun 2013 23:41:14 +0300 In-Reply-To: (Stefan Monnier's message of "Mon, 17 Jun 2013 20:53:31 -0400") Message-ID: <87li67xic5.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) close 9820 24.3.50 thanks From unknown Sat Sep 13 17:18:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 17 Jul 2013 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator