unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* lexical-binding in CC-mode
@ 2021-04-05 18:38 Stefan Monnier
  2021-04-06 16:19 ` Alan Mackenzie
  2021-04-10 19:47 ` Alan Mackenzie
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2021-04-05 18:38 UTC (permalink / raw)
  To: bug-cc-mode; +Cc: emacs-devel

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

Hi Alan,

We're getting to the last few remaining ELisp files in Emacs still using
the old non-lexical dialect, so I looked at converting CC-mode to use
the new dialect as well.  AFAICT the code is basically already prepared
for that, tho I did find some minor things in the patch below.

Of course, the change should be fully backward compatible (i.e. the
code sticks to the common subset of the two dialects).

See below the result of my attempt in the form of 4 patches.
0001 and 0004 are the important ones.  0002 makes the code more regular
(you already use `declare` at various places, so I think it's good to
use it more systematically).  0003 is largely a question of taste (and we
know we don't always agree on that), but I like the warnings it gives me
when a function is marked obsolete or when I make a typo.

As usual, take the parts you like,


        Stefan



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-progmodes-cc-.el-Prepare-for-lexical-binding.patch --]
[-- Type: text/x-diff, Size: 10447 bytes --]

From 0b160d16b7c2bf833c5f5596c5cf8471c3f7e4ba Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Mon, 5 Apr 2021 13:28:07 -0400
Subject: [PATCH 1/4] * lisp/progmodes/cc-*.el: Prepare for lexical-binding

Minor changes that were found while trying to use lexical-binding.

* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-construct):
Remove unused vars `decl-result` and `brace-decl-p`.
(c-electric-lt-gt, c-forward-over-illiterals): Make comment style
obey outline-minor-mode's conventions.
(c-defun-name-and-limits): Silence a warning about `where` being unused.

* lisp/progmodes/cc-engine.el (c-cache-to-parse-ps-state):
Remove always-nil vars `last` and `intermediate`.

* lisp/progmodes/cc-fonts.el (c-make-syntactic-matcher): Clarify that
regexp has to be a string rather than an expression returning a string.
(c-font-lock-c++-using): Remove unused var `after-name`.
(c-font-lock-c++-using): Tweak layout to avoid an arg being easy to misread.

* lisp/progmodes/cc-styles.el (c-set-offset): Mark arg as knowingly unused.

* lisp/progmodes/cc-mode.el (c-mode-base-map): Skip fill-paragraph-or-region
in Emacs.  Protect against disappearance of obsolete `c-subword-mode`.
---
 lisp/progmodes/cc-cmds.el   | 20 ++++++++++++--------
 lisp/progmodes/cc-defs.el   |  1 +
 lisp/progmodes/cc-engine.el | 12 ++++++------
 lisp/progmodes/cc-fonts.el  | 13 +++++++++----
 lisp/progmodes/cc-mode.el   | 10 +++++++---
 lisp/progmodes/cc-styles.el |  2 +-
 6 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 1754436d13..f7f2b10b7c 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1220,9 +1220,9 @@ c-electric-lt-gt
       (self-insert-command (prefix-numeric-value arg)))
     (setq final-pos (point))
 
-;;;; 2010-01-31: There used to be code here to put a syntax-table text
-;;;; property on the new < or > and its mate (if any) when they are template
-;;;; parens.  This is now done in an after-change function.
+;;;;  2010-01-31: There used to be code here to put a syntax-table text
+;;;;  property on the new < or > and its mate (if any) when they are template
+;;;;  parens.  This is now done in an after-change function.
 
     (when (and (not arg) (not literal))
       ;; Have we got a delimiter on a #include directive?
@@ -1640,7 +1640,7 @@ c-where-wrt-brace-construct
   ;; This function might do hidden buffer changes.
   (save-excursion
     (let* (knr-start knr-res
-	   decl-result brace-decl-p
+	   ;; decl-result brace-decl-p
 	   (start (point))
 	   (paren-state (c-parse-state))
 	   (least-enclosing (c-least-enclosing-brace paren-state)))
@@ -2308,6 +2308,7 @@ c-defun-name-and-limits
 			      (orig-point-min (point-min))
 			      (orig-point-max (point-max))
 			      lim name limits where)
+          (ignore where) ;Assigned within `c-while-widening-to-decl-block'.
 	  (setq lim (c-widen-to-enclosing-decl-scope
 		     paren-state orig-point-min orig-point-max))
 	  (and lim (setq lim (1- lim)))
@@ -2927,10 +2928,13 @@ c-forward-over-illiterals
 			 (c-looking-at-special-brace-list)))
 	       (or allow-early-stop (/= here last))
 	       (save-excursion	; Is this a check that we're NOT at top level?
-;;;; NO!  This seems to check that (i) EITHER we're at the top level; OR (ii) The next enclosing
-;;;; level of bracketing is a '{'.  HMM.  Doesn't seem to make sense.
-;;;; 2003/8/8 This might have something to do with the GCC extension "Statement Expressions", e.g.
-;;;; while ({stmt1 ; stmt2 ; exp ;}).  This form excludes such Statement Expressions.
+;;;;  NO!  This seems to check that (i) EITHER we're at the top level;
+;;;;  OR (ii) The next enclosing  level of bracketing is a '{'.  HMM.
+;;;;  Doesn't seem to make sense.
+;;;;  2003/8/8 This might have something to do with the GCC extension
+;;;;  "Statement Expressions", e.g.
+;;;;  while ({stmt1 ; stmt2 ; exp ;}).
+;;;;  This form excludes such Statement Expressions.
 		 (or (not (c-safe (up-list -1) t))
 		     (= (char-after) ?{))))
 	  (goto-char last)
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 536e676626..bfad72b7f2 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -993,6 +993,7 @@ c-with-syntax-table
   ;; way to execute code.
   ;; Maintainers' note: If TABLE is `c++-template-syntax-table', DON'T call
   ;; any forms inside this that call `c-parse-state'.  !!!!
+  ;; FIXME: Use `with-syntax-table' (introduced in Emacs-21.1)?
   `(let ((c-with-syntax-table-orig-table (syntax-table)))
      (unwind-protect
 	 (progn
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index cc9833a434..8634f7c63f 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2717,9 +2717,9 @@ c-cache-to-parse-ps-state
   ;; two char construct (such as a comment opener or an escaped character).)
   (if (and (consp elt) (>= (length elt) 3))
       ;; Inside a string or comment
-      (let ((depth 0) (containing nil) (last nil)
+      (let ((depth 0) (containing nil) ;; (last nil)
 	    in-string in-comment
-	    (min-depth 0) com-style com-str-start (intermediate nil)
+	    (min-depth 0) com-style com-str-start ;; (intermediate nil)
 	    (char-1 (nth 3 elt))	; first char of poss. 2-char construct
 	    (pos (car elt))
 	    (type (cadr elt)))
@@ -2736,14 +2736,14 @@ c-cache-to-parse-ps-state
 		       (1- pos)
 		     pos))
 	(if (memq 'pps-extended-state c-emacs-features)
-	    (list depth containing last
+	    (list depth containing nil ;; last
 		  in-string in-comment nil
 		  min-depth com-style com-str-start
-		  intermediate nil)
-	  (list depth containing last
+		  nil nil) ;; intermediate
+	  (list depth containing nil ;; last
 		in-string in-comment nil
 		min-depth com-style com-str-start
-		intermediate)))
+		))) ;; intermediate
 
     ;; Not in a string or comment.
     (if (memq 'pps-extended-state c-emacs-features)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 4e283764ce..57e5dccfd7 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -279,9 +279,11 @@ c-annotation-face
     ;; generated functions will.  (They are however used in places
     ;; covered by the font-lock context.)
     (byte-compile
+     ;; Starting with Emacs-24, we could skip this `byte-compile' and just
+     ;; use a closure.
      `(lambda (limit)
 	(let (res)
-	  (while (and (setq res (re-search-forward ,regexp limit t))
+	  (while (and (setq res (re-search-forward ',regexp limit t))
 		      (progn
 			(goto-char (match-beginning 0))
 			(or (c-skip-comments-and-strings limit)
@@ -861,6 +863,8 @@ c-basic-matchers-before
 		 ;; search from the end of the first highlighted
 		 ;; submatch (something that causes problems in other
 		 ;; places).
+		 ;; Starting with Emacs-24, we could skip this
+		 ;; `byte-compile' and just use a closure.
 		 `(lambda (limit)
 		    (while (re-search-forward
 			    ,(concat "\\(\\<" ; 1
@@ -2287,7 +2291,7 @@ c-font-lock-c++-using
   ;; font-lock-keyword-face.  It always returns NIL to inhibit this and
   ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
   ;; fontification".
-  (let (pos after-name)
+  (let (pos) ;; after-name
     (while (c-syntactic-re-search-forward c-using-key limit 'end)
       (while  ; Do one declarator of a comma separated list, each time around.
 	  (progn
@@ -2295,7 +2299,7 @@ c-font-lock-c++-using
 	    (setq pos (point))		; token after "using".
 	    (when (and (c-on-identifier)
 		       (c-forward-name))
-	      (setq after-name (point))
+	      ;; (setq after-name (point))
 	      (cond
 	       ((eq (char-after) ?=)		; using foo = <type-id>;
 		(goto-char pos)
@@ -2305,7 +2309,8 @@ c-font-lock-c++-using
 		       (c-go-up-list-backward)
 		       (eq (char-after) ?{)
 		       (eq (car (c-beginning-of-decl-1
-				 (c-determine-limit 1000))) 'same)
+				 (c-determine-limit 1000)))
+			   'same)
 		       (looking-at c-colon-type-list-re)))
 		;; Inherited protected member: leave unfontified
 		)
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index cfb23d0d45..f1f8f19cee 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -370,8 +370,9 @@ c-bind-special-erase-keys
 			     c-mode-base-map global-map)
   ;; In XEmacs the default fill function is called
   ;; fill-paragraph-or-region.
-  (substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph
-			     c-mode-base-map global-map)
+  (when (featurep 'xemacs)
+    (substitute-key-definition #'fill-paragraph-or-region #'c-fill-paragraph
+			       c-mode-base-map global-map))
 
   ;; We bind the forward deletion key and (implicitly) C-d to
   ;; `c-electric-delete-forward', and the backward deletion key to
@@ -443,7 +444,8 @@ c-bind-special-erase-keys
   ;; conflicts with OOBR
   ;;(define-key c-mode-base-map "\C-c\C-v"  'c-version)
   ;; (define-key c-mode-base-map "\C-c\C-y"  'c-toggle-hungry-state)  Commented out by ACM, 2005-11-22.
-  (define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode)
+  (define-key c-mode-base-map "\C-c\C-w"
+    (if (fboundp 'c-subword-mode) #'c-subword-mode #'subword-mode))
   (define-key c-mode-base-map "\C-c\C-k" 'c-toggle-comment-style)
   (define-key c-mode-base-map "\C-c\C-z" 'c-display-defun-name))
 
@@ -2055,6 +2057,7 @@ c-before-change
 				    (buffer-substring-no-properties beg end)))))))
 
 		(if c-get-state-before-change-functions
+		    ;; Use `run-hook-with-args'?
 		    (mapc (lambda (fn)
 			    (funcall fn beg end))
 			  c-get-state-before-change-functions))
@@ -2157,6 +2160,7 @@ c-after-change
 
 		(setq c-in-after-change-fontification t)
 		(save-excursion
+		  ;; Use `run-hook-with-args'?
 		  (mapc (lambda (fn)
 			  (funcall fn beg end old-len))
 			c-before-font-lock-functions)))
diff --git a/lisp/progmodes/cc-styles.el b/lisp/progmodes/cc-styles.el
index 29cbe54c3b..f2ebaa48f3 100644
--- a/lisp/progmodes/cc-styles.el
+++ b/lisp/progmodes/cc-styles.el
@@ -464,7 +464,7 @@ c-read-offset
     offset))
 
 ;;;###autoload
-(defun c-set-offset (symbol offset &optional ignored)
+(defun c-set-offset (symbol offset &optional _ignored)
   "Change the value of a syntactic element symbol in `c-offsets-alist'.
 SYMBOL is the syntactic element symbol to change and OFFSET is the new
 offset for that syntactic element.  The optional argument is not used
-- 
2.30.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-lisp-progmodes-cc-.el-Use-declare-in-macros.patch --]
[-- Type: text/x-diff, Size: 16575 bytes --]

From 3f22bfba9b15f52137ad2f3e19b5e9e154ade0f8 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Mon, 5 Apr 2021 13:43:09 -0400
Subject: [PATCH 2/4] * lisp/progmodes/cc-*.el: Use `declare` in macros

This converts most uses of `def-edebug-spec` and (put..list-indent-function..)
to use `declare` instead.  I left those in `cc-defs.el` because there
were too many, and I left those applied to functions since Emacs-21
only supports `declare` in `defmacro` and not in `defun`.

* lisp/progmodes/cc-langs.el (c-lang-defvar, c-lang-setvar):
* lisp/progmodes/cc-fonts.el (c-put-font-lock-face)
(c-remove-font-lock-face, c-put-font-lock-string-face)
(c-fontify-types-and-refs, c-font-lock-doc-comments):
* lisp/progmodes/cc-defs.el (cc-eval-when-compile, c-safe)
(c-tentative-buffer-changes, c-with-syntax-table, c-lang-defconst):
* lisp/progmodes/cc-cmds.el (c-while-widening-to-decl-block):
* lisp/progmodes/cc-engine.el (c-bos-pop-state)
(c-bos-save-error-info, c-put-is-sws, c-put-in-sws, c-remove-is-sws)
(c-remove-in-sws, c-remove-is-and-in-sws, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-state-maybe-marker, c-record-type-id, c-record-ref-id)
(c-forward-keyword-prefixed-id, c-forward-id-comma-list)
(c-pull-open-brace): Use `declare` for indent and debug specs.
---
 lisp/progmodes/cc-cmds.el   |  3 +--
 lisp/progmodes/cc-defs.el   | 21 +++++++--------------
 lisp/progmodes/cc-engine.el | 33 ++++++++++++++++-----------------
 lisp/progmodes/cc-fonts.el  | 15 +++++----------
 lisp/progmodes/cc-langs.el  | 12 ++++--------
 5 files changed, 33 insertions(+), 51 deletions(-)

diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index f7f2b10b7c..87ac076ee4 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1819,6 +1819,7 @@ c-widen-to-enclosing-decl-scope
     ;; This is a very special purpose macro, which assumes the existence of
     ;; several variables.  It is for use only in c-beginning-of-defun and
     ;; c-end-of-defun.
+    (declare (debug t))
     `(while
 	 (and ,condition
 	      (eq c-defun-tactic 'go-outward)
@@ -1828,8 +1829,6 @@ c-widen-to-enclosing-decl-scope
 		  paren-state orig-point-min orig-point-max))
        (setq where 'in-block))))
 
-(def-edebug-spec c-while-widening-to-decl-block t)
-
 (defun c-beginning-of-defun (&optional arg)
   "Move backward to the beginning of a defun.
 Every top level declaration that contains a brace paren block is
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index bfad72b7f2..3072733d4d 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -125,7 +125,7 @@ c-syntax-table-hwm
 
 This variant works around bugs in `eval-when-compile' in various
 \(X)Emacs versions.  See cc-defs.el for details."
-
+    (declare (indent 0) (debug t))
     (if c-inside-eval-when-compile
 	;; XEmacs 21.4.6 has a bug in `eval-when-compile' in that it
 	;; evaluates its body at macro expansion time if it's nested
@@ -170,9 +170,7 @@ c-syntax-table-hwm
 	 ;; constant that we eval.  That otoh introduce a problem in
 	 ;; that a returned lambda expression doesn't get byte
 	 ;; compiled (even if `function' is used).
-	 (eval '(let ((c-inside-eval-when-compile t)) ,@body)))))
-
-  (put 'cc-eval-when-compile 'lisp-indent-hook 0))
+	 (eval '(let ((c-inside-eval-when-compile t)) ,@body))))))
 
 \f
 ;;; Macros.
@@ -505,10 +503,10 @@ c-delete-and-extract-region
 
 (defmacro c-safe (&rest body)
   ;; safely execute BODY, return nil if an error occurred
+  (declare (indent 0) (debug t))
   `(condition-case nil
        (progn ,@body)
      (error nil)))
-(put 'c-safe 'lisp-indent-function 0)
 
 (defmacro c-int-to-char (integer)
   ;; In Emacs, a character is an integer.  In XEmacs, a character is a
@@ -628,6 +626,7 @@ c-tentative-buffer-changes
 macro inside `c-save-buffer-state'.  That way the change can be done
 even when the buffer is read-only, and without interference from
 various buffer change hooks."
+  (declare (indent 0) (debug t))
   `(let (-tnt-chng-keep
 	 -tnt-chng-state)
      (unwind-protect
@@ -638,7 +637,6 @@ c-tentative-buffer-changes
 	       -tnt-chng-state (c-tnt-chng-record-state)
 	       -tnt-chng-keep (progn ,@body))
        (c-tnt-chng-cleanup -tnt-chng-keep -tnt-chng-state))))
-(put 'c-tentative-buffer-changes 'lisp-indent-function 0)
 
 (defun c-tnt-chng-record-state ()
   ;; Used internally in `c-tentative-buffer-changes'.
@@ -993,6 +991,7 @@ c-with-syntax-table
   ;; way to execute code.
   ;; Maintainers' note: If TABLE is `c++-template-syntax-table', DON'T call
   ;; any forms inside this that call `c-parse-state'.  !!!!
+  (declare (indent 1) (debug t))
   ;; FIXME: Use `with-syntax-table' (introduced in Emacs-21.1)?
   `(let ((c-with-syntax-table-orig-table (syntax-table)))
      (unwind-protect
@@ -1000,7 +999,6 @@ c-with-syntax-table
 	   (set-syntax-table ,table)
 	   ,@code)
        (set-syntax-table c-with-syntax-table-orig-table))))
-(put 'c-with-syntax-table 'lisp-indent-function 1)
 
 (defmacro c-skip-ws-forward (&optional limit)
   "Skip over any whitespace following point.
@@ -2397,7 +2395,8 @@ c-lang-defconst
 already is one it will be completely replaced; the value in the
 earlier definition will not affect `c-lang-const' on the same
 constant.  A file is identified by its base name."
-
+  (declare (indent 1)
+	   (debug (&define name [&optional stringp] [&rest sexp def-form])))
   (let* ((sym (intern (symbol-name name) c-lang-constants))
 	 ;; Make `c-lang-const' expand to a straightforward call to
 	 ;; `c-get-lang-constant' in `c--macroexpand-all' below.
@@ -2488,12 +2487,6 @@ c-lang-defconst
        (c-define-lang-constant ',name ,bindings
 			       ,@(and pre-files `(',pre-files))))))
 
-(put 'c-lang-defconst 'lisp-indent-function 1)
-;(eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
-;  '
-(def-edebug-spec c-lang-defconst
-  (&define name [&optional stringp] [&rest sexp def-form]))
-
 (defun c-define-lang-constant (name bindings &optional pre-files)
   ;; Used by `c-lang-defconst'.
 
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 8634f7c63f..56d33ac117 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -735,6 +735,7 @@ c-bos-push-state
   '(setq stack (cons (cons state saved-pos)
 		     stack)))
 (defmacro c-bos-pop-state (&optional do-if-done)
+  (declare (debug t))
   `(if (setq state (car (car stack))
 	     saved-pos (cdr (car stack))
 	     stack (cdr stack))
@@ -759,6 +760,7 @@ c-bos-restore-pos
      (goto-char pos)
      (setq sym nil)))
 (defmacro c-bos-save-error-info (missing got)
+  (declare (debug t))
   `(setq saved-pos (vector pos ,missing ,got)))
 (defmacro c-bos-report-error ()
   '(unless noerror
@@ -1876,44 +1878,44 @@ c-debug-sws-msg
 
 (defmacro c-put-is-sws (beg end)
   ;; This macro does a hidden buffer change.
+  (declare (debug t))
   `(let ((beg ,beg) (end ,end))
      (put-text-property beg end 'c-is-sws t)
      ,@(when (facep 'c-debug-is-sws-face)
 	 '((c-debug-add-face beg end 'c-debug-is-sws-face)))))
-(def-edebug-spec c-put-is-sws t)
 
 (defmacro c-put-in-sws (beg end)
   ;; This macro does a hidden buffer change.
+  (declare (debug t))
   `(let ((beg ,beg) (end ,end))
      (put-text-property beg end 'c-in-sws t)
      ,@(when (facep 'c-debug-is-sws-face)
 	 '((c-debug-add-face beg end 'c-debug-in-sws-face)))))
-(def-edebug-spec c-put-in-sws t)
 
 (defmacro c-remove-is-sws (beg end)
   ;; This macro does a hidden buffer change.
+  (declare (debug t))
   `(let ((beg ,beg) (end ,end))
      (remove-text-properties beg end '(c-is-sws nil))
      ,@(when (facep 'c-debug-is-sws-face)
 	 '((c-debug-remove-face beg end 'c-debug-is-sws-face)))))
-(def-edebug-spec c-remove-is-sws t)
 
 (defmacro c-remove-in-sws (beg end)
   ;; This macro does a hidden buffer change.
+  (declare (debug t))
   `(let ((beg ,beg) (end ,end))
      (remove-text-properties beg end '(c-in-sws nil))
      ,@(when (facep 'c-debug-is-sws-face)
 	 '((c-debug-remove-face beg end 'c-debug-in-sws-face)))))
-(def-edebug-spec c-remove-in-sws t)
 
 (defmacro c-remove-is-and-in-sws (beg end)
   ;; This macro does a hidden buffer change.
+  (declare (debug t))
   `(let ((beg ,beg) (end ,end))
      (remove-text-properties beg end '(c-is-sws nil c-in-sws nil))
      ,@(when (facep 'c-debug-is-sws-face)
 	 '((c-debug-remove-face beg end 'c-debug-is-sws-face)
 	   (c-debug-remove-face beg end 'c-debug-in-sws-face)))))
-(def-edebug-spec c-remove-is-and-in-sws t)
 
 ;; The type of literal position `end' is in a `before-change-functions'
 ;; function - one of `c', `c++', `pound', `noise', `attribute' or nil (but NOT
@@ -3516,6 +3518,7 @@ c-state-brace-pair-desert
 (defmacro c-state-cache-top-lparen (&optional cache)
   ;; Return the address of the top left brace/bracket/paren recorded in CACHE
   ;; (default `c-state-cache') (or nil).
+  (declare (debug t))
   (let ((cash (or cache 'c-state-cache)))
     `(if (consp (car ,cash))
 	 (caar ,cash)
@@ -3524,6 +3527,7 @@ c-state-cache-top-lparen
 (defmacro c-state-cache-top-paren (&optional cache)
   ;; Return the address of the latest brace/bracket/paren (whether left or
   ;; right) recorded in CACHE (default `c-state-cache') or nil.
+  (declare (debug t))
   (let ((cash (or cache 'c-state-cache)))
     `(if (consp (car ,cash))
 	 (cdar ,cash)
@@ -3532,6 +3536,7 @@ c-state-cache-top-paren
 (defmacro c-state-cache-after-top-paren (&optional cache)
   ;; Return the position just after the latest brace/bracket/paren (whether
   ;; left or right) recorded in CACHE (default `c-state-cache') or nil.
+  (declare (debug t))
   (let ((cash (or cache 'c-state-cache)))
     `(if (consp (car ,cash))
 	 (cdar ,cash)
@@ -4486,6 +4491,7 @@ c-invalidate-state-cache
 (defmacro c-state-maybe-marker (place marker)
   ;; If PLACE is non-nil, return a marker marking it, otherwise nil.
   ;; We (re)use MARKER.
+  (declare (debug (form symbolp)))
   `(let ((-place- ,place))
      (and -place-
 	  (or ,marker (setq ,marker (make-marker)))
@@ -7773,6 +7779,7 @@ c-record-ref-identifiers
 (defvar c-last-identifier-range nil)
 
 (defmacro c-record-type-id (range)
+  (declare (debug t))
   (if (eq (car-safe range) 'cons)
       ;; Always true.
       `(setq c-record-type-identifiers
@@ -7783,6 +7790,7 @@ c-record-type-id
 		 (cons range c-record-type-identifiers))))))
 
 (defmacro c-record-ref-id (range)
+  (declare (debug t))
   (if (eq (car-safe range) 'cons)
       ;; Always true.
       `(setq c-record-ref-identifiers
@@ -7808,6 +7816,7 @@ c-forward-keyword-prefixed-id
   ;; if TYPE is 'type or as a reference if TYPE is 'ref.
   ;;
   ;; This macro might do hidden buffer changes.
+  (declare (debug t))
   `(let (res)
      (setq c-last-identifier-range nil)
      (while (if (setq res ,(if (eq type 'type)
@@ -7832,6 +7841,7 @@ c-forward-id-comma-list
   ;; `c-forward-keyword-prefixed-id'.
   ;;
   ;; This macro might do hidden buffer changes.
+  (declare (debug t))
   `(while (and (progn
 		 ,(when update-safe-pos
 		    '(setq safe-pos (point)))
@@ -8775,6 +8785,7 @@ c-forward-annotation
 (defmacro c-pull-open-brace (ps)
   ;; Pull the next open brace from PS (which has the form of paren-state),
   ;; skipping over any brace pairs.  Returns NIL when PS is exhausted.
+  (declare (debug (symbolp)))
   `(progn
      (while (consp (car ,ps))
        (setq ,ps (cdr ,ps)))
@@ -14685,18 +14696,6 @@ c-get-syntactic-indentation
 		    (current-column)))
       indent)))
 
-\f
-(def-edebug-spec c-bos-pop-state t)
-(def-edebug-spec c-bos-save-error-info t)
-(def-edebug-spec c-state-cache-top-lparen t)
-(def-edebug-spec c-state-cache-top-paren t)
-(def-edebug-spec c-state-cache-after-top-paren t)
-(def-edebug-spec c-state-maybe-marker (form symbolp))
-(def-edebug-spec c-record-type-id t)
-(def-edebug-spec c-record-ref-id t)
-(def-edebug-spec c-forward-keyword-prefixed-id t)
-(def-edebug-spec c-forward-id-comma-list t)
-(def-edebug-spec c-pull-open-brace (symbolp))
 \f
 (cc-provide 'cc-engine)
 
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 57e5dccfd7..3567f5e76e 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -218,6 +218,7 @@ c-annotation-face
     ;; incorrectly.
     ;;
     ;; This function does a hidden buffer change.
+    (declare (debug t))
     (if (fboundp 'font-lock-set-face)
 	;; Note: This function has no docstring in XEmacs so it might be
 	;; considered internal.
@@ -228,6 +229,7 @@ c-annotation-face
     ;; This is the inverse of `c-put-font-lock-face'.
     ;;
     ;; This function does a hidden buffer change.
+    (declare (debug t))
     (if (fboundp 'font-lock-remove-face)
 	`(font-lock-remove-face ,from ,to)
       `(remove-text-properties ,from ,to '(face nil))))
@@ -238,11 +240,13 @@ c-annotation-face
     ;; region should include them.
     ;;
     ;; This function does a hidden buffer change.
+    (declare (debug t))
     (if (featurep 'xemacs)
 	`(c-put-font-lock-face (1+ ,from) (1- ,to) 'font-lock-string-face)
       `(c-put-font-lock-face ,from ,to 'font-lock-string-face)))
 
   (defmacro c-fontify-types-and-refs (varlist &rest body)
+    (declare (indent 1) (debug let*))
     ;; Like `let', but additionally activates `c-record-type-identifiers'
     ;; and `c-record-ref-identifiers', and fontifies the recorded ranges
     ;; accordingly on exit.
@@ -253,7 +257,6 @@ c-annotation-face
 	   ,@varlist)
        (prog1 (progn ,@body)
 	 (c-fontify-recorded-types-and-refs))))
-  (put 'c-fontify-types-and-refs 'lisp-indent-function 1)
 
   (defun c-skip-comments-and-strings (limit)
     ;; If the point is within a region fontified as a comment or
@@ -486,13 +489,6 @@ c-annotation-face
 	  ,(c-make-font-lock-search-form (car normal) (cdr normal) t)
 	  nil))))
 
-;  (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
-;    '(progn
-(def-edebug-spec c-put-font-lock-face t)
-(def-edebug-spec c-remove-font-lock-face t)
-(def-edebug-spec c-put-font-lock-string-face t)
-  (def-edebug-spec c-fontify-types-and-refs let*)
-  (def-edebug-spec c-make-syntactic-matcher t)
   ;; If there are literal quoted or backquoted highlight specs in
   ;; the call to `c-make-font-lock-search-function' then let's
   ;; instrument the forms in them.
@@ -2788,7 +2784,7 @@ c-font-lock-doc-comments
   ;; is used as a flag in other code to skip comments.
   ;;
   ;; This function might do hidden buffer changes.
-
+  (declare (indent 2))
   (let (comment-beg region-beg)
     (if (memq (get-text-property (point) 'face)
 	      '(font-lock-comment-face font-lock-comment-delimiter-face))
@@ -2871,7 +2867,6 @@ c-font-lock-doc-comments
 
 	  (goto-char region-end)))))
   nil)
-(put 'c-font-lock-doc-comments 'lisp-indent-function 2)
 
 (defun c-find-invalid-doc-markup (regexp limit)
   ;; Used to fontify invalid markup in doc comments after the correct
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index fa4e73087e..9edef527d8 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -159,7 +159,9 @@ c-lang-defvar
 `c-lang-const' is typically used in VAL to get the right value for the
 language being initialized, and such calls will be macro expanded to
 the evaluated constant value at compile time."
-
+  (declare (indent defun)
+	   (debug (&define name def-form
+			   &optional &or ("quote" symbolp) stringp)))
   (when (and (not doc)
 	     (eq (car-safe val) 'c-lang-const)
 	     (eq (nth 1 val) var)
@@ -191,6 +193,7 @@ c-lang-setvar
 `c-lang-const' is typically used in VAL to get the right value for the
 language being initialized, and such calls will be macro expanded to
 the evaluated constant value at compile time."
+  (declare (debug (&define name def-form)))
   (let ((elem (assq var (cdr c-emacs-variable-inits))))
     (if elem
 	(setcdr elem (list val)) ; Maybe remove "list", sometime. 2006-07-19
@@ -200,13 +203,6 @@ c-lang-setvar
   ;; Return the symbol, like the other def* forms.
   `',var)
 
-(put 'c-lang-defvar 'lisp-indent-function 'defun)
-; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
-;  '
-(def-edebug-spec c-lang-defvar
-  (&define name def-form &optional &or ("quote" symbolp) stringp))
-(def-edebug-spec c-lang-setvar (&define name def-form))
-
 ;; Suppress "might not be defined at runtime" warning.
 ;; This file is only used when compiling other cc files.
 (declare-function cl-delete-duplicates "cl-seq" (cl-seq &rest cl-keys))
-- 
2.30.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-lisp-progmodes-cc-.el-Prefer-to-quote-functions.patch --]
[-- Type: text/x-diff, Size: 27590 bytes --]

From 92d421958424fa3a008e8f4dcfb2d7936ca784b6 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Mon, 5 Apr 2021 14:15:55 -0400
Subject: [PATCH 3/4] * lisp/progmodes/cc-*.el: Prefer #' to quote functions

---
 lisp/progmodes/cc-cmds.el   |  18 ++--
 lisp/progmodes/cc-defs.el   |   8 +-
 lisp/progmodes/cc-engine.el |   8 +-
 lisp/progmodes/cc-fonts.el  |   2 +-
 lisp/progmodes/cc-mode.el   | 195 ++++++++++++++++++------------------
 lisp/progmodes/cc-styles.el |   2 +-
 lisp/progmodes/cc-vars.el   |   2 +-
 7 files changed, 120 insertions(+), 115 deletions(-)

diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 87ac076ee4..c1c7916309 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -327,7 +327,7 @@ c-toggle-auto-newline
   (c-update-modeline)
   (c-keep-region-active))
 
-(defalias 'c-toggle-auto-state 'c-toggle-auto-newline)
+(defalias 'c-toggle-auto-state #'c-toggle-auto-newline)
 (make-obsolete 'c-toggle-auto-state 'c-toggle-auto-newline "22.1")
 
 (defun c-toggle-hungry-state (&optional arg)
@@ -434,7 +434,7 @@ c-hungry-delete-backwards
 	(delete-region (point) here)
       (funcall c-backspace-function 1))))
 
-(defalias 'c-hungry-backspace 'c-hungry-delete-backwards)
+(defalias 'c-hungry-backspace #'c-hungry-delete-backwards)
 
 (defun c-electric-delete-forward (arg)
   "Delete the following character or whitespace.
@@ -1526,10 +1526,10 @@ c-toggle-cpp-indent-to-body
   (if c-cpp-indent-to-body-flag
       (progn
 	(c-clear-stale-indent-to-body-abbrevs)
-	(mapc 'c-add-indent-to-body-to-abbrev-table
+	(mapc #'c-add-indent-to-body-to-abbrev-table
 	      c-cpp-indent-to-body-directives)
-	(add-hook 'c-special-indent-hook 'c-align-cpp-indent-to-body nil t))
-    (remove-hook 'c-special-indent-hook 'c-align-cpp-indent-to-body t))
+	(add-hook 'c-special-indent-hook #'c-align-cpp-indent-to-body nil t))
+    (remove-hook 'c-special-indent-hook #'c-align-cpp-indent-to-body t))
   (message "c-cpp-indent-to-body %sabled"
 	   (if c-cpp-indent-to-body-flag "en" "dis")))
 
@@ -1541,8 +1541,8 @@ c-toggle-cpp-indent-to-body
 (cond
  ((and (fboundp 'subword-mode) (not (fboundp 'c-subword-mode)))
   ;; Recent Emacsen come with their own subword support.  Use that.
-  (define-obsolete-function-alias 'c-subword-mode 'subword-mode "24.3")
-  (define-obsolete-variable-alias 'c-subword-mode 'subword-mode "24.3"))
+  (define-obsolete-function-alias 'c-subword-mode #'subword-mode "24.3")
+  (define-obsolete-variable-alias 'c-subword-mode #'subword-mode "24.3"))
  (t
   ;; Autoload directive for emacsen that doesn't have an older CC Mode
   ;; version in the dist.
@@ -5003,8 +5003,8 @@ c-indent-new-comment-line
 	     (funcall do-line-break)
 	     (indent-to col))))))
 
-(defalias 'c-comment-line-break-function 'c-indent-new-comment-line)
-(make-obsolete 'c-comment-line-break-function 'c-indent-new-comment-line "21.1")
+(defalias 'c-comment-line-break-function #'c-indent-new-comment-line)
+(make-obsolete 'c-comment-line-break-function #'c-indent-new-comment-line "21.1")
 
 ;; Advice for Emacsen older than 21.1 (!), released 2001/10
 (unless (boundp 'comment-line-break-function)
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 3072733d4d..9e17356d59 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -1923,7 +1923,7 @@ c-face-name-p
 (defun c-concat-separated (list separator)
   "Like `concat' on LIST, but separate each element with SEPARATOR.
 Notably, null elements in LIST are ignored."
-  (mapconcat 'identity (delete nil (append list nil)) separator))
+  (mapconcat #'identity (delete nil (append list nil)) separator))
 
 (defun c-make-keywords-re (adorn list &optional mode)
   "Make a regexp that matches all the strings the list.
@@ -2053,8 +2053,8 @@ c-make-bare-char-alt
     str))
 
 ;; Leftovers from (X)Emacs 19 compatibility.
-(defalias 'c-regexp-opt 'regexp-opt)
-(defalias 'c-regexp-opt-depth 'regexp-opt-depth)
+(defalias 'c-regexp-opt #'regexp-opt)
+(defalias 'c-regexp-opt-depth #'regexp-opt-depth)
 
 \f
 ;; Figure out what features this Emacs has
@@ -2474,7 +2474,7 @@ c-lang-defconst
     ;; definitions for this symbol, to make sure the order in the
     ;; `source' property is correct even when files are loaded out of
     ;; order.
-    (setq pre-files (mapcar 'car (get sym 'source)))
+    (setq pre-files (mapcar #'car (get sym 'source)))
     (if (memq file pre-files)
 	;; This can happen when the source file (e.g. cc-langs.el) is first
 	;; loaded as source, setting a 'source property entry, and then itself
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 56d33ac117..35f9146116 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -556,7 +556,7 @@ c-syntactic-content
 	    (setq from (point))))
 
 	(setcdr tail (list (buffer-substring-no-properties from to)))
-	(apply 'concat (cdr parts))))))
+	(apply #'concat (cdr parts))))))
 
 (defun c-shift-line-indentation (shift-amt)
   ;; Shift the indentation of the current line with the specified
@@ -5730,7 +5730,7 @@ c-literal-start
     (car (cddr (c-semi-pp-to-literal (point))))))
 
 ;; In case external callers use this; it did have a docstring.
-(defalias 'c-literal-limits-fast 'c-literal-limits)
+(defalias 'c-literal-limits-fast #'c-literal-limits)
 
 (defun c-collect-line-comments (range)
   "If the argument is a cons of two buffer positions (such as returned by
@@ -6843,7 +6843,7 @@ c-list-found-types
     (maphash (lambda (type _)
 	       (setq type-list (cons type type-list)))
 	      c-found-types)
-    (sort type-list 'string-lessp)))
+    (sort type-list #'string-lessp)))
 
 ;; Shut up the byte compiler.
 (defvar c-maybe-stale-found-type)
@@ -12558,7 +12558,7 @@ c-add-stmt-syntax
 	  on-label)
 
       ;; Use point as the anchor point for "namespace", "extern", etc.
-      (apply 'c-add-syntax syntax-symbol
+      (apply #'c-add-syntax syntax-symbol
 	     (if (rassq syntax-symbol c-other-decl-block-key-in-symbols-alist)
 		 (point) nil)
 	     syntax-extra-args)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 3567f5e76e..8ac51be170 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -2585,7 +2585,7 @@ objc-font-lock-keywords
 ;; package.  The value replaced here isn't relevant now anyway since
 ;; those types are builtin and therefore listed directly in
 ;; `c-primitive-type-kwds'.
-(when (equal (sort (append objc-font-lock-extra-types nil) 'string-lessp)
+(when (equal (sort (append objc-font-lock-extra-types nil) #'string-lessp)
 	     '("BOOL" "Class" "IMP" "SEL"))
   (setq objc-font-lock-extra-types
 	(cc-eval-when-compile (list (concat "[" c-upper "]\\sw*")))))
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index f1f8f19cee..c7fc0db05c 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -227,7 +227,7 @@ c-initialize-cc-mode
 	    ;; Fix obsolete variables.
 	    (if (boundp 'c-comment-continuation-stars)
 		(setq c-block-comment-prefix c-comment-continuation-stars))
-	    (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode)
+	    (add-hook 'change-major-mode-hook #'c-leave-cc-mode-mode)
 	    ;; Connect up with Emacs's electric-pair-mode
 	    (eval-after-load "elec-pair"
 	      '(when (boundp 'electric-pair-inhibit-predicate)
@@ -240,9 +240,9 @@ c-initialize-cc-mode
 	    (setq c-initialization-ok t)
 	    ;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4
             (when (fboundp 'electric-indent-local-mode)
-	      (add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook)
+	      (add-hook 'electric-indent-mode-hook #'c-electric-indent-mode-hook)
               (add-hook 'electric-indent-local-mode-hook
-                        'c-electric-indent-local-mode-hook)))
+                        #'c-electric-indent-local-mode-hook)))
 	;; Will try initialization hooks again if they failed.
 	(put 'c-initialize-cc-mode initprop c-initialization-ok))))
 
@@ -325,38 +325,38 @@ c-bind-special-erase-keys
 
   ;; Separate M-BS from C-M-h.  The former should remain
   ;; backward-kill-word.
-  (define-key c-mode-base-map [(control meta h)] 'c-mark-function)
-  (define-key c-mode-base-map "\e\C-q"    'c-indent-exp)
-  (substitute-key-definition 'backward-sentence
-			     'c-beginning-of-statement
+  (define-key c-mode-base-map [(control meta h)] #'c-mark-function)
+  (define-key c-mode-base-map "\e\C-q"    #'c-indent-exp)
+  (substitute-key-definition #'backward-sentence
+			     #'c-beginning-of-statement
 			     c-mode-base-map global-map)
-  (substitute-key-definition 'forward-sentence
-			     'c-end-of-statement
+  (substitute-key-definition #'forward-sentence
+			     #'c-end-of-statement
 			     c-mode-base-map global-map)
-  (substitute-key-definition 'indent-new-comment-line
-			     'c-indent-new-comment-line
+  (substitute-key-definition #'indent-new-comment-line
+			     #'c-indent-new-comment-line
 			     c-mode-base-map global-map)
-  (substitute-key-definition 'indent-for-tab-command
+  (substitute-key-definition #'indent-for-tab-command
 			     ;; XXX Is this the right thing to do
 			     ;; here?
-			     'c-indent-line-or-region
+			     #'c-indent-line-or-region
 			     c-mode-base-map global-map)
   (when (fboundp 'comment-indent-new-line)
     ;; indent-new-comment-line has changed name to
     ;; comment-indent-new-line in Emacs 21.
-    (substitute-key-definition 'comment-indent-new-line
-			       'c-indent-new-comment-line
+    (substitute-key-definition #'comment-indent-new-line
+			       #'c-indent-new-comment-line
 			       c-mode-base-map global-map))
 
   ;; RMS says don't make these the default.
   ;; (April 2006): RMS has now approved these commands as defaults.
   (unless (memq 'argumentative-bod-function c-emacs-features)
-    (define-key c-mode-base-map "\e\C-a"    'c-beginning-of-defun)
-    (define-key c-mode-base-map "\e\C-e"    'c-end-of-defun))
+    (define-key c-mode-base-map "\e\C-a"    #'c-beginning-of-defun)
+    (define-key c-mode-base-map "\e\C-e"    #'c-end-of-defun))
 
-  (define-key c-mode-base-map "\C-c\C-n"  'c-forward-conditional)
-  (define-key c-mode-base-map "\C-c\C-p"  'c-backward-conditional)
-  (define-key c-mode-base-map "\C-c\C-u"  'c-up-conditional)
+  (define-key c-mode-base-map "\C-c\C-n"  #'c-forward-conditional)
+  (define-key c-mode-base-map "\C-c\C-p"  #'c-backward-conditional)
+  (define-key c-mode-base-map "\C-c\C-u"  #'c-up-conditional)
 
   ;; It doesn't suffice to put `c-fill-paragraph' on
   ;; `fill-paragraph-function' since `c-fill-paragraph' must be called
@@ -366,7 +366,7 @@ c-bind-special-erase-keys
   ;; before that.  Also, `c-fill-paragraph' chains on to
   ;; `fill-paragraph' and the value on `fill-paragraph-function' to
   ;; do the actual filling work.
-  (substitute-key-definition 'fill-paragraph 'c-fill-paragraph
+  (substitute-key-definition #'fill-paragraph #'c-fill-paragraph
 			     c-mode-base-map global-map)
   ;; In XEmacs the default fill function is called
   ;; fill-paragraph-or-region.
@@ -389,20 +389,20 @@ c-bind-special-erase-keys
   ;; automatically maps the [delete] and [backspace] keys to these two
   ;; depending on window system and user preferences.  (In earlier
   ;; versions it's possible to do the same by using `function-key-map'.)
-  (define-key c-mode-base-map "\C-d" 'c-electric-delete-forward)
-  (define-key c-mode-base-map "\177" 'c-electric-backspace)
-  (define-key c-mode-base-map "\C-c\C-d"     'c-hungry-delete-forward)
-  (define-key c-mode-base-map [?\C-c ?\d]    'c-hungry-delete-backwards)
-  (define-key c-mode-base-map [?\C-c ?\C-\d] 'c-hungry-delete-backwards)
-  (define-key c-mode-base-map [?\C-c deletechar] 'c-hungry-delete-forward) ; C-c <delete> on a tty.
+  (define-key c-mode-base-map "\C-d" #'c-electric-delete-forward)
+  (define-key c-mode-base-map "\177" #'c-electric-backspace)
+  (define-key c-mode-base-map "\C-c\C-d"     #'c-hungry-delete-forward)
+  (define-key c-mode-base-map [?\C-c ?\d]    #'c-hungry-delete-backwards)
+  (define-key c-mode-base-map [?\C-c ?\C-\d] #'c-hungry-delete-backwards)
+  (define-key c-mode-base-map [?\C-c deletechar] #'c-hungry-delete-forward) ; C-c <delete> on a tty.
   (define-key c-mode-base-map [?\C-c (control deletechar)] ; C-c C-<delete> on a tty.
-    'c-hungry-delete-forward)
+    #'c-hungry-delete-forward)
   (when (boundp 'normal-erase-is-backspace)
     ;; The automatic C-d and DEL mapping functionality doesn't extend
     ;; to special combinations like C-c C-<delete>, so we have to hook
     ;; into the `normal-erase-is-backspace' system to bind it directly
     ;; as appropriate.
-    (add-hook 'normal-erase-is-backspace-mode-hook 'c-bind-special-erase-keys)
+    (add-hook 'normal-erase-is-backspace-mode-hook #'c-bind-special-erase-keys)
     (c-bind-special-erase-keys))
 
   (when (fboundp 'delete-forward-p)
@@ -411,43 +411,43 @@ c-bind-special-erase-keys
     ;; directly, and use `delete-forward-p' to decide what [delete]
     ;; should do.  That's done in the XEmacs specific
     ;; `c-electric-delete' and `c-hungry-delete' functions.
-    (define-key c-mode-base-map [delete]    'c-electric-delete)
-    (define-key c-mode-base-map [backspace] 'c-electric-backspace)
-    (define-key c-mode-base-map (kbd "C-c <delete>") 'c-hungry-delete)
-    (define-key c-mode-base-map (kbd "C-c C-<delete>") 'c-hungry-delete)
+    (define-key c-mode-base-map [delete]    #'c-electric-delete)
+    (define-key c-mode-base-map [backspace] #'c-electric-backspace)
+    (define-key c-mode-base-map (kbd "C-c <delete>") #'c-hungry-delete)
+    (define-key c-mode-base-map (kbd "C-c C-<delete>") #'c-hungry-delete)
     (define-key c-mode-base-map (kbd "C-c <backspace>")
-      'c-hungry-delete-backwards)
+      #'c-hungry-delete-backwards)
     (define-key c-mode-base-map (kbd "C-c C-<backspace>")
-      'c-hungry-delete-backwards))
-
-  (define-key c-mode-base-map "#"         'c-electric-pound)
-  (define-key c-mode-base-map "{"         'c-electric-brace)
-  (define-key c-mode-base-map "}"         'c-electric-brace)
-  (define-key c-mode-base-map "/"         'c-electric-slash)
-  (define-key c-mode-base-map "*"         'c-electric-star)
-  (define-key c-mode-base-map ";"         'c-electric-semi&comma)
-  (define-key c-mode-base-map ","         'c-electric-semi&comma)
-  (define-key c-mode-base-map ":"         'c-electric-colon)
-  (define-key c-mode-base-map "("         'c-electric-paren)
-  (define-key c-mode-base-map ")"         'c-electric-paren)
-
-  (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
-  (define-key c-mode-base-map "\C-c\C-a"  'c-toggle-auto-newline)
-  (define-key c-mode-base-map "\C-c\C-b"  'c-submit-bug-report)
-  (define-key c-mode-base-map "\C-c\C-c"  'comment-region)
-  (define-key c-mode-base-map "\C-c\C-l"  'c-toggle-electric-state)
-  (define-key c-mode-base-map "\C-c\C-o"  'c-set-offset)
-  (define-key c-mode-base-map "\C-c\C-q"  'c-indent-defun)
-  (define-key c-mode-base-map "\C-c\C-s"  'c-show-syntactic-information)
-  ;; (define-key c-mode-base-map "\C-c\C-t"  'c-toggle-auto-hungry-state)  Commented out by ACM, 2005-03-05.
-  (define-key c-mode-base-map "\C-c."     'c-set-style)
+      #'c-hungry-delete-backwards))
+
+  (define-key c-mode-base-map "#"         #'c-electric-pound)
+  (define-key c-mode-base-map "{"         #'c-electric-brace)
+  (define-key c-mode-base-map "}"         #'c-electric-brace)
+  (define-key c-mode-base-map "/"         #'c-electric-slash)
+  (define-key c-mode-base-map "*"         #'c-electric-star)
+  (define-key c-mode-base-map ";"         #'c-electric-semi&comma)
+  (define-key c-mode-base-map ","         #'c-electric-semi&comma)
+  (define-key c-mode-base-map ":"         #'c-electric-colon)
+  (define-key c-mode-base-map "("         #'c-electric-paren)
+  (define-key c-mode-base-map ")"         #'c-electric-paren)
+
+  (define-key c-mode-base-map "\C-c\C-\\" #'c-backslash-region)
+  (define-key c-mode-base-map "\C-c\C-a"  #'c-toggle-auto-newline)
+  (define-key c-mode-base-map "\C-c\C-b"  #'c-submit-bug-report)
+  (define-key c-mode-base-map "\C-c\C-c"  #'comment-region)
+  (define-key c-mode-base-map "\C-c\C-l"  #'c-toggle-electric-state)
+  (define-key c-mode-base-map "\C-c\C-o"  #'c-set-offset)
+  (define-key c-mode-base-map "\C-c\C-q"  #'c-indent-defun)
+  (define-key c-mode-base-map "\C-c\C-s"  #'c-show-syntactic-information)
+  ;; (define-key c-mode-base-map "\C-c\C-t"  #'c-toggle-auto-hungry-state)  Commented out by ACM, 2005-03-05.
+  (define-key c-mode-base-map "\C-c."     #'c-set-style)
   ;; conflicts with OOBR
-  ;;(define-key c-mode-base-map "\C-c\C-v"  'c-version)
-  ;; (define-key c-mode-base-map "\C-c\C-y"  'c-toggle-hungry-state)  Commented out by ACM, 2005-11-22.
+  ;;(define-key c-mode-base-map "\C-c\C-v"  #'c-version)
+  ;; (define-key c-mode-base-map "\C-c\C-y"  #'c-toggle-hungry-state)  Commented out by ACM, 2005-11-22.
   (define-key c-mode-base-map "\C-c\C-w"
     (if (fboundp 'c-subword-mode) #'c-subword-mode #'subword-mode))
-  (define-key c-mode-base-map "\C-c\C-k" 'c-toggle-comment-style)
-  (define-key c-mode-base-map "\C-c\C-z" 'c-display-defun-name))
+  (define-key c-mode-base-map "\C-c\C-k" #'c-toggle-comment-style)
+  (define-key c-mode-base-map "\C-c\C-z" #'c-display-defun-name))
 
 ;; We don't require the outline package, but we configure it a bit anyway.
 (cc-bytecomp-defvar outline-level)
@@ -619,12 +619,12 @@ c-basic-common-init
 
   ;; now set their values
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
-  (set (make-local-variable 'indent-line-function) 'c-indent-line)
-  (set (make-local-variable 'indent-region-function) 'c-indent-region)
-  (set (make-local-variable 'normal-auto-fill-function) 'c-do-auto-fill)
+  (set (make-local-variable 'indent-line-function) #'c-indent-line)
+  (set (make-local-variable 'indent-region-function) #'c-indent-region)
+  (set (make-local-variable 'normal-auto-fill-function) #'c-do-auto-fill)
   (set (make-local-variable 'comment-multi-line) t)
   (set (make-local-variable 'comment-line-break-function)
-       'c-indent-new-comment-line)
+       #'c-indent-new-comment-line)
 
   ;; Prevent time-wasting activity on C-y.
   (when (boundp 'yank-handled-properties)
@@ -640,7 +640,7 @@ c-basic-common-init
   ;; Install `c-fill-paragraph' on `fill-paragraph-function' so that a
   ;; direct call to `fill-paragraph' behaves better.  This still
   ;; doesn't work with filladapt but it's better than nothing.
-  (set (make-local-variable 'fill-paragraph-function) 'c-fill-paragraph)
+  (set (make-local-variable 'fill-paragraph-function) #'c-fill-paragraph)
 
   ;; Initialize the cache for `c-looking-at-or-maybe-in-bracelist'.
   (setq c-laomib-cache nil)
@@ -717,7 +717,7 @@ c-basic-common-init
   (setq c-offsets-alist (copy-alist c-offsets-alist))
 
   ;; setup the comment indent variable in an Emacs version portable way
-  (set (make-local-variable 'comment-indent-function) 'c-comment-indent)
+  (set (make-local-variable 'comment-indent-function) #'c-comment-indent)
   ;; What sort of comments are default for M-;?
   (setq c-block-comment-flag c-block-comment-is-default)
 
@@ -742,15 +742,15 @@ c-basic-common-init
   (when (featurep 'xemacs)
     (make-local-hook 'before-change-functions)
     (make-local-hook 'after-change-functions))
-  (add-hook 'before-change-functions 'c-before-change nil t)
+  (add-hook 'before-change-functions #'c-before-change nil t)
   (setq c-just-done-before-change nil)
   ;; FIXME: We should use the new `depth' arg in Emacs-27 (e.g. a depth of -10
   ;; would do since font-lock uses a(n implicit) depth of 0) so we don't need
   ;; c-after-font-lock-init.
-  (add-hook 'after-change-functions 'c-after-change nil t)
+  (add-hook 'after-change-functions #'c-after-change nil t)
   (when (boundp 'font-lock-extend-after-change-region-function)
     (set (make-local-variable 'font-lock-extend-after-change-region-function)
-         'c-extend-after-change-region))) ; Currently (2009-05) used by all
+         #'c-extend-after-change-region))) ; Currently (2009-05) used by all
                           ; languages with #define (C, C++,; ObjC), and by AWK.
 
 (defun c-setup-doc-comment-style ()
@@ -816,7 +816,7 @@ c-common-init
 	      c-before-font-lock-functions))))
 
   (set (make-local-variable 'outline-regexp) "[^#\n\^M]")
-  (set (make-local-variable 'outline-level) 'c-outline-level)
+  (set (make-local-variable 'outline-level) #'c-outline-level)
   (set (make-local-variable 'add-log-current-defun-function)
        (lambda ()
 	 (or (c-cpp-define-name) (car (c-defun-name-and-limits nil)))))
@@ -965,8 +965,8 @@ c-postprocess-file-styles
 	  nil))))
 
 (if (boundp 'before-hack-local-variables-hook)
-    (add-hook 'before-hack-local-variables-hook 'c-before-hack-hook)
-  (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles))
+    (add-hook 'before-hack-local-variables-hook #'c-before-hack-hook)
+  (add-hook 'hack-local-variables-hook #'c-postprocess-file-styles))
 
 (defmacro c-run-mode-hooks (&rest hooks)
   ;; Emacs 21.1 has introduced a system with delayed mode hooks that
@@ -2473,15 +2473,15 @@ c-font-lock-init
   ;; Emacs bug #19669.
   (when (boundp 'font-lock-extend-region-functions)
     (setq font-lock-extend-region-functions
-	  (delq 'font-lock-extend-region-wholelines
+	  (delq #'font-lock-extend-region-wholelines
 		font-lock-extend-region-functions)))
 
   (make-local-variable 'font-lock-fontify-region-function)
-  (setq font-lock-fontify-region-function 'c-font-lock-fontify-region)
+  (setq font-lock-fontify-region-function #'c-font-lock-fontify-region)
 
   (if (featurep 'xemacs)
       (make-local-hook 'font-lock-mode-hook))
-  (add-hook 'font-lock-mode-hook 'c-after-font-lock-init nil t))
+  (add-hook 'font-lock-mode-hook #'c-after-font-lock-init nil t))
 
 ;; Emacs 22 and later.
 (defun c-extend-after-change-region (beg end _old-len)
@@ -2571,7 +2571,7 @@ c-mode-map
     map)
   "Keymap used in c-mode buffers.")
 ;; Add bindings which are only useful for C.
-(define-key c-mode-map "\C-c\C-e"  'c-macro-expand)
+(define-key c-mode-map "\C-c\C-e"  #'c-macro-expand)
 
 
 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
@@ -2634,7 +2634,7 @@ c-mode
   (when (featurep 'xemacs)
     (easy-menu-add c-c-menu))
   (cc-imenu-init cc-imenu-c-generic-expression)
-  (add-hook 'flymake-diagnostic-functions 'flymake-cc nil t)
+  (add-hook 'flymake-diagnostic-functions #'flymake-cc nil t)
   (c-run-mode-hooks 'c-mode-common-hook))
 
 (defconst c-or-c++-mode--regexp
@@ -2692,10 +2692,10 @@ c++-mode-map
     map)
   "Keymap used in c++-mode buffers.")
 ;; Add bindings which are only useful for C++.
-(define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
-(define-key c++-mode-map "\C-c:"    'c-scope-operator)
-(define-key c++-mode-map "<"        'c-electric-lt-gt)
-(define-key c++-mode-map ">"        'c-electric-lt-gt)
+(define-key c++-mode-map "\C-c\C-e" #'c-macro-expand)
+(define-key c++-mode-map "\C-c:"    #'c-scope-operator)
+(define-key c++-mode-map "<"        #'c-electric-lt-gt)
+(define-key c++-mode-map ">"        #'c-electric-lt-gt)
 
 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
 		  (cons "C++" (c-lang-const c-mode-menu c++)))
@@ -2726,7 +2726,7 @@ c++-mode
   (when (featurep 'xemacs)
     (easy-menu-add c-c++-menu))
   (cc-imenu-init cc-imenu-c++-generic-expression)
-  (add-hook 'flymake-diagnostic-functions 'flymake-cc nil t)
+  (add-hook 'flymake-diagnostic-functions #'flymake-cc nil t)
   (c-run-mode-hooks 'c-mode-common-hook))
 
 \f
@@ -2741,7 +2741,7 @@ objc-mode-map
     map)
   "Keymap used in objc-mode buffers.")
 ;; Add bindings which are only useful for Objective-C.
-(define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)
+(define-key objc-mode-map "\C-c\C-e" #'c-macro-expand)
 
 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
 		  (cons "ObjC" (c-lang-const c-mode-menu objc)))
@@ -2882,7 +2882,7 @@ pike-mode-map
     map)
   "Keymap used in pike-mode buffers.")
 ;; Additional bindings.
-(define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)
+(define-key pike-mode-map "\C-c\C-e" #'c-macro-expand)
 
 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
 		  (cons "Pike" (c-lang-const c-mode-menu pike)))
@@ -2929,17 +2929,22 @@ awk-mode-map
   (let ((map (c-make-inherited-keymap)))
     map)
   "Keymap used in awk-mode buffers.")
+;; FIXME: Maybe we should move `awk-mode-map' and `awk-mode' to `cc-awk.el'
+;; to avoid the need for these `declare-function's as well as the
+;; `awk-mode-syntax-table' workaround in `awk-mode'.
+(declare-function c-awk-end-of-defun "cc-awk" (&optional arg))
+(declare-function c-awk-beginning-of-defun "cc-awk" (&optional arg))
 ;; Add bindings which are only useful for awk.
-(define-key awk-mode-map "#" 'self-insert-command);Overrides electric parent binding.
-(define-key awk-mode-map "/" 'self-insert-command);Overrides electric parent binding.
-(define-key awk-mode-map "*" 'self-insert-command);Overrides electric parent binding.
-(define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
-(define-key awk-mode-map "\C-c\C-p" 'undefined)
-(define-key awk-mode-map "\C-c\C-u" 'undefined)
-(define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
-(define-key awk-mode-map "\M-e" 'c-end-of-statement)       ; 2003/10/7
-(define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun)
-(define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun)
+(define-key awk-mode-map "#" #'self-insert-command);Overrides electric parent binding.
+(define-key awk-mode-map "/" #'self-insert-command);Overrides electric parent binding.
+(define-key awk-mode-map "*" #'self-insert-command);Overrides electric parent binding.
+(define-key awk-mode-map "\C-c\C-n" #'undefined) ; #if doesn't exist in awk.
+(define-key awk-mode-map "\C-c\C-p" #'undefined)
+(define-key awk-mode-map "\C-c\C-u" #'undefined)
+(define-key awk-mode-map "\M-a"     #'c-beginning-of-statement) ; 2003/10/7
+(define-key awk-mode-map "\M-e"     #'c-end-of-statement)       ; 2003/10/7
+(define-key awk-mode-map "\C-\M-a"  #'c-awk-beginning-of-defun)
+(define-key awk-mode-map "\C-\M-e"  #'c-awk-end-of-defun)
 
 (easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
 		  (cons "AWK" (c-lang-const c-mode-menu awk)))
diff --git a/lisp/progmodes/cc-styles.el b/lisp/progmodes/cc-styles.el
index f2ebaa48f3..0022da2fe0 100644
--- a/lisp/progmodes/cc-styles.el
+++ b/lisp/progmodes/cc-styles.el
@@ -450,7 +450,7 @@ c-read-offset
     ;; In principle completing-read is used here, but SPC is unbound
     ;; to make it less annoying to enter lists.
     (set-keymap-parent keymap minibuffer-local-completion-map)
-    (define-key keymap " " 'self-insert-command)
+    (define-key keymap " " #'self-insert-command)
     (while (not offset)
       (setq input (read-from-minibuffer prompt nil keymap t
 					'c-read-offset-history
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 88ee092da7..6537104aaa 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -330,7 +330,7 @@ c-syntactic-indentation
   :type 'boolean
   :group 'c)
 (make-variable-buffer-local 'c-syntactic-indentation)
-(put 'c-syntactic-indentation 'safe-local-variable 'booleanp)
+(put 'c-syntactic-indentation 'safe-local-variable #'booleanp)
 
 (defcustom c-syntactic-indentation-in-macros t
   "Enable syntactic analysis inside macros.
-- 
2.30.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-lisp-progmodes-cc-.el-Activate-lexical-binding.patch --]
[-- Type: text/x-diff, Size: 6165 bytes --]

From cbb9065cf852490077bef077d9265f265bb260ac Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Mon, 5 Apr 2021 14:16:50 -0400
Subject: [PATCH 4/4] * lisp/progmodes/cc-*.el: Activate lexical-binding

---
 lisp/progmodes/cc-align.el    | 2 +-
 lisp/progmodes/cc-awk.el      | 2 +-
 lisp/progmodes/cc-bytecomp.el | 2 +-
 lisp/progmodes/cc-cmds.el     | 2 +-
 lisp/progmodes/cc-defs.el     | 2 +-
 lisp/progmodes/cc-engine.el   | 2 +-
 lisp/progmodes/cc-fonts.el    | 2 +-
 lisp/progmodes/cc-guess.el    | 2 +-
 lisp/progmodes/cc-langs.el    | 2 +-
 lisp/progmodes/cc-menus.el    | 2 +-
 lisp/progmodes/cc-mode.el     | 2 +-
 lisp/progmodes/cc-styles.el   | 2 +-
 lisp/progmodes/cc-vars.el     | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el
index 51d51deef7..840360b089 100644
--- a/lisp/progmodes/cc-align.el
+++ b/lisp/progmodes/cc-align.el
@@ -1,4 +1,4 @@
-;;; cc-align.el --- custom indentation functions for CC Mode
+;;; cc-align.el --- custom indentation functions for CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el
index 3228944372..363ae481e2 100644
--- a/lisp/progmodes/cc-awk.el
+++ b/lisp/progmodes/cc-awk.el
@@ -1,4 +1,4 @@
-;;; cc-awk.el --- AWK specific code within cc-mode.
+;;; cc-awk.el --- AWK specific code within cc-mode.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1988, 1994, 1996, 2000-2021 Free Software Foundation,
 ;; Inc.
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el
index 3f7caf3c2e..610a3a7b20 100644
--- a/lisp/progmodes/cc-bytecomp.el
+++ b/lisp/progmodes/cc-bytecomp.el
@@ -1,4 +1,4 @@
-;;; cc-bytecomp.el --- compile time setup for proper compilation
+;;; cc-bytecomp.el --- compile time setup for proper compilation  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2000-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index c1c7916309..33fab3e5a6 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1,4 +1,4 @@
-;;; cc-cmds.el --- user level commands for CC Mode
+;;; cc-cmds.el --- user level commands for CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 9e17356d59..c6a7a001a5 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -1,4 +1,4 @@
-;;; cc-defs.el --- compile time definitions for CC Mode
+;;; cc-defs.el --- compile time definitions for CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 35f9146116..99edbc79b4 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1,4 +1,4 @@
-;;; cc-engine.el --- core syntax guessing engine for CC mode -*- coding: utf-8 -*-
+;;; cc-engine.el --- core syntax guessing engine for CC mode -*- coding: utf-8; lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 8ac51be170..62d6674016 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1,4 +1,4 @@
-;;; cc-fonts.el --- font lock support for CC Mode
+;;; cc-fonts.el --- font lock support for CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2002-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-guess.el b/lisp/progmodes/cc-guess.el
index 1b852ec491..d1a7008885 100644
--- a/lisp/progmodes/cc-guess.el
+++ b/lisp/progmodes/cc-guess.el
@@ -1,4 +1,4 @@
-;;; cc-guess.el --- guess indentation values by scanning existing code
+;;; cc-guess.el --- guess indentation values by scanning existing code  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2006, 2011-2021 Free Software
 ;; Foundation, Inc.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 9edef527d8..f61c8f530c 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1,4 +1,4 @@
-;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 -*-
+;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8; lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-menus.el b/lisp/progmodes/cc-menus.el
index 0ff6efb7d3..82524d7a81 100644
--- a/lisp/progmodes/cc-menus.el
+++ b/lisp/progmodes/cc-menus.el
@@ -1,4 +1,4 @@
-;;; cc-menus.el --- imenu support for CC Mode
+;;; cc-menus.el --- imenu support for CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index c7fc0db05c..0761a3fb20 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1,4 +1,4 @@
-;;; cc-mode.el --- major mode for editing C and similar languages
+;;; cc-mode.el --- major mode for editing C and similar languages  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-styles.el b/lisp/progmodes/cc-styles.el
index 0022da2fe0..51530d3c92 100644
--- a/lisp/progmodes/cc-styles.el
+++ b/lisp/progmodes/cc-styles.el
@@ -1,4 +1,4 @@
-;;; cc-styles.el --- support for styles in CC Mode
+;;; cc-styles.el --- support for styles in CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 6537104aaa..c17d60e275 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -1,4 +1,4 @@
-;;; cc-vars.el --- user customization variables for CC Mode
+;;; cc-vars.el --- user customization variables for CC Mode  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 1987, 1992-2021 Free Software Foundation, Inc.
 
-- 
2.30.2


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

* Re: lexical-binding in CC-mode
  2021-04-05 18:38 lexical-binding in CC-mode Stefan Monnier
@ 2021-04-06 16:19 ` Alan Mackenzie
  2021-04-06 16:49   ` Stefan Monnier
  2021-04-06 18:42   ` Dmitry Gutov
  2021-04-10 19:47 ` Alan Mackenzie
  1 sibling, 2 replies; 7+ messages in thread
From: Alan Mackenzie @ 2021-04-06 16:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bug-cc-mode, emacs-devel

Hello, Stefan.

On Mon, Apr 05, 2021 at 14:38:08 -0400, Stefan Monnier wrote:
> Hi Alan,

> We're getting to the last few remaining ELisp files in Emacs still using
> the old non-lexical dialect, so I looked at converting CC-mode to use
> the new dialect as well.  AFAICT the code is basically already prepared
> for that, tho I did find some minor things in the patch below.

OK, it seems this can't be put off any longer.  ;-)

I've been experimenting with lexical-binding in CC Mode for about two
years, now.  There's no real advantage in l-b for it, but no real
disadvantages, either.

The only thing I worry about is that l-b might not work properly in a
previous Emacs release (for standalone CC Mode), and there doesn't
appear to be a way of switching it on/off according to any criterion.
In particular, the following doesn't seem to work, neither in Emacs 25.3
or Emacs 28:

    -*- eval: (setq lexical-binding (>= emacs-major-version 26)) -*-

..  That incantation leaves lexical-binding at nil, regardless of Emacs
version.

> Of course, the change should be fully backward compatible (i.e. the
> code sticks to the common subset of the two dialects).

Do closures (for lambda forms) work in Emacs 25 and earlier?

> See below the result of my attempt in the form of 4 patches.
> 0001 and 0004 are the important ones.  0002 makes the code more regular
> (you already use `declare` at various places, so I think it's good to
> use it more systematically).  0003 is largely a question of taste (and we
> know we don't always agree on that), but I like the warnings it gives me
> when a function is marked obsolete or when I make a typo.

Thanks.

> As usual, take the parts you like,

OK, I'll get it done in the next day or two.

>         Stefan

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: lexical-binding in CC-mode
  2021-04-06 16:19 ` Alan Mackenzie
@ 2021-04-06 16:49   ` Stefan Monnier
  2021-04-06 18:42   ` Dmitry Gutov
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2021-04-06 16:49 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: bug-cc-mode, emacs-devel

> The only thing I worry about is that l-b might not work properly in a
> previous Emacs release (for standalone CC Mode), and there doesn't
> appear to be a way of switching it on/off according to any criterion.
> In particular, the following doesn't seem to work, neither in Emacs 25.3
> or Emacs 28:
>
>     -*- eval: (setq lexical-binding (>= emacs-major-version 26)) -*-
>
> ..  That incantation leaves lexical-binding at nil, regardless of Emacs
> version.

Indeed, there's no such thing.  As always it's possible to work
something out if really needed, but the equivalent of the intended
behavior above is pretty cumbersome to obtain, so in all likelihood if
a need for something like this comes up, we'd want to find a different
workaround (e.g. by changing the code).

>> Of course, the change should be fully backward compatible (i.e. the
>> code sticks to the common subset of the two dialects).
> Do closures (for lambda forms) work in Emacs 25 and earlier?

Yes, they do.
There have a been a few changes that can impact compatibility, but
they've been rather minor.  The only ones I can think of are:
- performance (IIRC both for `condition-case` and for `unwind-protect`,
  the performance of lexical code was slightly improved in Emacs-25,
  and the cost of closure-creation ).
- `defun` could not refer to surrounding lexical variables in
  Emacs<24.3.  It's rare to nest `defun` within a `let` or another
  function, so it only affects very rare cases and these can be
  rewritten to use `defalias+lambda` if needed.
- I think there were a few bugs where macros could not rely on the
  value of `lexical-binding` to know if the returned code would be using
  the lexical dialect or not and these were fixed sometime before
  Emacs-25.  That's only relevant for the rare macros which want to generate
  different code for the different dialects (in most cases it's used to
  signal an error when the generated code only works with lexical-binding).

So I'm quite hopeful that there won't be any backward compatibility
issue for CC-mode in this respect.


        Setfan




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

* Re: lexical-binding in CC-mode
  2021-04-06 16:19 ` Alan Mackenzie
  2021-04-06 16:49   ` Stefan Monnier
@ 2021-04-06 18:42   ` Dmitry Gutov
  2021-04-06 20:35     ` Filipp Gunbin
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2021-04-06 18:42 UTC (permalink / raw)
  To: Alan Mackenzie, Stefan Monnier; +Cc: bug-cc-mode, emacs-devel

On 06.04.2021 19:19, Alan Mackenzie wrote:
>> Of course, the change should be fully backward compatible (i.e. the
>> code sticks to the common subset of the two dialects).
> Do closures (for lambda forms) work in Emacs 25 and earlier?
> 

Have you considered making Emacs 25 the minimum version, BTW?

I have recently raised the Emacs version requirement on a couple of my 
packages (ones that, arguably, any user should be able to access), and 
have yet to receive any complaints.



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

* Re: lexical-binding in CC-mode
  2021-04-06 18:42   ` Dmitry Gutov
@ 2021-04-06 20:35     ` Filipp Gunbin
  0 siblings, 0 replies; 7+ messages in thread
From: Filipp Gunbin @ 2021-04-06 20:35 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: bug-cc-mode, Alan Mackenzie, Stefan Monnier, emacs-devel

On 06/04/2021 21:42 +0300, Dmitry Gutov wrote:

> Have you considered making Emacs 25 the minimum version, BTW?

... And maybe dropping XEmacs support.



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

* Re: lexical-binding in CC-mode
  2021-04-05 18:38 lexical-binding in CC-mode Stefan Monnier
  2021-04-06 16:19 ` Alan Mackenzie
@ 2021-04-10 19:47 ` Alan Mackenzie
  2021-04-10 20:21   ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2021-04-10 19:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bug-cc-mode, emacs-devel

Hello, Stefan.

On Mon, Apr 05, 2021 at 14:38:08 -0400, Stefan Monnier wrote:
> Hi Alan,

> We're getting to the last few remaining ELisp files in Emacs still using
> the old non-lexical dialect, so I looked at converting CC-mode to use
> the new dialect as well.  AFAICT the code is basically already prepared
> for that, tho I did find some minor things in the patch below.

The conversion to lexical-binding is now (?)complete and committed to
master.

> Of course, the change should be fully backward compatible (i.e. the
> code sticks to the common subset of the two dialects).

I tried CC Mode (lexical) out with Emacs 24.5, and like you intimated,
it seems to have no problems there.

> See below the result of my attempt in the form of 4 patches.
> 0001 and 0004 are the important ones.  0002 makes the code more regular
> (you already use `declare` at various places, so I think it's good to
> use it more systematically).  0003 is largely a question of taste (and we
> know we don't always agree on that), but I like the warnings it gives me
> when a function is marked obsolete or when I make a typo.

These two patches, one moving edebug specs to `declare' forms, the other
putting #' rather than ' before function names, I haven't done, yet.
Creating them must have been quite a bit of work, so thanks!  Both of
these features are in XEmacs (as I'm sure you've already checked), so
there's nothing much holding me back applying them.

> As usual, take the parts you like,

:-)

>         Stefan

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: lexical-binding in CC-mode
  2021-04-10 19:47 ` Alan Mackenzie
@ 2021-04-10 20:21   ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2021-04-10 20:21 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: bug-cc-mode, emacs-devel

>> We're getting to the last few remaining ELisp files in Emacs still using
>> the old non-lexical dialect, so I looked at converting CC-mode to use
>> the new dialect as well.  AFAICT the code is basically already prepared
>> for that, tho I did find some minor things in the patch below.
>
> The conversion to lexical-binding is now (?)complete and committed to
> master.

Great, thank you.


        Stefan




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

end of thread, other threads:[~2021-04-10 20:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-05 18:38 lexical-binding in CC-mode Stefan Monnier
2021-04-06 16:19 ` Alan Mackenzie
2021-04-06 16:49   ` Stefan Monnier
2021-04-06 18:42   ` Dmitry Gutov
2021-04-06 20:35     ` Filipp Gunbin
2021-04-10 19:47 ` Alan Mackenzie
2021-04-10 20:21   ` Stefan Monnier

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).