From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#66706: =?UTF-8?Q?[PATCH]=C2=A0Automatic?= elisp dialect insertion Date: Mon, 23 Oct 2023 19:46:14 +0200 Message-ID: <17C83052-7946-45DE-B660-DA7EB82001B0@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_D3432800-D637-4F59-A33C-6BB3EE9E184F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33377"; mail-complaints-to="usenet@ciao.gmane.io" To: 66706@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 23 19:48:02 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1quz21-0008UJ-DT for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Oct 2023 19:48:01 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quz1b-0002gW-Qb; Mon, 23 Oct 2023 13:47:35 -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 1quz1Z-0002gH-HT for bug-gnu-emacs@gnu.org; Mon, 23 Oct 2023 13:47:33 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quz1Z-0002pr-8f for bug-gnu-emacs@gnu.org; Mon, 23 Oct 2023 13:47:33 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quz22-00054F-2L for bug-gnu-emacs@gnu.org; Mon, 23 Oct 2023 13:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 Oct 2023 17:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66706 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bug Report Original-Received: via spool by submit@debbugs.gnu.org id=B.169808322319401 (code B ref -1); Mon, 23 Oct 2023 17:48:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Oct 2023 17:47:03 +0000 Original-Received: from localhost ([127.0.0.1]:51588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quz15-00052r-2a for submit@debbugs.gnu.org; Mon, 23 Oct 2023 13:47:03 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:41312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quz12-00052M-BB for submit@debbugs.gnu.org; Mon, 23 Oct 2023 13:47:02 -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 1quz0O-0002UF-Gq for bug-gnu-emacs@gnu.org; Mon, 23 Oct 2023 13:46:23 -0400 Original-Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quz0N-0002ii-1x for bug-gnu-emacs@gnu.org; Mon, 23 Oct 2023 13:46:20 -0400 Original-Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507a55302e0so4876880e87.0 for ; Mon, 23 Oct 2023 10:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698083175; x=1698687975; darn=gnu.org; h=to:date:message-id:subject:mime-version:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=fJPlknUZwkjyLeXn1X5uE19cZRyxWoauSdM8j03c+wY=; b=OFDRB9vB8eNGAOR9A59hJfDb54DGYxUsO1vqkN6ee9m0jheYLqBUYYrVGuPNOkwwo0 a5rSs0X8WoiysTb1NZYxw1RedfCc3UR9dRnLXdvyx+R3nS7w32GdIMKjIMAlGltjQzK0 KjZNUJGiJFXyhVkO28PumbP2DXb50M4l12Nb/FJQ56MzJiF7MjkmanqOXQU8lxU6swwr K66iBeLtuGlgn7cERCVTMOZnhDXcTeyvKrBb3EBh5sRZm4WDBCEDBZZ2L/y6NtrtrefE UDcfeT/XSZ8cr3S2wqTDdZcNFcD9CTXJlbLB55hi/DhcM4pgfXYrv3iapwbiKT1jbgeC 9FOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698083175; x=1698687975; h=to:date:message-id:subject:mime-version:from:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fJPlknUZwkjyLeXn1X5uE19cZRyxWoauSdM8j03c+wY=; b=aGUWvpeXQXLqC8yWc6cyKYEXGi4JF8M4b1DiaId9AzE+jxc67diS4AjdaE/m7AMkdd O1I34wJcY7/c8MQ9I5ZdsggUdyT0jRaBf2ZUMmQzMRlN8v/1isE0aqtOXz6RVkelpWfQ F6rVkJ8j6jVGPqoO2WpFajwwBQnPXHJyOvBc1WEJvSxXgYB9svaAEBL+/3ROWJ2zDzAd jzVkEzHu5FwDpeFiTjgkqkfb4MqanGP/t7dNdX8qB4nGthH/ddcS42y44WN3NYPWS36h KGU5wgcKy8bZijdg06XJTLHNlGX9xxOSWCoUU9gp6O85ug7wyCN3l4dj+0QpUM8+/0y/ SvRQ== X-Gm-Message-State: AOJu0YwYTaz7gzTqKbins96BhEn8QRZxcTuvVGJkkYXvzl8ABDfTuiVQ cmwk4Js/R7Wb6T9OU41M8Zlr7MxJ3U8EnA== X-Google-Smtp-Source: AGHT+IEIzyZeWGq0BihzJtGnTOIqrhlqkiBKD0hZC4YIQrs+8InWMTAjORm13D3bsMNu+dMsu0E9Mg== X-Received: by 2002:a05:6512:711:b0:507:a9b7:f071 with SMTP id b17-20020a056512071100b00507a9b7f071mr7027850lfs.1.1698083175468; Mon, 23 Oct 2023 10:46:15 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id m14-20020a056512358e00b00501c673e773sm1788053lfr.39.2023.10.23.10.46.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2023 10:46:15 -0700 (PDT) X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x12f.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273038 Archived-At: --Apple-Mail=_D3432800-D637-4F59-A33C-6BB3EE9E184F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii This patch inserts the lexical cookie in new Elisp files automatically. It helps users by making it less likely that they forget to add it, and = eliminates some drudgery. Their code will be more future-safe, and more robust and performant here = and now. --Apple-Mail=_D3432800-D637-4F59-A33C-6BB3EE9E184F Content-Disposition: attachment; filename=0001-Automatic-Elisp-dialect-declaration-insertion.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Automatic-Elisp-dialect-declaration-insertion.patch" Content-Transfer-Encoding: quoted-printable =46rom=201f046584a58da54b32b6be8c17d00c990453a177=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Sun,=2022=20Oct=202023=2016:25:28=20+0200=0A= Subject:=20[PATCH]=20Automatic=20Elisp=20dialect=20declaration=20= insertion=0A=0AInsert=20the=20`;;;=20-*-=20lexical-binding:t=20-*-`=20= cookie=20and=20set=0A`lexical-binding`=20to=20`t`=20when=20the=20user=20= visits=20a=20new=20Elisp=20file,=20unless=0Athis=20feature=20is=20= disabled.=20=20`auto-insert-mode`=20takes=20precedence.=0A=0A*=20= etc/NEWS:=20Announce.=0A*=20lisp/progmodes/elisp-mode.el=20= (emacs-lisp-mode):=20Add=20hook.=0A(elisp-auto-dialect-declaration):=20= New=20defcustom.=0A(elisp--insert-auto-dialect-declaration):=20New=20= function.=0A---=0A=20etc/NEWS=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20|=2011=20+++++++++++=0A=20lisp/progmodes/elisp-mode.el=20= |=2035=20++++++++++++++++++++++++++++++++++-=0A=202=20files=20changed,=20= 45=20insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20a/etc/NEWS=20= b/etc/NEWS=0Aindex=20d0880669752..b87f51a134c=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-797,6=20+797,17=20@@=20This=20= argument=20specifies=20the=20prettifying=20algorithm=20to=20use.=0A=20=0A= =20**=20Emacs=20Lisp=20mode=0A=20=0A+***=20Automatic=20Elisp=20dialect=20= declaration=20insertion.=0A+When=20visiting=20a=20new=20Elisp=20file,=20= Emacs=20will=20now=20automatically=20insert=20a=0A+';;;=20-*-=20= lexical-binding:=20t=20-*-'=20line=20to=20declare=20the=20modern=20Elisp=0A= +lexical-binding=20dialect,=20and=20set=20the=20'lexical-binding'=20= variable=0A+in=20the=20buffer=20to=20't'.=0A+=0A+This=20mechanism=20is=20= controlled=20by=20the=20new=20'elisp-auto-dialect-declaration'=0A+user=20= option.=20=20It=20will=20only=20insert=20a=20declaration=20into=20an=20= empty=20buffer:=0A+if=20the=20buffer=20already=20had=20text=20added=20by=20= means=20of=20'auto-insert-mode'=0A+then=20it=20will=20not=20do=20= anything.=0A+=0A=20---=0A=20***=20',@'=20now=20has=20'prefix'=20syntax.=0A= =20Previously,=20the=20'@'=20character,=20which=20normally=20has=20= 'symbol'=20syntax,=0Adiff=20--git=20a/lisp/progmodes/elisp-mode.el=20= b/lisp/progmodes/elisp-mode.el=0Aindex=20ff90a744ea3..8ac32ecd077=20= 100644=0A---=20a/lisp/progmodes/elisp-mode.el=0A+++=20= b/lisp/progmodes/elisp-mode.el=0A@@=20-363,7=20+363,40=20@@=20= emacs-lisp-mode=0A=20=20=20(add-hook=20'flymake-diagnostic-functions=20= #'elisp-flymake-checkdoc=20nil=20t)=0A=20=20=20(add-hook=20= 'flymake-diagnostic-functions=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20#'elisp-flymake-byte-compile=20nil=20t)=0A-=20=20(add-hook=20= 'context-menu-functions=20#'elisp-context-menu=2010=20t))=0A+=20=20= (add-hook=20'context-menu-functions=20#'elisp-context-menu=2010=20t)=0A+=20= =20;;=20Add=20this=20hook=20sufficient=20late=20to=20give=20other=20= hooks=20(like=20`auto-insert')=0A+=20=20;;=20the=20opportunity=20to=20= insert=20something=20with=20higher=20priority.=0A+=20=20(add-hook=20= 'find-file-hook=20#'elisp--insert-auto-dialect-declaration=2050=20t))=0A= +=0A+(defcustom=20elisp-auto-dialect-declaration=20'lexical=0A+=20=20= "Dialect=20declaration=20automatically=20inserted=20in=20new=20Elisp=20= buffers.=0A+The=20declaration=20is=20\";;;=20-*-=20lexical-binding:=20t=20= -*-\".=0A+It=20is=20only=20inserted=20when=20an=20empty=20non-existing=20= file=20is=20visited.=0A+Possible=20values=20are:=0A+=20=20`lexical'=20=20= declare=20use=20of=20the=20modern=20lexical=20binding=20dialect.=0A+=20=20= `nil'=20=20=20=20=20=20do=20not=20automatically=20insert=20any=20= declaration.=0A+=0A+If=20`auto-insert-mode'=20is=20used=20to=20put=20= something=20in=20the=20buffer=20instead,=0A+then=20no=20declaration=20is=20= inserted."=0A+=20=20:type=20'(choice=20(const=20:tag=20"Lexical=20= binding=20(modern)"=20lexical)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(const=20:tag=20"No=20automatic=20declaration"=20nil))=0A+=20= =20:group=20'lisp=0A+=20=20:version=20"30.1")=0A+=0A+(defun=20= elisp--insert-auto-dialect-declaration=20()=0A+=20=20"Insert=20the=20= `elisp-auto-dialect-declaration'=20selection=20in=20a=20new=20empty=20= buffer.=0A+Otherwise,=20do=20nothing."=0A+=20=20(when=20(and=20(eq=20= elisp-auto-dialect-declaration=20'lexical)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20(not=20buffer-read-only)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20(zerop=20(buffer-size))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= ;;=20Don't=20modify=20a=20buffer=20corresponding=20to=20an=20existing=20= empty=20file.=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(not=20(and=20= buffer-file-name=20(file-exists-p=20buffer-file-name))))=0A+=20=20=20=20= (let=20((was-modified=20(buffer-modified-p)))=0A+=20=20=20=20=20=20= (insert=20";;;=20-*-=20lexical-binding:=20t=20-*-\n")=0A+=20=20=20=20=20=20= (setq-local=20lexical-binding=20t)=0A+=20=20=20=20=20=20;;=20Mark=20the=20= buffer=20unmodified=20(unless=20it=20was=20modified=20before)=0A+=20=20=20= =20=20=20;;=20so=20that=20the=20user=20isn't=20bothered=20when=20killing=20= it=20or=20quitting=20Emacs.=0A+=20=20=20=20=20=20(set-buffer-modified-p=20= was-modified))))=0A=20=0A=20;;=20Font-locking=20support.=0A=20=0A--=20=0A= 2.32.0=20(Apple=20Git-132)=0A=0A= --Apple-Mail=_D3432800-D637-4F59-A33C-6BB3EE9E184F--