help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enable-local-variables and emacs --batch


From: Kaushal Modi
Subject: Re: enable-local-variables and emacs --batch
Date: Sat, 3 Nov 2018 08:49:03 -0400

On Sat, Nov 3, 2018 at 7:21 AM Kaushal Modi <kaushal.modi@gmail.com> wrote:

> Now the challenge is edebugging in --batch mode.

I don't know how to edebug in --batch, but I tried to used messages,
to get confused even more.

I couldn't reproduce the issue in that minimal example, so just added
debug messages to my actual code.

Below is the debug output while the .org file is opened in emacs --batch.

Debug code:

=====
    (message "file: %S" (buffer-file-name))

    (message "enable-local-variables = %S" enable-local-variables)
    (message "org-hugo-section (safe-local-variable) = %S" (get
'org-hugo-section 'safe-local-variable))
    (if-let* ((valid-dir-locals-found (dir-locals-find-file (buffer-file-name)))
            (dir (if (listp valid-dir-locals-found)
                     (car valid-dir-locals-found)
                   valid-dir-locals-found)))
      (message ".dir-locals.el file: %s"
               (car
                (dir-locals--all-files dir))))

    (message "[ox-hugo section-path DBG] org-hugo-section: %S" org-hugo-section)
=====

Output:

=====
file: 
"/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content-org/dir-locals/dir-locals-test.org"
enable-local-variables = t
org-hugo-section (safe-local-variable) = stringp
.dir-locals.el file:
/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content-org/dir-locals/.dir-locals.el
[ox-hugo section-path DBG] org-hugo-section: "posts"
=====

Content in ..content-org/dir-locals/.dir-locals.el:

=====
((nil . ((indent-tabs-mode . nil)
         (fill-column . 70)
         (sentence-end-double-space . t)))
 (org-mode . ((mode . auto-fill)
              (org-hugo-section . "dir-locals-test")
              (org-hugo-front-matter-format . "yaml")
              (org-hugo-footer . "\n\nThis text is auto inserted at
the end of the exported Markdown.")
              (org-hugo-preserve-filling . nil)
              (org-hugo-use-code-for-kbd . t)
              (org-hugo-export-with-toc . t)
              (org-hugo-export-with-section-numbers . t)
              (org-hugo-export-creator-string . "Dummy creator string")
              (org-hugo-date-format . "%Y-%m-%d")
              (org-hugo-auto-export-on-save . t))))
=====


So my confusion ..:

1. Checked that enable-local-variables is t ("enable-local-variables =
t" in debug)
2. Checked that org-hugo-section is marked as safe if it's a string
("org-hugo-section (safe-local-variable) = stringp" in debug)
3. Checked that the correct .dir-locals.el file is applied
(".dir-locals.el file:
/home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/elisp/ox-hugo/test/site/content-org/dir-locals/.dir-locals.el"
in debug)
4. See that .dir-locals.el file above and the value of
org-hugo-section -> (org-hugo-section . "dir-locals-test") <- it is
"dir-locals-test" .. and it is a string!

But still the value read of `org-hugo-section' in that .org file
buffer is "posts"!! (in debug -> [ox-hugo section-path DBG]
org-hugo-section: "posts")

So this happens only in emacs --batch, not when I open that file
manually in a regular Emacs session.

Help?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]