From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Kitchin Newsgroups: gmane.emacs.bugs Subject: bug#24452: 25.1.50; add/delete-file-local-variable does not work as expected Date: Mon, 19 Sep 2016 08:57:07 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1474291081 26436 195.159.176.226 (19 Sep 2016 13:18:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Sep 2016 13:18:01 +0000 (UTC) User-Agent: mu4e 0.9.16; emacs 25.1.50.1 Cc: 24452@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 19 15:17:53 2016 Return-path: Envelope-to: geb-bug-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 1blyRk-0002cv-9k for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Sep 2016 15:17:20 +0200 Original-Received: from localhost ([::1]:55336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blyRi-0006Xq-Hd for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Sep 2016 09:17:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bly99-0007r5-2K for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2016 08:58:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bly94-0003nV-TL for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2016 08:58:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bly94-0003nN-QN for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2016 08:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bly94-000176-Ek for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2016 08:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: John Kitchin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Sep 2016 12:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24452 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24452-submit@debbugs.gnu.org id=B24452.14742898384228 (code B ref 24452); Mon, 19 Sep 2016 12:58:02 +0000 Original-Received: (at 24452) by debbugs.gnu.org; 19 Sep 2016 12:57:18 +0000 Original-Received: from localhost ([127.0.0.1]:34878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bly8M-000168-Ay for submit@debbugs.gnu.org; Mon, 19 Sep 2016 08:57:18 -0400 Original-Received: from mail-qt0-f170.google.com ([209.85.216.170]:33620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bly8K-00015u-0Y for 24452@debbugs.gnu.org; Mon, 19 Sep 2016 08:57:16 -0400 Original-Received: by mail-qt0-f170.google.com with SMTP id 11so70986099qtc.0 for <24452@debbugs.gnu.org>; Mon, 19 Sep 2016 05:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=QXASSrYoh8+9hnRw6FTVgu4Siq7Abtz8cFWaB84+8jk=; b=V7shPLNMaPd1BEMhZ7mP6nV/GuJq5esFf+F/7j+vVXVWf4PNuxWvP9otRW9Y8daFjt tQW+ZMdJxmD7P9DsYRu00MfsgboeI4LDvce0B4dq01qHtLbDL11UGmpp6UgDiBYX+PwA XUxmHE3FmFXTlNDBxbfaaXWuWD2uxTCwE8/o7U3r1n6guiJfo1IOpa9xFsTZqs7cxEOa TLbjahgrVxdpUiHMYvWgqbqeWOpIx4x6BpWKJ/SAuCZAdkQeDddXSw7ExT4ht7JQ/Fu8 94wowRIHJV3gWBRWB5vWxoNr0LmJaUiK88ygvhvukT3KMmWFr63CW3cksh/Rb+ad7Ove BV9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=QXASSrYoh8+9hnRw6FTVgu4Siq7Abtz8cFWaB84+8jk=; b=Dq66QIqLdHs5nJJQFsOiIdSxw9MtwGf2wobwx0xF1ixWCNDszyM2okODPPzPvbHMMI wP9UQpxeo63rAODawg6Ot5wjZOA6dMniHf9VosaH3LsmdyMAZncpMmMqndqZ9bFS1GVv Vr62cYLnz3M4ADOsEr6sGZAl+KAfBPyWtoOhVPmGzZKDogbv81OFh/Sf5YAjylTXh/SW cPv3fBsq6nkpP+dPikTZ/kH0j0y26SQfuveJawFODqGfabf5T4OegUDp/CGyAh+vQiRQ WyMMNrRnQhcNZGPYkCHivdvOZdpH+DFcLMAoTxWddr7ztj77AAcLCvl4yJIgD1TbqoYS Nalw== X-Gm-Message-State: AE9vXwN/Ydl01ivxjete4xDXHD4HkhnHsnImThRkBBnPLtyJ7/TplFll9b+CVJGRs9NIsQ== X-Received: by 10.200.47.89 with SMTP id k25mr29490694qta.75.1474289830284; Mon, 19 Sep 2016 05:57:10 -0700 (PDT) Original-Received: from johns-air.wv.cc.cmu.edu (Johns-Air.wv.cc.cmu.edu. [128.237.182.185]) by smtp.gmail.com with ESMTPSA id t64sm12903210qke.5.2016.09.19.05.57.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Sep 2016 05:57:08 -0700 (PDT) In-reply-to: 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:123439 Archived-At: Thanks for the reply. Those are some good points I hadn't considered. Glenn Morris writes: > John Kitchin wrote: > >> In the add-file-local-variable and related functions, the local >> variables are found with code like: >> See remarks below to explain these lines: (search-forward "Local Variables:" nil t) (search-forward "foo: bar" nil t) (search-forward "End:" nil t) > > It uses the same logic as the function that actually applies file local > variables (hack-local-variables). > >> This is too open I think, and leads to errors in files that contain that >> phrase in places near the end of the file that aren't related to Local >> Variables. For example, in code that is searching for that string, or in >> text files that talk about Local Variables. > > Then you would already have had a more obvious issue when visiting the > file in the first place. It doesn't seem to cause any issues when visiting the file. It does cause an issue when adding file local variables though without ^L or obfuscation as you note below. For example, in this email I added a local var foo with value bar, and it added the two extra search-forward lines above. I guess this is known, expected behavior at this point. > The format of Local Variables is too > long-established to be changed now, and there's no point > add-file-local-variable being stricter than hack-local-variables. I didn't mean to suggest changing the format (I can see though that my original suggestion suggested that). It seems it isn't too easy to make it more strict given the broad range of situations where there are or aren't comment syntax and where it is or isn't needed. > The standard solution is eg to add a ^L, or obfuscate the "Local > Variables", so it's not picked up. This is a good tip that does resolve the issue for me. Thanks! > >> I think the search should be done with a regexp that considers the start >> of a line and comment-start: >> >> (format "^%s+ Local Variables:" comment-start) > > Some files have no comment syntax. In some that do, there's no need for > the LV section to use it (eg it could be after the "end{document}" in a > latex file, or inside #if 0 in C). And then there's the case where > comment-start is itself specified in the LV section. It looks like this bug report is closeable. Thanks again for the clarifications. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu