* Ignore Local Variables list in source blocks
@ 2024-12-18 4:13 Joseph Turner
2024-12-18 17:16 ` Max Nikulin
0 siblings, 1 reply; 10+ messages in thread
From: Joseph Turner @ 2024-12-18 4:13 UTC (permalink / raw)
To: Org Mode Mailing List; +Cc: bohonghuang
Hello!
Is there a way to make Emacs ignore Local Variables lists which appear
inside of source blocks?
For example, is there a way to include the following content in an Org
file without Emacs attempting to locally set foo to bar?
#+BEGIN_EXAMPLE
# Local Variables:
# foo: 'bar
# End:
#+END_EXAMPLE
This issue first came up in org-srs:
https://github.com/bohonghuang/org-srs/issues/7
Thank you,
Joseph
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-18 4:13 Ignore Local Variables list in source blocks Joseph Turner
@ 2024-12-18 17:16 ` Max Nikulin
2024-12-19 21:37 ` Joseph Turner via General discussions about Org-mode.
0 siblings, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2024-12-18 17:16 UTC (permalink / raw)
To: Joseph Turner, emacs-orgmode; +Cc: bohonghuang
On 18/12/2024 11:13, Joseph Turner wrote:
>
> Is there a way to make Emacs ignore Local Variables lists which appear
> inside of source blocks?
>
> For example, is there a way to include the following content in an Org
> file without Emacs attempting to locally set foo to bar?
>
> #+BEGIN_EXAMPLE
> # Local Variables:
> # foo: 'bar
> # End:
> #+END_EXAMPLE
Have you tried to create a comment block below?
#+begin_comment
Deactivate local variables above in the example block:
Local Variables:
End:
#+end_comment
If it is not enough (and breaking the example into 2 parts is not
acceptable) then ask Emacs developers. I do not think, Org should (and
has a chance) to deal with this feature
(info "(emacs) Specifying File Variables")
<https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-18 17:16 ` Max Nikulin
@ 2024-12-19 21:37 ` Joseph Turner via General discussions about Org-mode.
2024-12-20 14:46 ` Max Nikulin
2024-12-20 15:37 ` Copy info node name (was: Re: Ignore Local Variables list in source blocks) Max Nikulin
0 siblings, 2 replies; 10+ messages in thread
From: Joseph Turner via General discussions about Org-mode. @ 2024-12-19 21:37 UTC (permalink / raw)
To: emacs-orgmode; +Cc: bohonghuang, Max Nikulin
Max Nikulin <manikulin@gmail.com> writes:
> On 18/12/2024 11:13, Joseph Turner wrote:
>> Is there a way to make Emacs ignore Local Variables lists which
>> appear
>> inside of source blocks?
>> For example, is there a way to include the following content in an
>> Org
>> file without Emacs attempting to locally set foo to bar?
>> #+BEGIN_EXAMPLE
>> # Local Variables:
>> # foo: 'bar
>> # End:
>> #+END_EXAMPLE
>
> Have you tried to create a comment block below?
>
> #+begin_comment
> Deactivate local variables above in the example block:
> Local Variables:
> End:
> #+end_comment
In my testing, in order to make Emacs ignore the `foo: bar' binding, the
empty Local Variables list actually needs to go first.
> If it is not enough (and breaking the example into 2 parts is not
> acceptable) then ask Emacs developers. I do not think, Org should (and
> has a chance) to deal with this feature
Yes, I agree that Org should not deal with this feature.
Splitting the example into two parts results in "File mode specification
error: (user-error Local variables entry is missing the prefix) " upon
opening the file. You can test with this:
--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC org
# Local Variables:
#+END_SRC
#+BEGIN_SRC org
# org-srs-review-new-items-per-day: 30
# org-srs-review-max-reviews-per-day: 100
# End:
#+END_SRC
--8<---------------cut here---------------end--------------->8---
> (info "(emacs) Specifying File Variables")
By the way, is there a built-in command to copy that (info ...) sexp
when viewing that info page?
> <https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html>
Thanks, I just re-read that page more carefully, and I see this:
If some unrelated text might look to Emacs as a local variables
list, you can countermand that by inserting a form-feed character (a
page delimiter, *note Pages::) after that text. Emacs only looks for
file-local variables in the last page of a file, after the last page
delimiter.
In the org-srs README.org, I think we can just throw a \f at the bottom
of the file (or before a Local Variables list which we do want to use).
Problem solved! Thank you, Max!
Joseph
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-19 21:37 ` Joseph Turner via General discussions about Org-mode.
@ 2024-12-20 14:46 ` Max Nikulin
2024-12-20 14:53 ` Nikolaos Chatzikonstantinou
2024-12-21 2:11 ` Joseph Turner
2024-12-20 15:37 ` Copy info node name (was: Re: Ignore Local Variables list in source blocks) Max Nikulin
1 sibling, 2 replies; 10+ messages in thread
From: Max Nikulin @ 2024-12-20 14:46 UTC (permalink / raw)
To: Joseph Turner, emacs-orgmode; +Cc: bohonghuang
On 20/12/2024 04:37, Joseph Turner wrote:
> Max Nikulin writes:
>> Have you tried to create a comment block below?
>>
>> #+begin_comment
>> Deactivate local variables above in the example block:
>> Local Variables:
>> End:
>> #+end_comment
>
> In my testing, in order to make Emacs ignore the `foo: bar' binding, the
> empty Local Variables list actually needs to go first.
Then it is more fragile in the case of complex documents, but still may
be viable for simple ones with single example.
> Splitting the example into two parts results in "File mode specification
> error: (user-error Local variables entry is missing the prefix) " upon
> opening the file.
I expected that the code looking up for local variables is reasonably shy.
> You can test with this:
> #+BEGIN_SRC org
> # Local Variables:
> #+END_SRC
>
> #+BEGIN_SRC org
> # org-srs-review-new-items-per-day: 30
> # org-srs-review-max-reviews-per-day: 100
> # End:
> #+END_SRC
Unfortunately
: # Local Variables:
#+BEGIN_EXAMPLE
# org-srs-review-new-items-per-day: 30
# org-srs-review-max-reviews-per-day: 100
# End:
#+END_EXAMPLE
Causes a warning as well:
"Local variables list is not properly terminated"
>> (info "(emacs) Specifying File Variables")
>
> By the way, is there a built-in command to copy that (info ...) sexp
> when viewing that info page?
A short answer "C-0 c" or "C-0 w". Maybe I will send a longer one,
dropping bohonghuang from Cc.
>> <https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html>
>
> Thanks, I just re-read that page more carefully, and I see this:
>
> If some unrelated text might look to Emacs as a local variables
> list, you can countermand that by inserting a form-feed character (a
> page delimiter, *note Pages::) after that text. Emacs only looks for
> file-local variables in the last page of a file, after the last page
> delimiter.
I do not like non-printable characters. E.g. Thunderbird rendered your
message with confusingly large vertical space in the middle. Outside of
Emacs, kludges like ";;; org.el ends here" are not common. I would not
be surprised by some issues on attempt to edit the README.org file on
the GitHub site directly.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-20 14:46 ` Max Nikulin
@ 2024-12-20 14:53 ` Nikolaos Chatzikonstantinou
2024-12-21 2:13 ` Joseph Turner
2024-12-21 2:13 ` Joseph Turner
2024-12-21 2:11 ` Joseph Turner
1 sibling, 2 replies; 10+ messages in thread
From: Nikolaos Chatzikonstantinou @ 2024-12-20 14:53 UTC (permalink / raw)
To: Joseph Turner, emacs-orgmode, bohonghuang
On Fri, Dec 20, 2024 at 9:46 AM Max Nikulin <manikulin@gmail.com> wrote:
>
> On 20/12/2024 04:37, Joseph Turner wrote:
> > Max Nikulin writes:
> >> Have you tried to create a comment block below?
> >>
> >> #+begin_comment
> >> Deactivate local variables above in the example block:
> >> Local Variables:
> >> End:
> >> #+end_comment
> >
> > In my testing, in order to make Emacs ignore the `foo: bar' binding, the
> > empty Local Variables list actually needs to go first.
>
> Then it is more fragile in the case of complex documents, but still may
> be viable for simple ones with single example.
>
> > Splitting the example into two parts results in "File mode specification
> > error: (user-error Local variables entry is missing the prefix) " upon
> > opening the file.
>
> I expected that the code looking up for local variables is reasonably shy.
>
> > You can test with this:
> > #+BEGIN_SRC org
> > # Local Variables:
> > #+END_SRC
> >
> > #+BEGIN_SRC org
> > # org-srs-review-new-items-per-day: 30
> > # org-srs-review-max-reviews-per-day: 100
> > # End:
> > #+END_SRC
>
> Unfortunately
>
> : # Local Variables:
> #+BEGIN_EXAMPLE
> # org-srs-review-new-items-per-day: 30
> # org-srs-review-max-reviews-per-day: 100
> # End:
> #+END_EXAMPLE
>
> Causes a warning as well:
> "Local variables list is not properly terminated"
>
> >> (info "(emacs) Specifying File Variables")
> >
> > By the way, is there a built-in command to copy that (info ...) sexp
> > when viewing that info page?
>
> A short answer "C-0 c" or "C-0 w". Maybe I will send a longer one,
> dropping bohonghuang from Cc.
>
> >> <https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html>
> >
> > Thanks, I just re-read that page more carefully, and I see this:
> >
> > If some unrelated text might look to Emacs as a local variables
> > list, you can countermand that by inserting a form-feed character (a
> > page delimiter, *note Pages::) after that text. Emacs only looks for
> > file-local variables in the last page of a file, after the last page
> > delimiter.
>
> I do not like non-printable characters. E.g. Thunderbird rendered your
> message with confusingly large vertical space in the middle. Outside of
> Emacs, kludges like ";;; org.el ends here" are not common. I would not
> be surprised by some issues on attempt to edit the README.org file on
> the GitHub site directly.
If I do something like
#+begin_comment
Local Variables:
End:
#+end_comment
#+begin_src
Local Variables:
foo: 40
End:
#+end_src
Then the variable is not set, as Emacs does not look for a Local
Variables list more than once.
Regards,
Nikolaos Chatzikonstantinou
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-20 14:53 ` Nikolaos Chatzikonstantinou
@ 2024-12-21 2:13 ` Joseph Turner
2024-12-21 2:13 ` Joseph Turner
1 sibling, 0 replies; 10+ messages in thread
From: Joseph Turner @ 2024-12-21 2:13 UTC (permalink / raw)
To: Nikolaos Chatzikonstantinou; +Cc: emacs-orgmode, bohonghuang
Nikolaos Chatzikonstantinou <nchatz314@gmail.com> writes:
[...]
> If I do something like
>
> #+begin_comment
> Local Variables:
> End:
> #+end_comment
>
> #+begin_src
> Local Variables:
> foo: 40
> End:
> #+end_src
>
> Then the variable is not set, as Emacs does not look for a Local
> Variables list more than once.
Thanks! This approach is a bit fragile, though since Emacs only looks
at the last 3000 characters for "Local Variables:".
Joseph
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-20 14:53 ` Nikolaos Chatzikonstantinou
2024-12-21 2:13 ` Joseph Turner
@ 2024-12-21 2:13 ` Joseph Turner
1 sibling, 0 replies; 10+ messages in thread
From: Joseph Turner @ 2024-12-21 2:13 UTC (permalink / raw)
To: Nikolaos Chatzikonstantinou; +Cc: emacs-orgmode, bohonghuang
Nikolaos Chatzikonstantinou <nchatz314@gmail.com> writes:
[...]
> If I do something like
>
> #+begin_comment
> Local Variables:
> End:
> #+end_comment
>
> #+begin_src
> Local Variables:
> foo: 40
> End:
> #+end_src
>
> Then the variable is not set, as Emacs does not look for a Local
> Variables list more than once.
Thanks! This approach is a bit fragile, since Emacs only looks at the
last 3000 characters for "Local Variables:".
Joseph
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Ignore Local Variables list in source blocks
2024-12-20 14:46 ` Max Nikulin
2024-12-20 14:53 ` Nikolaos Chatzikonstantinou
@ 2024-12-21 2:11 ` Joseph Turner
1 sibling, 0 replies; 10+ messages in thread
From: Joseph Turner @ 2024-12-21 2:11 UTC (permalink / raw)
To: emacs-orgmode; +Cc: bohonghuang
Max Nikulin <manikulin@gmail.com> writes:
[...]
>>> (info "(emacs) Specifying File Variables")
>> By the way, is there a built-in command to copy that (info ...) sexp
>> when viewing that info page?
>
> A short answer "C-0 c" or "C-0 w". Maybe I will send a longer one,
> dropping bohonghuang from Cc.
Thanks! Very good to know about!
>>> <https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html>
>> Thanks, I just re-read that page more carefully, and I see this:
>> If some unrelated text might look to Emacs as a local variables
>> list, you can countermand that by inserting a form-feed character (a
>> page delimiter, *note Pages::) after that text. Emacs only looks for
>> file-local variables in the last page of a file, after the last page
>> delimiter.
>
> I do not like non-printable characters. E.g. Thunderbird rendered your
> message with confusingly large vertical space in the middle. Outside
> of Emacs, kludges like ";;; org.el ends here" are not common. I would
> not be surprised by some issues on attempt to edit the README.org file
> on the GitHub site directly.
Also good to know about.
Thanks!
Joseph
^ permalink raw reply [flat|nested] 10+ messages in thread
* Copy info node name (was: Re: Ignore Local Variables list in source blocks)
2024-12-19 21:37 ` Joseph Turner via General discussions about Org-mode.
2024-12-20 14:46 ` Max Nikulin
@ 2024-12-20 15:37 ` Max Nikulin
1 sibling, 0 replies; 10+ messages in thread
From: Max Nikulin @ 2024-12-20 15:37 UTC (permalink / raw)
To: Joseph Turner, emacs-orgmode; +Cc: rms
Due to a recent texinfo thread on emacs-devel, I have added RMS to Cc.
On 20/12/2024 04:37, Joseph Turner wrote:
> Max Nikulin writes:
>> (info "(emacs) Specifying File Variables")
> By the way, is there a built-in command to copy that (info ...) sexp
> when viewing that info page?
TLDR;
"C-0 c" or "C-0 w"
Actually to get the reference above I copied and edited the file part of
the HTTP URL
>> <https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html>
Autocompletion from browsing history in address bar is a rather
convenient feature to quickly open some document visited earlier.
Unfortunately HTML page metadata does not contain manual and node names,
so a browser extension that copies info references, while possible,
would not be reliable. (I have noticed that HTML links may have extra
data-manual="elisp" attributes without data-node conterpart.)
Back to Emacs, `org-store-link' allows to save an info link for
insertion into an Org mode document.
However I am unaware of any command that allows to create a more precise
reference. Enough nodes have index anchors and it may be more convenient:
<https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-_005f>
An issue with Org links to index anchors that they can not be easily
exported to html_node variant of the texinfo document, especially if the
manual is not installed on the machine. (E.g. sphinx puts
machine-readable index of sections and anchors along with HTML files.)
Earlier I have not tries to find if it is possible to copy info node
name as *a command*. Actually neither (info "(info)"), nor (info
"(info-stnd"), nor (info "(emacs)") describe how to copy current node
name, so the feature is a part of hidden UI. I still had an impression
that I have seen a keybinding somewhere. This time I found it in "C-h m"
list, it is present in "?" info help as well (of course, without details
related to sexp).
The final step is the docstring for the "c" and "w" key bindings.
`Info-copy-current-node-name'
An advantage of the
(info "(emacs) Specifying File Variables")
form is that it usually can be used to open specific part of the
document in a standalone info browser. (Eli believes they are dead.)
Another feature I missed in info browsers is equivalent of browser "copy
link" context menu option for links. It is handy to copy link for notes
without leaving the current document.
I am not surprised that people use any option (HTTP URL, etc.), but not
"(emacs) Specifying File Variables" form (or some dedicated URL scheme).
The feature is hidden (and incompatible with yelp and khelpcenter).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Ignore Local Variables list in source blocks
@ 2024-12-18 4:12 Joseph Turner
0 siblings, 0 replies; 10+ messages in thread
From: Joseph Turner @ 2024-12-18 4:12 UTC (permalink / raw)
To: Org Mode Mailing List
Hello!
Is there a way to make Emacs ignore Local Variables lists which appear
inside of source blocks?
For example, is there a way to include the following content in an Org
file without Emacs attempting to locally set foo to bar?
#+BEGIN_EXAMPLE
# Local Variables:
# foo: 'bar
# End:
#+END_EXAMPLE
This issue first came up in org-srs:
https://github.com/bohonghuang/org-srs/issues/7
Thank you,
Joseph
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-12-21 2:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-18 4:13 Ignore Local Variables list in source blocks Joseph Turner
2024-12-18 17:16 ` Max Nikulin
2024-12-19 21:37 ` Joseph Turner via General discussions about Org-mode.
2024-12-20 14:46 ` Max Nikulin
2024-12-20 14:53 ` Nikolaos Chatzikonstantinou
2024-12-21 2:13 ` Joseph Turner
2024-12-21 2:13 ` Joseph Turner
2024-12-21 2:11 ` Joseph Turner
2024-12-20 15:37 ` Copy info node name (was: Re: Ignore Local Variables list in source blocks) Max Nikulin
-- strict thread matches above, loose matches on Subject: below --
2024-12-18 4:12 Ignore Local Variables list in source blocks Joseph Turner
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).