emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Inheriting some local variables from source code block editing b


From: Göktuğ Kayaalp
Subject: Re: [O] Inheriting some local variables from source code block editing buffers
Date: Tue, 01 May 2018 06:30:33 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

On 2018-04-30 00:09 +02, Bastien <address@hidden> wrote:
> Hi Göktuğ,
>
> thanks for your patch.

You're welcome!

> Kayaalp <address@hidden> writes:
> Do you have other examples on local variables that would be useful to
> pass on when editing code in Org Src buffers?

Currently I only pass on lexical-binding and truncate-lines, and I do
not have another concrete example in my configuration (I do not use
source blocks for anything other than shell and elisp currently).  But I
have listed some hypothetical use cases further down.

> In general, instead of inheriting values from the Org's buffer, I'd
> allow users to set the values independantly -- for example, the cdr
> of elements in `org-babel-load-languages', instead of being `t' all
> the time (because nil makes no sense to me), could contain an alist
> of variables and their local values when editing and... executing.

This might be a better way indeed.  But this setting is then global,
i.e. one can't have the file A.org have lexical-binding on, but B.org
off (which might be necessary for say an older org file that depends on
lexical binding).

> This is: *if* we find cases that seem generic enough.
>
> What do you think?

One case I can think of is to set variables like fill-column when
editing inline LaTeX, HTML, &c blocks, and also, those like
c-file-style, where say when writing a paper the author wants to use k&r
style, but when writing a literate source prefers gnu style.

Maybe a good way to achieve this would be to have the way you suggest to
set defaults for Babel, but allow to define such bindings also in
individual org mode files, either via the local variables or with a
specific #+keyword like:

    #+edit_special_bindings: lexical-binding:t
    # or
    #+edit_special_bindings: c-file-style:gnu fill-column:80

which is better IMO because there is no need to declare separately which
variables to copy, and is more granular.  Also, in this case, a shortcut
syntax for inheriting the buffer local value of a variable can be
useful:

    ==== x.org ===
    # -*- fill-column: 65 -*-
    #+edit_special_bindings: c-file-style:gnu fill-column*

This can be useful when one needs/wants to keep a consistent style in a
given file.

-- 
İ. Göktuğ Kayaalp       <https://www.gkayaalp.com/>
                         024C 30DD 597D 142B 49AC
                         40EB 465C D949 B101 2427



reply via email to

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