emacs-devel
[Top][All Lists]
Advanced

[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: Lynn Winebarger
Subject: Re: [elpa] externals/org 26ef5e3e5b: org-src: Use `sh-mode' for all the shells it can handle
Date: Mon, 17 Apr 2023 12:16:36 -0400

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>


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.

Lynn


reply via email to

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