From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel 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 Message-ID: References: <168174708495.14139.12756054653439048176@vcs2.savannah.gnu.org> <20230417155805.3E200C1391A@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000009a73ad05f98a8474" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21285"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Matthew Trzcinski , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 17 18:17:52 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1poRY8-0005JD-Jn for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Apr 2023 18:17:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poRXE-0001SN-PJ; Mon, 17 Apr 2023 12:16:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1poRXA-0001S3-Ph for emacs-devel@gnu.org; Mon, 17 Apr 2023 12:16:54 -0400 Original-Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poRX8-0004aG-L6 for emacs-devel@gnu.org; Mon, 17 Apr 2023 12:16:52 -0400 Original-Received: by mail-pj1-x102d.google.com with SMTP id hg12so11640129pjb.2 for ; Mon, 17 Apr 2023 09:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681748209; x=1684340209; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dx7HpuJj11MN93od8HtLfC8Yai4z5vTivCqvKNS5YGc=; b=Tiks8dMscA0Iq/5tUTaUxzxE6hhZkQHoYKLTlU01FNxd6GTsVEcqrksIXa+GDPnwBc ogayJW7HGHoeyZj2gjIOJSQIWqrcCqFKLsGxCTjGSfXK9PzuCjOP3dYHQfCj7StCvns6 UtPEp3x6nYZGR0MIVceS9UlzO+XnZZEQlsM4N4uQ09KCYf70/fxJxgoyDmnGLqSE0SFU E+C2rX1OYS947dVP2SOujeBLah2vNwXjIlSFFbbUkDPEQeu1vgzUc29npE4sRaeDsByP 7VW/1uFD0QhBvDNZdjudpN5abgu/87XhgpWYySarlO75YIP8hFQMgLgIWciA93zzHCsu MMgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681748209; x=1684340209; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dx7HpuJj11MN93od8HtLfC8Yai4z5vTivCqvKNS5YGc=; b=N9DzVjZpycSErqtxqXIkPhOVCH/J53nvfZXQ/dAp92K9O/+sY44MvA0fhCrd+vUqta uE994C/X++uUvrL+E6roKrqbRCcqy0vcLWA6B6zpkQprTdcNeYheTo21iGiiNpJFUiBD C41gID2o5gzYB9ZNb4XYwCtByC1zE4RtMXeSFERPNQHu59duffxg32LXVsORTBVTXkZw 3w6VZLVeK/tpQF74ba/+YFXcW5EptoRt0XPgISb6fZSnuNOhtLdm88G/UBCY3JGzY7XP VmLdltZAyoPs7nI4S5OalrNPga40/uETSoNv3cC/2oOGb0xnzTSx3Pini10cPQc0dZVq GOpA== X-Gm-Message-State: AAQBX9f8lAkEpRN+2xlyUejRT1k0zOF8QaD3reSWmHro0d5RUn9gE1pn ny+IBkF5CwM51srti1cVvetw82V6nIHOWvcfjjA= X-Google-Smtp-Source: AKy350aQv/Gd37k3PjXxsPaRu7hGhQu5wKypjD2fCjmmxUjAY+fzknRI3nVNt720lcVDovXlx8bcl8k1eNkRxGyzoo4= X-Received: by 2002:a17:90a:7522:b0:246:9675:99b9 with SMTP id q31-20020a17090a752200b00246967599b9mr4188826pjk.8.1681748209069; Mon, 17 Apr 2023 09:16:49 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=owinebar@gmail.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305368 Archived-At: --0000000000009a73ad05f98a8474 Content-Type: text/plain; charset="UTF-8" On Mon, Apr 17, 2023, 12:10 PM Stefan Monnier 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 --0000000000009a73ad05f98a8474 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Apr 17, 2023, 12:10 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
=
>=C2=A0 (defcustom org-src-lang-mod= es
> -=C2=A0 '(("C" . c)
> +=C2=A0 `(("C" . c)
>=C2=A0 =C2=A0 =C2=A0 ("C++" . c++)
>=C2=A0 =C2=A0 =C2=A0 ("asymptote" . asy)
> -=C2=A0 =C2=A0 ("bash" . sh)
>=C2=A0 =C2=A0 =C2=A0 ("beamer" . latex)
>=C2=A0 =C2=A0 =C2=A0 ("calc" . fundamental)
>=C2=A0 =C2=A0 =C2=A0 ("cpp" . c++)
> @@ -208,9 +215,10 @@ but which mess up the display of a snippet in Org= exported files.")
>=C2=A0 =C2=A0 =C2=A0 ("elisp" . emacs-lisp)
>=C2=A0 =C2=A0 =C2=A0 ("ocaml" . tuareg)
>=C2=A0 =C2=A0 =C2=A0 ("screen" . shell-script)
> -=C2=A0 =C2=A0 ("shell" . sh)
>=C2=A0 =C2=A0 =C2=A0 ("sqlite" . sql)
> -=C2=A0 =C2=A0 ("toml" . conf-toml))
> +=C2=A0 =C2=A0 ("toml" . conf-toml)
> +=C2=A0 =C2=A0 ("shell" . sh)
> +=C2=A0 =C2=A0 ,@(org-src--get-known-shells))
>=C2=A0 =C2=A0 "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.=C2=A0 Basically because it's mor= e
efficient to add to the beginning rather than to the end of a list:

=C2=A0 =C2=A0 ELISP> (macroexpand '`(,@(list 1 2) a b c d))
=C2=A0 =C2=A0 (append (list 1 2) '(a b c d))
=C2=A0 =C2=A0 ELISP> (macroexpand '`(a b c d ,@(list 1 2)))
=C2=A0 =C2=A0 (cons 'a (cons 'b (cons 'c (cons 'd (list 1 2= )))))
=C2=A0 =C2=A0 ELISP>

<= /div>

Why is the former more e= fficient than the latter?=C2=A0 It looks like the former would have to cons= truct the '(1 2) list twice, and the latter only once.=C2=A0 And the &#= 39;(a b c d) cons cells are only allocated once either way.

Lynn