unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Recommend lexical-binding in Coding Conventions
@ 2020-10-21  1:05 Stefan Kangas
  2020-10-21  4:32 ` Drew Adams
  2020-10-21 13:33 ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Kangas @ 2020-10-21  1:05 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

We don't currently recommend using lexical-binding in our Coding
Conventions (`(elisp) Tips').  Is there some reason for that, or is it
just an oversight?

I would suggest to add it, and have attached a first draft for what it
could look like.

Thoughts?

[-- Attachment #2: 0001-Recommend-lexical-binding-in-Coding-Conventions.patch --]
[-- Type: text/x-diff, Size: 2156 bytes --]

From a2835ab38edcbd583f87998813ebf36abe110165 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Wed, 21 Oct 2020 01:50:50 +0200
Subject: [PATCH] Recommend lexical-binding in Coding Conventions

* doc/lispref/tips.texi (Coding Conventions, Library Headers):
Recommend using lexical-binding.
---
 doc/lispref/tips.texi | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi
index 5b09b2ccea..6bed53f263 100644
--- a/doc/lispref/tips.texi
+++ b/doc/lispref/tips.texi
@@ -94,6 +94,11 @@ Coding Conventions
 If one prefix is insufficient, your package can use two or three
 alternative common prefixes, so long as they make sense.
 
+@item
+We recommended to enable @code{lexical-binding} in new code, and to
+convert existing Emacs Lisp code to use lexical binding if it doesn't
+already.  @xref{Using Lexical Binding}.
+
 @item
 Put a call to @code{provide} at the end of each separate Lisp file.
 @xref{Named Features}.
@@ -963,7 +968,7 @@ Library Headers
 
 @smallexample
 @group
-;;; foo.el --- Support for the Foo programming language
+;;; foo.el --- Support for the Foo programming language  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2010-2020 Your Name
 @end group
@@ -986,14 +991,14 @@ Library Headers
   The very first line should have this format:
 
 @example
-;;; @var{filename} --- @var{description}
+;;; @var{filename} --- @var{description}  -*- lexical-binding: t; -*-
 @end example
 
 @noindent
-The description should be contained in one line.  If the file
-needs a @samp{-*-} specification, put it after @var{description}.
-If this would make the first line too long, use a Local Variables
-section at the end of the file.
+The description should be contained in one line.  If the file needs to
+set more variables in the @samp{-*-} specification, add it after
+@code{lexical-binding}.  If this would make the first line too long, use
+a Local Variables section at the end of the file.
 
   The copyright notice usually lists your name (if you wrote the
 file).  If you have an employer who claims copyright on your work, you
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-10-21 16:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-21  1:05 Recommend lexical-binding in Coding Conventions Stefan Kangas
2020-10-21  4:32 ` Drew Adams
2020-10-21 13:33 ` Stefan Monnier
2020-10-21 14:52   ` Drew Adams
2020-10-21 15:14     ` Stefan Kangas
2020-10-21 15:30       ` Alan Mackenzie
2020-10-21 16:07         ` Robert Pluim
2020-10-21 16:19         ` Stefan Kangas
2020-10-21 16:38       ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).