From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: enable-local-variables and emacs --batch Date: Sat, 03 Nov 2018 11:16:54 +0200 Message-ID: <83a7mqfrll.fsf@gnu.org> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1541236534 9829 195.159.176.226 (3 Nov 2018 09:15:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2018 09:15:34 +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 Nov 03 10:15:30 2018 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 1gIs1h-0002TO-Ui for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Nov 2018 10:15:30 +0100 Original-Received: from localhost ([::1]:54867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIs3o-0000Sj-89 for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Nov 2018 05:17:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIs3I-0000Rc-Pw for help-gnu-emacs@gnu.org; Sat, 03 Nov 2018 05:17:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIs3E-0003qy-Uk for help-gnu-emacs@gnu.org; Sat, 03 Nov 2018 05:17:08 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIs3E-0003pr-MJ for help-gnu-emacs@gnu.org; Sat, 03 Nov 2018 05:17:04 -0400 Original-Received: from [176.228.60.248] (port=4236 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gIs3E-0001Z2-7y for help-gnu-emacs@gnu.org; Sat, 03 Nov 2018 05:17:04 -0400 In-reply-to: (message from Kaushal Modi on Thu, 1 Nov 2018 10:54:02 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:118572 Archived-At: > From: Kaushal Modi > Date: Thu, 1 Nov 2018 10:54:02 -0400 > > I am unable to get the safe-marked variables to evaluate from > .dir-locals.el *only* when running emacs --batch. > > For example, I have the below evaluated in emacs --batch --eval before > I load an Org file: > > (put 'org-hugo-section 'safe-local-variable 'stringp) > > And this in .dir-locals.el: > > ((org-mode . ((org-hugo-section . "foo")))) > > But the org-hugo-section does not get set to "foo". > > If I open an Org file in the directory with that .dir-locals.el in a > non-batch regular Emacs session, C-h v org-hugo-section shows that > it's set to "foo", and I get no prompts to apply/save that local > variable (as expected because I have marked it as > safe-local-variable). > > So the only way I can make the .dir-locals.el apply that value is if I > do (setq enable-local-variables :all) when running emacs --batch. > > But I don't consider that safe. > > Why isn't the 'safe-local-variable attribute ignored only when running > emacs --batch? You didn't show any actual command you are using for the batch-mode invocation, but my first guess would be that the file is visited before the --eval command-line option is executed.