[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the
From: |
Philip Kaludercic |
Subject: |
Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle |
Date: |
Mon, 17 Apr 2023 16:27:46 +0000 |
Lynn Winebarger <owinebar@gmail.com> writes:
> On Mon, Apr 17, 2023, 12:10 PM Stefan Monnier <monnier@iro.umontreal.ca>
> wrote:
>
>> > (defcustom org-src-lang-modes
>> > - '(("C" . c)
>> > + `(("C" . c)
>> > ("C++" . c++)
>> > ("asymptote" . asy)
>> > - ("bash" . sh)
>> > ("beamer" . latex)
>> > ("calc" . fundamental)
>> > ("cpp" . c++)
>> > @@ -208,9 +215,10 @@ but which mess up the display of a snippet in Org
>> exported files.")
>> > ("elisp" . emacs-lisp)
>> > ("ocaml" . tuareg)
>> > ("screen" . shell-script)
>> > - ("shell" . sh)
>> > ("sqlite" . sql)
>> > - ("toml" . conf-toml))
>> > + ("toml" . conf-toml)
>> > + ("shell" . sh)
>> > + ,@(org-src--get-known-shells))
>> > "Alist mapping languages to their major mode.
>>
>> Side note: while it really doesn't matter here for such trivial
>> top-level code, I prefer to put such ,@ at the beginning rather than the
>> end of lists, when it's an option. Basically because it's more
>> efficient to add to the beginning rather than to the end of a list:
>>
>> ELISP> (macroexpand '`(,@(list 1 2) a b c d))
>> (append (list 1 2) '(a b c d))
>> ELISP> (macroexpand '`(a b c d ,@(list 1 2)))
>> (cons 'a (cons 'b (cons 'c (cons 'd (list 1 2)))))
>> ELISP>
Is this just an implementation detail, or is there a reason that this
could not expand to
(append '(a b c d) (list 1 2))
> Why is the former more efficient than the latter? It looks like the former
> would have to construct the '(1 2) list twice, and the latter only once.
> And the '(a b c d) cons cells are only allocated once either way.
(I believe) It is more efficient, since there are fewer function calls.
I have had issues in the past with ,@ expanding to code that would have
exceeded the maximal evaluation depth, until I split it up and manually
used `append' that has the advantage of being implemented in C.
> Lynn
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Stefan Monnier, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Lynn Winebarger, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle,
Philip Kaludercic <=
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Mattias Engdegård, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Mattias Engdegård, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Stefan Monnier, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Mattias Engdegård, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Stefan Monnier, 2023/04/17
- Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Mattias Engdegård, 2023/04/18
Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle, Stefan Monnier, 2023/04/17