From 040c03cae2db361d2e014a52d969a6b0ebc48f1c Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 25 Jun 2022 14:58:01 +0200 Subject: Make `M-q' work on the first line of a multi-line string again * lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): Exclude the quote marks from the region so that filling works (bug#56197). --- lisp/emacs-lisp/lisp-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index aaec13d1afc..781c80fd5a0 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -1481,8 +1481,8 @@ and initial semicolons." (progn (forward-sexp 1) t)) - (narrow-to-region (ppss-comment-or-string-start ppss) - (point)))) + (narrow-to-region (1+ (ppss-comment-or-string-start ppss)) + (1- (point))))) ;; Move back to where we were. (goto-char start) (fill-paragraph justify))))))) -- cgit v1.2.3 From 8f5d9d0abd0f5078646bc85c7a4d480b32057a47 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 26 Jun 2022 16:31:33 +0200 Subject: Fix a recent Lisp mode filling test failure * lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): Restore the "fill first line separately" logic. --- lisp/emacs-lisp/lisp-mode.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 781c80fd5a0..6d5391d1e90 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -1426,6 +1426,9 @@ and initial semicolons." ;; a comment: Point is on a program line; we are interested ;; particularly in docstring lines. ;; + ;; FIXME: The below bindings are probably mostly irrelevant + ;; since we're now narrowing to a region before filling. + ;; ;; We bind `paragraph-start' and `paragraph-separate' temporarily. They ;; are buffer-local, but we avoid changing them so that they can be set ;; to make `forward-paragraph' and friends do something the user wants. @@ -1485,6 +1488,15 @@ and initial semicolons." (1- (point))))) ;; Move back to where we were. (goto-char start) + ;; We should fill the first line of a string + ;; separately (since it's usually a doc string). + (if (= (line-number-at-pos) 1) + (narrow-to-region (line-beginning-position) + (line-beginning-position 2)) + (save-excursion + (goto-char (point-min)) + (forward-line 1) + (narrow-to-region (point) (point-max)))) (fill-paragraph justify))))))) ;; Never return nil. t) -- cgit v1.2.3 From 3b66c23325909fef077831c5f289221583e75bd7 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 2 Jul 2022 05:35:15 +0200 Subject: Font lock \\`' command substitutions in docstrings * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2): Support \\`' command substitutions. --- lisp/emacs-lisp/lisp-mode.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 6d5391d1e90..3797217e1a0 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -476,8 +476,14 @@ This will generate compile-time constants from BINDINGS." "[ \t']*\\(" lisp-mode-symbol-regexp "\\)?") (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) - ;; Words inside \\[] tend to be for `substitute-command-keys'. - (,(concat "\\\\\\\\\\[\\(" lisp-mode-symbol-regexp "\\)\\]") + ;; Words inside \\[] or \\`' tend to be for `substitute-command-keys'. + (,(rx "\\\\[" (group (regexp lisp-mode-symbol-regexp)) "]") + (1 font-lock-constant-face prepend)) + (,(rx "\\\\`" (group + (+ (regexp lisp-mode-symbol-regexp) + ;; allow multiple words, e.g. "C-x a" + (? " "))) + "'") (1 font-lock-constant-face prepend)) ;; Ineffective backslashes (typically in need of doubling). ("\\(\\\\\\)\\([^\"\\]\\)" -- cgit v1.2.3 From b000bd47a6efbd12cab6e6a1b19a59014931abd8 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 3 Jul 2022 20:59:00 +0200 Subject: Font lock \\<> and \\{} command substitutions in docstrings * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2): Support \\<> and \\{} command substitutions. --- lisp/emacs-lisp/lisp-mode.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 3797217e1a0..ac56d423391 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -476,9 +476,13 @@ This will generate compile-time constants from BINDINGS." "[ \t']*\\(" lisp-mode-symbol-regexp "\\)?") (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) - ;; Words inside \\[] or \\`' tend to be for `substitute-command-keys'. + ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for + ;; `substitute-command-keys'. (,(rx "\\\\[" (group (regexp lisp-mode-symbol-regexp)) "]") (1 font-lock-constant-face prepend)) + (,(rx "\\\\" (or (seq "<" (group-n 1 (regexp lisp-mode-symbol-regexp)) ">") + (seq "{" (group-n 1 (regexp lisp-mode-symbol-regexp)) "}"))) + (1 font-lock-variable-name-face prepend)) (,(rx "\\\\`" (group (+ (regexp lisp-mode-symbol-regexp) ;; allow multiple words, e.g. "C-x a" -- cgit v1.2.3 From ae3416d69431fe80e767813bfe9837df599eca98 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 3 Jul 2022 23:05:50 +0200 Subject: Simplify lisp-el-font-lock-keywords-2 definition slightly * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2): Simplify slightly. --- lisp/emacs-lisp/lisp-mode.el | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index ac56d423391..d61432b7ddf 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -478,17 +478,15 @@ This will generate compile-time constants from BINDINGS." (2 font-lock-constant-face nil t)) ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for ;; `substitute-command-keys'. - (,(rx "\\\\[" (group (regexp lisp-mode-symbol-regexp)) "]") + (,(rx "\\\\" (or (seq "[" (group-n 1 (regexp lisp-mode-symbol-regexp)) "]") + (seq "`" (group-n 1 (+ (regexp lisp-mode-symbol-regexp) + ;; allow multiple words, e.g. "C-x a" + (? " "))) + "'"))) (1 font-lock-constant-face prepend)) (,(rx "\\\\" (or (seq "<" (group-n 1 (regexp lisp-mode-symbol-regexp)) ">") (seq "{" (group-n 1 (regexp lisp-mode-symbol-regexp)) "}"))) (1 font-lock-variable-name-face prepend)) - (,(rx "\\\\`" (group - (+ (regexp lisp-mode-symbol-regexp) - ;; allow multiple words, e.g. "C-x a" - (? " "))) - "'") - (1 font-lock-constant-face prepend)) ;; Ineffective backslashes (typically in need of doubling). ("\\(\\\\\\)\\([^\"\\]\\)" (1 (elisp--font-lock-backslash) prepend)) @@ -496,7 +494,7 @@ This will generate compile-time constants from BINDINGS." (,(concat "[`‘']\\(" lisp-mode-symbol-regexp "\\)['’]") (1 font-lock-constant-face prepend)) ;; \\= tends to be an escape in doc strings. - ("\\\\\\\\=" + (,(rx "\\\\=") (0 font-lock-builtin-face prepend)) ;; Constant values. (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>") -- cgit v1.2.3 From 544361d37f3877b2f10c362936a283f4a0b2fa71 Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Mon, 4 Jul 2022 14:12:24 +0200 Subject: Replace lisp-mode-symbol-regexp with (rx lisp-mode-symbol) This is shorter, simplifies use inside rx expressions, and removes need for eval-when-compile elsewhere (for later exploitation). * lisp/emacs-lisp/lisp-mode.el (lisp-mode-symbol): New rx-define. (lisp-mode-symbol-regexp): Redefine using lisp-mode-symbol. (lisp-imenu-generic-expression, lisp--el-match-keyword) (lisp-fdefs, lisp-string-in-doc-position-p): * lisp/emacs-lisp/checkdoc.el (checkdoc--error-bad-format-p): * lisp/emacs-lisp/shorthands.el (shorthands-font-lock-shorthands): Use lisp-mode-symbol instead of lisp-mode-symbol-regexp. --- lisp/emacs-lisp/checkdoc.el | 6 ++--- lisp/emacs-lisp/lisp-mode.el | 56 +++++++++++++++++++++++-------------------- lisp/emacs-lisp/shorthands.el | 2 +- 3 files changed, 34 insertions(+), 30 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 2cb5fa120e0..2c9adfe2d27 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -165,7 +165,7 @@ (require 'cl-lib) (require 'help-mode) ;; for help-xref-info-regexp (require 'thingatpt) ;; for handy thing-at-point-looking-at -(require 'lisp-mode) ;; for lisp-mode-symbol-regexp +(require 'lisp-mode) ;; for lisp-mode-symbol regexp (eval-when-compile (require 'dired)) ;; for dired-map-over-marks (require 'lisp-mnt) @@ -2604,13 +2604,13 @@ The correct format is \"Foo\" or \"some-symbol: Foo\". See also (unless (let ((case-fold-search nil)) (looking-at (rx (or upper-case "%s")))) ;; A defined Lisp symbol is always okay. - (unless (and (looking-at (rx (group (regexp lisp-mode-symbol-regexp)))) + (unless (and (looking-at (rx (group lisp-mode-symbol))) (or (fboundp (intern (match-string 1))) (boundp (intern (match-string 1))))) ;; Other Lisp symbols are sometimes okay. (rx-let ((c (? "\\\n"))) ; `c' is for a continued line (let ((case-fold-search nil) - (some-symbol (rx (regexp lisp-mode-symbol-regexp) + (some-symbol (rx lisp-mode-symbol c ":" c (+ (any " \t\n")))) (lowercase-str (rx c (group (any "a-z") (+ wordchar))))) (if (looking-at some-symbol) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index d61432b7ddf..ab572d57952 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -89,8 +89,12 @@ table) "Syntax table used in `lisp-mode'.") +(rx-define lisp-mode-symbol (+ (| (syntax word) + (syntax symbol) + (: "\\" nonl)))) + (eval-and-compile - (defconst lisp-mode-symbol-regexp "\\(?:\\sw\\|\\s_\\|\\\\.\\)+")) + (defconst lisp-mode-symbol-regexp (rx lisp-mode-symbol))) (defvar lisp-imenu-generic-expression (list @@ -117,7 +121,7 @@ ;; CLOS and EIEIO "defgeneric" "defmethod") t)) - "\\s-+\\(" lisp-mode-symbol-regexp "\\)")) + "\\s-+\\(" (rx lisp-mode-symbol) "\\)")) 2) ;; Like the previous, but uses a quoted symbol as the name. (list nil @@ -126,7 +130,7 @@ (regexp-opt '("defalias" "define-obsolete-function-alias") t)) - "\\s-+'\\(" lisp-mode-symbol-regexp "\\)")) + "\\s-+'\\(" (rx lisp-mode-symbol) "\\)")) 2) (list (purecopy "Variables") (purecopy (concat "^\\s-*(" @@ -138,12 +142,12 @@ "defconstant" "defparameter" "define-symbol-macro") t)) - "\\s-+\\(" lisp-mode-symbol-regexp "\\)")) + "\\s-+\\(" (rx lisp-mode-symbol) "\\)")) 2) ;; For `defvar'/`defvar-local', we ignore (defvar FOO) constructs. (list (purecopy "Variables") (purecopy (concat "^\\s-*(defvar\\(?:-local\\)?\\s-+\\(" - lisp-mode-symbol-regexp "\\)" + (rx lisp-mode-symbol) "\\)" "[[:space:]\n]+[^)]")) 1) (list (purecopy "Types") @@ -160,7 +164,7 @@ ;; CLOS and EIEIO "defclass") t)) - "\\s-+'?\\(" lisp-mode-symbol-regexp "\\)")) + "\\s-+'?\\(" (rx lisp-mode-symbol) "\\)")) 2)) "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") @@ -270,7 +274,7 @@ to a package-local -loaddefs.el file.") (catch 'found (while (re-search-forward (eval-when-compile - (concat "(\\(" lisp-mode-symbol-regexp "\\)\\_>")) + (concat "(\\(" (rx lisp-mode-symbol) "\\)\\_>")) limit t) (let ((sym (intern-soft (match-string 1)))) (when (and (or (special-form-p sym) (macrop sym)) @@ -419,8 +423,8 @@ This will generate compile-time constants from BINDINGS." ;; Any whitespace and defined object. "[ \t']*" "\\(([ \t']*\\)?" ;; An opening paren. - "\\(\\(setf\\)[ \t]+" lisp-mode-symbol-regexp - "\\|" lisp-mode-symbol-regexp "\\)?") + "\\(\\(setf\\)[ \t]+" (rx lisp-mode-symbol) + "\\|" (rx lisp-mode-symbol) "\\)?") (1 font-lock-keyword-face) (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) (cond ((eq type 'var) font-lock-variable-name-face) @@ -446,8 +450,8 @@ This will generate compile-time constants from BINDINGS." ;; Any whitespace and defined object. "[ \t']*" "\\(([ \t']*\\)?" ;; An opening paren. - "\\(\\(setf\\)[ \t]+" lisp-mode-symbol-regexp - "\\|" lisp-mode-symbol-regexp "\\)?") + "\\(\\(setf\\)[ \t]+" (rx lisp-mode-symbol) + "\\|" (rx lisp-mode-symbol) "\\)?") (1 font-lock-keyword-face) (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) (cond ((eq type 'var) font-lock-variable-name-face) @@ -473,34 +477,34 @@ This will generate compile-time constants from BINDINGS." (lisp--el-match-keyword . 1) ;; Exit/Feature symbols as constants. (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\_>" - "[ \t']*\\(" lisp-mode-symbol-regexp "\\)?") + "[ \t']*\\(" (rx lisp-mode-symbol) "\\)?") (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for ;; `substitute-command-keys'. - (,(rx "\\\\" (or (seq "[" (group-n 1 (regexp lisp-mode-symbol-regexp)) "]") - (seq "`" (group-n 1 (+ (regexp lisp-mode-symbol-regexp) + (,(rx "\\\\" (or (seq "[" (group-n 1 lisp-mode-symbol) "]") + (seq "`" (group-n 1 (+ lisp-mode-symbol ;; allow multiple words, e.g. "C-x a" (? " "))) "'"))) (1 font-lock-constant-face prepend)) - (,(rx "\\\\" (or (seq "<" (group-n 1 (regexp lisp-mode-symbol-regexp)) ">") - (seq "{" (group-n 1 (regexp lisp-mode-symbol-regexp)) "}"))) + (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) ">") + (seq "{" (group-n 1 lisp-mode-symbol) "}"))) (1 font-lock-variable-name-face prepend)) ;; Ineffective backslashes (typically in need of doubling). ("\\(\\\\\\)\\([^\"\\]\\)" (1 (elisp--font-lock-backslash) prepend)) ;; Words inside ‘’, '' and `' tend to be symbol names. - (,(concat "[`‘']\\(" lisp-mode-symbol-regexp "\\)['’]") + (,(concat "[`‘']\\(" (rx lisp-mode-symbol) "\\)['’]") (1 font-lock-constant-face prepend)) ;; \\= tends to be an escape in doc strings. (,(rx "\\\\=") (0 font-lock-builtin-face prepend)) ;; Constant values. - (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>") + (,(concat "\\_<:" (rx lisp-mode-symbol) "\\_>") (0 font-lock-builtin-face)) ;; ELisp and CLisp `&' keywords as types. - (,(concat "\\_<&" lisp-mode-symbol-regexp "\\_>") + (,(concat "\\_<&" (rx lisp-mode-symbol) "\\_>") . font-lock-type-face) ;; ELisp regexp grouping constructs (,(lambda (bound) @@ -537,30 +541,30 @@ This will generate compile-time constants from BINDINGS." (,(concat "(" cl-kws-re "\\_>") . 1) ;; Exit/Feature symbols as constants. (,(concat "(\\(catch\\|throw\\|provide\\|require\\)\\_>" - "[ \t']*\\(" lisp-mode-symbol-regexp "\\)?") + "[ \t']*\\(" (rx lisp-mode-symbol) "\\)?") (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) ;; Erroneous structures. (,(concat "(" cl-errs-re "\\_>") (1 font-lock-warning-face)) ;; Words inside ‘’ and `' tend to be symbol names. - (,(concat "[`‘]\\(" lisp-mode-symbol-regexp "\\)['’]") + (,(concat "[`‘]\\(" (rx lisp-mode-symbol) "\\)['’]") (1 font-lock-constant-face prepend)) ;; Uninterned symbols, e.g., (defpackage #:my-package ...) ;; must come before keywords below to have effect - (,(concat "#:" lisp-mode-symbol-regexp "") 0 font-lock-builtin-face) + (,(concat "#:" (rx lisp-mode-symbol) "") 0 font-lock-builtin-face) ;; Constant values. - (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>") + (,(concat "\\_<:" (rx lisp-mode-symbol) "\\_>") (0 font-lock-builtin-face)) ;; ELisp and CLisp `&' keywords as types. - (,(concat "\\_<&" lisp-mode-symbol-regexp "\\_>") + (,(concat "\\_<&" (rx lisp-mode-symbol) "\\_>") . font-lock-type-face) ;; This is too general -- rms. ;; A user complained that he has functions whose names start with `do' ;; and that they get the wrong color. ;; That user has violated the https://www.cliki.net/Naming+conventions: ;; CL (but not EL!) `with-' (context) and `do-' (iteration) - (,(concat "(\\(\\(do-\\|with-\\)" lisp-mode-symbol-regexp "\\)") + (,(concat "(\\(\\(do-\\|with-\\)" (rx lisp-mode-symbol) "\\)") (1 font-lock-keyword-face)) (lisp--match-hidden-arg (0 '(face font-lock-warning-face @@ -596,7 +600,7 @@ containing STARTPOS." (and (looking-at (eval-when-compile (concat "([ \t\n]*\\(" - lisp-mode-symbol-regexp "\\)"))) + (rx lisp-mode-symbol) "\\)"))) (match-string 1))))) (docelt (and firstsym (function-get (intern-soft firstsym) diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index a9e4343715c..75cbe5f1923 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -62,7 +62,7 @@ (when read-symbol-shorthands (while (re-search-forward (eval-when-compile - (concat "\\_<\\(" lisp-mode-symbol-regexp "\\)\\_>")) + (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>")) limit t) (let* ((existing (get-text-property (match-beginning 1) 'face)) (probe (and (not (memq existing '(font-lock-comment-face -- cgit v1.2.3 From 1268902db17501862e5efbd51a41108ffc5105f3 Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Mon, 4 Jul 2022 14:52:50 +0200 Subject: Remove some useless `eval-when-compile` * lisp/cedet/semantic/java.el (semantic-java-number-regexp): * lisp/cedet/semantic/lex.el (semantic-lex-number-expression): * lisp/emacs-lisp/cl-indent.el (common-lisp-indent-function-1): * lisp/emacs-lisp/lisp-mode.el (lisp-imenu-generic-expression) (lisp--el-match-keyword, lisp-string-in-doc-position-p): * lisp/emacs-lisp/shorthands.el (shorthands-font-lock-shorthands): * lisp/net/socks.el (socks-send-command): * lisp/progmodes/meta-mode.el (meta-font-lock-keywords): * lisp/shell.el (shell--parse-pcomplete-arguments): * lisp/textmodes/sgml-mode.el (sgml-mode): * lisp/textmodes/tex-mode.el (tex--guess-mode) (tex-common-initialization, tex-input-files-re): * lisp/textmodes/tildify.el (tildify-mode): * lisp/xdg.el (xdg-line-regexp): Eliminate `eval-when-compile` when the argument would be evaluated by the compiler anyway. --- lisp/cedet/semantic/java.el | 37 ++++++++--------- lisp/cedet/semantic/lex.el | 37 ++++++++--------- lisp/emacs-lisp/cl-indent.el | 7 ++-- lisp/emacs-lisp/lisp-mode.el | 96 ++++++++++++++++++++----------------------- lisp/emacs-lisp/shorthands.el | 3 +- lisp/net/socks.el | 9 ++-- lisp/progmodes/meta-mode.el | 41 +++++++++--------- lisp/shell.el | 11 +++-- lisp/textmodes/sgml-mode.el | 11 +++-- lisp/textmodes/tex-mode.el | 33 +++++++-------- lisp/textmodes/tildify.el | 5 +-- lisp/xdg.el | 13 +++--- 12 files changed, 141 insertions(+), 162 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/cedet/semantic/java.el b/lisp/cedet/semantic/java.el index 9b70afd0a33..53fd4de2975 100644 --- a/lisp/cedet/semantic/java.el +++ b/lisp/cedet/semantic/java.el @@ -37,25 +37,24 @@ ;;; Lexical analysis ;; (defconst semantic-java-number-regexp - (eval-when-compile - (concat "\\(" - "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" - "\\|" - "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" - "\\|" - "\\<[0-9]+[.][fFdD]\\>" - "\\|" - "\\<[0-9]+[.]" - "\\|" - "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" - "\\|" - "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" - "\\|" - "\\<0[xX][[:xdigit:]]+[lL]?\\>" - "\\|" - "\\<[0-9]+[lLfFdD]?\\>" - "\\)" - )) + (concat "\\(" + "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" + "\\|" + "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" + "\\|" + "\\<[0-9]+[.][fFdD]\\>" + "\\|" + "\\<[0-9]+[.]" + "\\|" + "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" + "\\|" + "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" + "\\|" + "\\<0[xX][[:xdigit:]]+[lL]?\\>" + "\\|" + "\\<[0-9]+[lLfFdD]?\\>" + "\\)" + ) "Lexer regexp to match Java number terminals. Following is the specification of Java number literals. diff --git a/lisp/cedet/semantic/lex.el b/lisp/cedet/semantic/lex.el index 885ffbf5a73..9c64cc9f7e5 100644 --- a/lisp/cedet/semantic/lex.el +++ b/lisp/cedet/semantic/lex.el @@ -574,25 +574,24 @@ may need to be overridden for some special languages.") (defvar-local semantic-lex-number-expression ;; This expression was written by David Ponce for Java, and copied ;; here for C and any other similar language. - (eval-when-compile - (concat "\\(" - "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" - "\\|" - "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" - "\\|" - "\\<[0-9]+[.][fFdD]\\>" - "\\|" - "\\<[0-9]+[.]" - "\\|" - "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" - "\\|" - "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" - "\\|" - "\\<0[xX][[:xdigit:]]+[lL]?\\>" - "\\|" - "\\<[0-9]+[lLfFdD]?\\>" - "\\)" - )) + (concat "\\(" + "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" + "\\|" + "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" + "\\|" + "\\<[0-9]+[.][fFdD]\\>" + "\\|" + "\\<[0-9]+[.]" + "\\|" + "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" + "\\|" + "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" + "\\|" + "\\<0[xX][[:xdigit:]]+[lL]?\\>" + "\\|" + "\\<[0-9]+[lLfFdD]?\\>" + "\\)" + ) "Regular expression for matching a number. If this value is nil, no number extraction is done during lex. This expression tries to match C and Java like numbers. diff --git a/lisp/emacs-lisp/cl-indent.el b/lisp/emacs-lisp/cl-indent.el index 213eecf88d4..fe7e4506d7c 100644 --- a/lisp/emacs-lisp/cl-indent.el +++ b/lisp/emacs-lisp/cl-indent.el @@ -378,10 +378,9 @@ instead." function) (setq tentative-defun t)) ((string-match - (eval-when-compile - (concat "\\`\\(" - (regexp-opt '("with" "without" "do")) - "\\)-")) + (concat "\\`\\(" + (regexp-opt '("with" "without" "do")) + "\\)-") function) (setq method '(&lambda &body)))))) ;; backwards compatibility. Bletch. diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index ab572d57952..888e3397199 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -100,48 +100,45 @@ (list (list nil (purecopy (concat "^\\s-*(" - (eval-when-compile - (regexp-opt - '("defun" "defmacro" - ;; Elisp. - "defun*" "defsubst" "define-inline" - "define-advice" "defadvice" "define-skeleton" - "define-compilation-mode" "define-minor-mode" - "define-global-minor-mode" - "define-globalized-minor-mode" - "define-derived-mode" "define-generic-mode" - "ert-deftest" - "cl-defun" "cl-defsubst" "cl-defmacro" - "cl-define-compiler-macro" "cl-defgeneric" - "cl-defmethod" - ;; CL. - "define-compiler-macro" "define-modify-macro" - "defsetf" "define-setf-expander" - "define-method-combination" - ;; CLOS and EIEIO - "defgeneric" "defmethod") - t)) + (regexp-opt + '("defun" "defmacro" + ;; Elisp. + "defun*" "defsubst" "define-inline" + "define-advice" "defadvice" "define-skeleton" + "define-compilation-mode" "define-minor-mode" + "define-global-minor-mode" + "define-globalized-minor-mode" + "define-derived-mode" "define-generic-mode" + "ert-deftest" + "cl-defun" "cl-defsubst" "cl-defmacro" + "cl-define-compiler-macro" "cl-defgeneric" + "cl-defmethod" + ;; CL. + "define-compiler-macro" "define-modify-macro" + "defsetf" "define-setf-expander" + "define-method-combination" + ;; CLOS and EIEIO + "defgeneric" "defmethod") + t) "\\s-+\\(" (rx lisp-mode-symbol) "\\)")) 2) ;; Like the previous, but uses a quoted symbol as the name. (list nil (purecopy (concat "^\\s-*(" - (eval-when-compile - (regexp-opt - '("defalias" "define-obsolete-function-alias") - t)) + (regexp-opt + '("defalias" "define-obsolete-function-alias") + t) "\\s-+'\\(" (rx lisp-mode-symbol) "\\)")) 2) (list (purecopy "Variables") (purecopy (concat "^\\s-*(" - (eval-when-compile - (regexp-opt - '(;; Elisp - "defconst" "defcustom" - ;; CL - "defconstant" - "defparameter" "define-symbol-macro") - t)) + (regexp-opt + '(;; Elisp + "defconst" "defcustom" + ;; CL + "defconstant" + "defparameter" "define-symbol-macro") + t) "\\s-+\\(" (rx lisp-mode-symbol) "\\)")) 2) ;; For `defvar'/`defvar-local', we ignore (defvar FOO) constructs. @@ -152,18 +149,17 @@ 1) (list (purecopy "Types") (purecopy (concat "^\\s-*(" - (eval-when-compile - (regexp-opt - '(;; Elisp - "defgroup" "deftheme" - "define-widget" "define-error" - "defface" "cl-deftype" "cl-defstruct" - ;; CL - "deftype" "defstruct" - "define-condition" "defpackage" - ;; CLOS and EIEIO - "defclass") - t)) + (regexp-opt + '(;; Elisp + "defgroup" "deftheme" + "define-widget" "define-error" + "defface" "cl-deftype" "cl-defstruct" + ;; CL + "deftype" "defstruct" + "define-condition" "defpackage" + ;; CLOS and EIEIO + "defclass") + t) "\\s-+'?\\(" (rx lisp-mode-symbol) "\\)")) 2)) @@ -273,8 +269,7 @@ to a package-local -loaddefs.el file.") ;; FIXME: Move to elisp-mode.el. (catch 'found (while (re-search-forward - (eval-when-compile - (concat "(\\(" (rx lisp-mode-symbol) "\\)\\_>")) + (concat "(\\(" (rx lisp-mode-symbol) "\\)\\_>") limit t) (let ((sym (intern-soft (match-string 1)))) (when (and (or (special-form-p sym) (macrop sym)) @@ -591,16 +586,15 @@ This will generate compile-time constants from BINDINGS." "Gaudy highlighting from Emacs Lisp mode used in Backtrace mode.") (defun lisp-string-in-doc-position-p (listbeg startpos) - "Return non-nil if a doc string may occur at STARTPOS inside a list. + "Return non-nil if a doc string may occur at STARTPOS inside a list. LISTBEG is the position of the start of the innermost list containing STARTPOS." (let* ((firstsym (and listbeg (save-excursion (goto-char listbeg) (and (looking-at - (eval-when-compile - (concat "([ \t\n]*\\(" - (rx lisp-mode-symbol) "\\)"))) + (concat "([ \t\n]*\\(" + (rx lisp-mode-symbol) "\\)")) (match-string 1))))) (docelt (and firstsym (function-get (intern-soft firstsym) diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index 75cbe5f1923..ffd3856db6c 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -61,8 +61,7 @@ (defun shorthands-font-lock-shorthands (limit) (when read-symbol-shorthands (while (re-search-forward - (eval-when-compile - (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>")) + (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>") limit t) (let* ((existing (get-text-property (match-beginning 1) 'face)) (probe (and (not (memq existing '(font-lock-comment-face diff --git a/lisp/net/socks.el b/lisp/net/socks.el index 8df0773e1d2..2ba1c20566f 100644 --- a/lisp/net/socks.el +++ b/lisp/net/socks.el @@ -407,11 +407,10 @@ When ATYPE indicates an IP, param ADDRESS must be given as raw bytes." (setq version (process-get proc 'socks-server-protocol)) (cond ((equal version 'http) - (setq request (format (eval-when-compile - (concat - "CONNECT %s:%d HTTP/1.0\r\n" - "User-Agent: Emacs/SOCKS v1.0\r\n" - "\r\n")) + (setq request (format (concat + "CONNECT %s:%d HTTP/1.0\r\n" + "User-Agent: Emacs/SOCKS v1.0\r\n" + "\r\n") (cond ((equal atype socks-address-type-name) address) (t diff --git a/lisp/progmodes/meta-mode.el b/lisp/progmodes/meta-mode.el index 5aaa277431a..34288e0e4fb 100644 --- a/lisp/progmodes/meta-mode.el +++ b/lisp/progmodes/meta-mode.el @@ -108,30 +108,27 @@ (macro-keywords-2 "\\(primarydef\\|secondarydef\\|tertiarydef\\)") (args-keywords - (eval-when-compile - (regexp-opt - '("expr" "suffix" "text" "primary" "secondary" "tertiary") - t))) + (regexp-opt + '("expr" "suffix" "text" "primary" "secondary" "tertiary") + t)) (type-keywords - (eval-when-compile - (regexp-opt - '("boolean" "color" "numeric" "pair" "path" "pen" "picture" - "string" "transform" "newinternal") - t))) + (regexp-opt + '("boolean" "color" "numeric" "pair" "path" "pen" "picture" + "string" "transform" "newinternal") + t)) (syntactic-keywords - (eval-when-compile - (regexp-opt - '("for" "forever" "forsuffixes" "endfor" - "step" "until" "upto" "downto" "thru" "within" - "iff" "if" "elseif" "else" "fi" "exitif" "exitunless" - "let" "def" "vardef" "enddef" "mode_def" - "true" "false" "known" "unknown" "and" "or" "not" - "save" "interim" "inner" "outer" "relax" - "begingroup" "endgroup" "expandafter" "scantokens" - "generate" "input" "endinput" "end" "bye" - "message" "errmessage" "errhelp" "special" "numspecial" - "readstring" "readfrom" "write") - t))) + (regexp-opt + '("for" "forever" "forsuffixes" "endfor" + "step" "until" "upto" "downto" "thru" "within" + "iff" "if" "elseif" "else" "fi" "exitif" "exitunless" + "let" "def" "vardef" "enddef" "mode_def" + "true" "false" "known" "unknown" "and" "or" "not" + "save" "interim" "inner" "outer" "relax" + "begingroup" "endgroup" "expandafter" "scantokens" + "generate" "input" "endinput" "end" "bye" + "message" "errmessage" "errhelp" "special" "numspecial" + "readstring" "readfrom" "write") + t)) ) (list ;; embedded TeX code in btex ... etex diff --git a/lisp/shell.el b/lisp/shell.el index 8bcc578406a..85225b128ab 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -440,12 +440,11 @@ Useful for shells like zsh that has this feature." (push (point) begins) (let ((arg ())) (while (looking-at - (eval-when-compile - (concat - "\\(?:[^\s\t\n\\\"';]+" - "\\|'\\([^']*\\)'?" - "\\|\"\\(\\(?:[^\"\\]\\|\\\\.\\)*\\)\"?" - "\\|\\\\\\(\\(?:.\\|\n\\)?\\)\\)"))) + (concat + "\\(?:[^\s\t\n\\\"';]+" + "\\|'\\([^']*\\)'?" + "\\|\"\\(\\(?:[^\"\\]\\|\\\\.\\)*\\)\"?" + "\\|\\\\\\(\\(?:.\\|\n\\)?\\)\\)")) (goto-char (match-end 0)) (cond ((match-beginning 3) ;Backslash escape. diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index ff881377a7e..13ff3dcab6a 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -600,12 +600,11 @@ Do \\[describe-key] on the following bindings to discover what they do. (setq-local tildify-foreach-region-function (apply-partially 'tildify-foreach-ignore-environments - `((,(eval-when-compile - (concat - "<\\(" - (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var" - "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR")) - "\\)\\>[^>]*>")) + `((,(concat + "<\\(" + (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var" + "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR")) + "\\)\\>[^>]*>") . ("")) ("") ("<" . ">")))) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 473643bb483..e90d214a127 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -983,14 +983,13 @@ Inherits `shell-mode-map' with a few additions.") (when (and slash (not comment)) (setq mode (if (looking-at - (eval-when-compile - (concat - (regexp-opt '("documentstyle" "documentclass" - "begin" "subsection" "section" - "part" "chapter" "newcommand" - "renewcommand" "RequirePackage") - 'words) - "\\|NeedsTeXFormat{LaTeX"))) + (concat + (regexp-opt '("documentstyle" "documentclass" + "begin" "subsection" "section" + "part" "chapter" "newcommand" + "renewcommand" "RequirePackage") + 'words) + "\\|NeedsTeXFormat{LaTeX")) (if (and (looking-at "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") ;; SliTeX is almost never used any more nowadays. @@ -1242,11 +1241,10 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook (apply-partially #'tildify-foreach-ignore-environments `(("\\\\\\\\" . "") ; do not remove this - (,(eval-when-compile - (concat "\\\\begin{\\(" - (regexp-opt '("verbatim" "math" "displaymath" - "equation" "eqnarray" "eqnarray*")) - "\\)}")) + (,(concat "\\\\begin{\\(" + (regexp-opt '("verbatim" "math" "displaymath" + "equation" "eqnarray" "eqnarray*")) + "\\)}") . ("\\\\end{" 1 "}")) ("\\\\verb\\*?\\(.\\)" . (1)) ("\\$\\$?" . (0)) @@ -2126,11 +2124,10 @@ If NOT-ALL is non-nil, save the `.dvi' file." (defvar tex-compile-history nil) (defvar tex-input-files-re - (eval-when-compile - (concat "\\." (regexp-opt '("tex" "texi" "texinfo" - "bbl" "ind" "sty" "cls") t) - ;; Include files with no dots (for directories). - "\\'\\|\\`[^.]+\\'"))) + (concat "\\." (regexp-opt '("tex" "texi" "texinfo" + "bbl" "ind" "sty" "cls") t) + ;; Include files with no dots (for directories). + "\\'\\|\\`[^.]+\\'")) (defcustom tex-use-reftex t "If non-nil, use RefTeX's list of files to determine what command to use." diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 9dcfb10d6df..2a7ad295ab7 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -494,9 +494,8 @@ variable will be set to the representation." (if (not (string-equal " " (or space tildify-space-string))) (when space (setq tildify-space-string space)) - (message (eval-when-compile - (concat "Hard space is a single space character, tildify-" - "mode won't have any effect, disabling."))) + (message (concat "Hard space is a single space character, tildify-" + "mode won't have any effect, disabling.")) (setq tildify-mode nil)))) (if tildify-mode (add-hook 'post-self-insert-hook #'tildify-space nil t) diff --git a/lisp/xdg.el b/lisp/xdg.el index 6a0b1dedd1d..c7d9c0e785e 100644 --- a/lisp/xdg.el +++ b/lisp/xdg.el @@ -171,13 +171,12 @@ file:///foo/bar.jpg" ;; https://www.freedesktop.org/wiki/Software/xdg-user-dirs/ (defconst xdg-line-regexp - (eval-when-compile - (rx "XDG_" - (group-n 1 (or "DESKTOP" "DOWNLOAD" "TEMPLATES" "PUBLICSHARE" - "DOCUMENTS" "MUSIC" "PICTURES" "VIDEOS")) - "_DIR=\"" - (group-n 2 (or "/" "$HOME/") (*? (or (not (any "\"")) "\\\""))) - "\"")) + (rx "XDG_" + (group-n 1 (or "DESKTOP" "DOWNLOAD" "TEMPLATES" "PUBLICSHARE" + "DOCUMENTS" "MUSIC" "PICTURES" "VIDEOS")) + "_DIR=\"" + (group-n 2 (or "/" "$HOME/") (*? (or (not (any "\"")) "\\\""))) + "\"") "Regexp matching non-comment lines in `xdg-user-dirs' config files.") (defvar xdg-user-dirs nil -- cgit v1.2.3 From cfc754a67c049e9297c19eb5400f8ea38159a0d9 Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Mon, 4 Jul 2022 15:54:14 +0200 Subject: ; remove regexp ambiguity --- lisp/emacs-lisp/lisp-mode.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 888e3397199..65f76a4fa35 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -478,10 +478,10 @@ This will generate compile-time constants from BINDINGS." ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for ;; `substitute-command-keys'. (,(rx "\\\\" (or (seq "[" (group-n 1 lisp-mode-symbol) "]") - (seq "`" (group-n 1 (+ lisp-mode-symbol - ;; allow multiple words, e.g. "C-x a" - (? " "))) - "'"))) + (seq "`" (group-n 1 + ;; allow multiple words, e.g. "C-x a" + lisp-mode-symbol (* " " lisp-mode-symbol)) + "'"))) (1 font-lock-constant-face prepend)) (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) ">") (seq "{" (group-n 1 lisp-mode-symbol) "}"))) -- cgit v1.2.3 From 162c6c12f97db9b4b3042dc8d122027e9fb01e71 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 4 Jul 2022 18:42:26 +0200 Subject: Prefer defvar-keymap in emacs-lisp/*.el * lisp/emacs-lisp/backtrace.el (backtrace-mode-map): * lisp/emacs-lisp/bytecomp.el (emacs-lisp-compilation-mode-map): * lisp/emacs-lisp/checkdoc.el (checkdoc-minor-mode-map): * lisp/emacs-lisp/crm.el (crm-local-completion-map) (crm-local-must-match-map): * lisp/emacs-lisp/debug.el (debugger-mode-map): * lisp/emacs-lisp/edebug.el (edebug-mode-map, edebug-global-map) (edebug-eval-mode-map): * lisp/emacs-lisp/eieio-custom.el (eieio-custom-mode-map): * lisp/emacs-lisp/elp.el (elp-results-symname-map): * lisp/emacs-lisp/lisp-mode.el (lisp-mode-shared-map): * lisp/emacs-lisp/re-builder.el (reb-mode-map) (reb-lisp-mode-map, reb-subexp-mode-map): * lisp/emacs-lisp/tabulated-list.el (tabulated-list-mode-map) (tabulated-list-sort-button-map): * lisp/emacs-lisp/timer-list.el (timer-list-mode-map): --- lisp/emacs-lisp/backtrace.el | 114 ++++++++++---------- lisp/emacs-lisp/bytecomp.el | 6 +- lisp/emacs-lisp/checkdoc.el | 56 +++++----- lisp/emacs-lisp/crm.el | 39 +++---- lisp/emacs-lisp/debug.el | 93 +++++++++-------- lisp/emacs-lisp/edebug.el | 213 ++++++++++++++++++-------------------- lisp/emacs-lisp/eieio-custom.el | 8 +- lisp/emacs-lisp/elp.el | 12 +-- lisp/emacs-lisp/lisp-mode.el | 35 +++---- lisp/emacs-lisp/re-builder.el | 60 +++++------ lisp/emacs-lisp/tabulated-list.el | 49 ++++----- lisp/emacs-lisp/timer-list.el | 12 +-- 12 files changed, 332 insertions(+), 365 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el index 3231877a30c..e305822af1f 100644 --- a/lisp/emacs-lisp/backtrace.el +++ b/lisp/emacs-lisp/backtrace.el @@ -199,63 +199,63 @@ functions returns non-nil. When adding a function to this hook, you should also set the :source-available flag for the backtrace frames where the source code location is known.") -(defvar backtrace-mode-map - (let ((map (copy-keymap special-mode-map))) - (set-keymap-parent map button-buffer-map) - (define-key map "n" 'backtrace-forward-frame) - (define-key map "p" 'backtrace-backward-frame) - (define-key map "v" 'backtrace-toggle-locals) - (define-key map "#" 'backtrace-toggle-print-circle) - (define-key map ":" 'backtrace-toggle-print-gensym) - (define-key map "s" 'backtrace-goto-source) - (define-key map "\C-m" 'backtrace-help-follow-symbol) - (define-key map "+" 'backtrace-multi-line) - (define-key map "-" 'backtrace-single-line) - (define-key map "." 'backtrace-expand-ellipses) - (define-key map [follow-link] 'mouse-face) - (define-key map [mouse-2] 'mouse-select-window) - (easy-menu-define nil map "" - '("Backtrace" - ["Next Frame" backtrace-forward-frame - :help "Move cursor forwards to the start of a backtrace frame"] - ["Previous Frame" backtrace-backward-frame - :help "Move cursor backwards to the start of a backtrace frame"] - "--" - ["Show Variables" backtrace-toggle-locals - :style toggle - :active (backtrace-get-index) - :selected (plist-get (backtrace-get-view) :show-locals) - :help "Show or hide the local variables for the frame at point"] - ["Show Circular Structures" backtrace-toggle-print-circle - :style toggle - :active (backtrace-get-index) - :selected (plist-get (backtrace-get-view) :print-circle) - :help - "Condense or expand shared or circular structures in the frame at point"] - ["Show Uninterned Symbols" backtrace-toggle-print-gensym - :style toggle - :active (backtrace-get-index) - :selected (plist-get (backtrace-get-view) :print-gensym) - :help - "Toggle unique printing of uninterned symbols in the frame at point"] - ["Expand \"...\"s" backtrace-expand-ellipses - :help "Expand all the abbreviated forms in the current frame"] - ["Show on Multiple Lines" backtrace-multi-line - :help "Use line breaks and indentation to make a form more readable"] - ["Show on Single Line" backtrace-single-line] - "--" - ["Go to Source" backtrace-goto-source - :active (and (backtrace-get-index) - (plist-get (backtrace-frame-flags - (nth (backtrace-get-index) backtrace-frames)) - :source-available)) - :help "Show the source code for the current frame"] - ["Help for Symbol" backtrace-help-follow-symbol - :help "Show help for symbol at point"] - ["Describe Backtrace Mode" describe-mode - :help "Display documentation for backtrace-mode"])) - map) - "Local keymap for `backtrace-mode' buffers.") +(defvar-keymap backtrace-mode-map + :doc "Local keymap for `backtrace-mode' buffers." + :parent (make-composed-keymap special-mode-map + button-buffer-map) + "n" #'backtrace-forward-frame + "p" #'backtrace-backward-frame + "v" #'backtrace-toggle-locals + "#" #'backtrace-toggle-print-circle + ":" #'backtrace-toggle-print-gensym + "s" #'backtrace-goto-source + "RET" #'backtrace-help-follow-symbol + "+" #'backtrace-multi-line + "-" #'backtrace-single-line + "." #'backtrace-expand-ellipses + "" 'mouse-face + "" #'mouse-select-window + + :menu + '("Backtrace" + ["Next Frame" backtrace-forward-frame + :help "Move cursor forwards to the start of a backtrace frame"] + ["Previous Frame" backtrace-backward-frame + :help "Move cursor backwards to the start of a backtrace frame"] + "--" + ["Show Variables" backtrace-toggle-locals + :style toggle + :active (backtrace-get-index) + :selected (plist-get (backtrace-get-view) :show-locals) + :help "Show or hide the local variables for the frame at point"] + ["Show Circular Structures" backtrace-toggle-print-circle + :style toggle + :active (backtrace-get-index) + :selected (plist-get (backtrace-get-view) :print-circle) + :help + "Condense or expand shared or circular structures in the frame at point"] + ["Show Uninterned Symbols" backtrace-toggle-print-gensym + :style toggle + :active (backtrace-get-index) + :selected (plist-get (backtrace-get-view) :print-gensym) + :help + "Toggle unique printing of uninterned symbols in the frame at point"] + ["Expand \"...\"s" backtrace-expand-ellipses + :help "Expand all the abbreviated forms in the current frame"] + ["Show on Multiple Lines" backtrace-multi-line + :help "Use line breaks and indentation to make a form more readable"] + ["Show on Single Line" backtrace-single-line] + "--" + ["Go to Source" backtrace-goto-source + :active (and (backtrace-get-index) + (plist-get (backtrace-frame-flags + (nth (backtrace-get-index) backtrace-frames)) + :source-available)) + :help "Show the source code for the current frame"] + ["Help for Symbol" backtrace-help-follow-symbol + :help "Show help for symbol at point"] + ["Describe Backtrace Mode" describe-mode + :help "Display documentation for backtrace-mode"])) (defconst backtrace--flags-width 2 "Width in characters of the flags for a backtrace frame.") diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index bd3db85c148..6545c8d961d 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1123,10 +1123,8 @@ message buffer `default-directory'." :type '(repeat (choice (const :tag "Default" nil) (string :tag "Directory")))) -(defvar emacs-lisp-compilation-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "g" 'emacs-lisp-compilation-recompile) - map)) +(defvar-keymap emacs-lisp-compilation-mode-map + "g" #'emacs-lisp-compilation-recompile) (defvar emacs-lisp-compilation--current-file nil) diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 2c9adfe2d27..611f32e23c6 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -1279,38 +1279,30 @@ TEXT, START, END and UNFIXABLE conform to ;;; Minor Mode specification ;; -(defvar checkdoc-minor-mode-map - (let ((map (make-sparse-keymap)) - (pmap (make-sparse-keymap))) - ;; Override some bindings - (define-key map "\C-\M-x" #'checkdoc-eval-defun) - (define-key map "\C-x`" #'checkdoc-continue) - (define-key map [menu-bar emacs-lisp eval-buffer] - #'checkdoc-eval-current-buffer) - ;; Add some new bindings under C-c ? - (define-key pmap "x" #'checkdoc-defun) - (define-key pmap "X" #'checkdoc-ispell-defun) - (define-key pmap "`" #'checkdoc-continue) - (define-key pmap "~" #'checkdoc-ispell-continue) - (define-key pmap "s" #'checkdoc-start) - (define-key pmap "S" #'checkdoc-ispell-start) - (define-key pmap "d" #'checkdoc) - (define-key pmap "D" #'checkdoc-ispell) - (define-key pmap "b" #'checkdoc-current-buffer) - (define-key pmap "B" #'checkdoc-ispell-current-buffer) - (define-key pmap "e" #'checkdoc-eval-current-buffer) - (define-key pmap "m" #'checkdoc-message-text) - (define-key pmap "M" #'checkdoc-ispell-message-text) - (define-key pmap "c" #'checkdoc-comments) - (define-key pmap "C" #'checkdoc-ispell-comments) - (define-key pmap " " #'checkdoc-rogue-spaces) - - ;; bind our submap into map - (define-key map "\C-c?" pmap) - map) - "Keymap used to override evaluation key-bindings for documentation checking.") - -;; Add in a menubar with easy-menu +(defvar-keymap checkdoc-minor-mode-map + :doc "Keymap used to override evaluation key-bindings for documentation checking." + ;; Override some bindings + "C-M-x" #'checkdoc-eval-defun + "C-x `" #'checkdoc-continue + " " #'checkdoc-eval-current-buffer + + ;; Add some new bindings under C-c ? + "C-c ? x" #'checkdoc-defun + "C-c ? X" #'checkdoc-ispell-defun + "C-c ? `" #'checkdoc-continue + "C-c ? ~" #'checkdoc-ispell-continue + "C-c ? s" #'checkdoc-start + "C-c ? S" #'checkdoc-ispell-start + "C-c ? d" #'checkdoc + "C-c ? D" #'checkdoc-ispell + "C-c ? b" #'checkdoc-current-buffer + "C-c ? B" #'checkdoc-ispell-current-buffer + "C-c ? e" #'checkdoc-eval-current-buffer + "C-c ? m" #'checkdoc-message-text + "C-c ? M" #'checkdoc-ispell-message-text + "C-c ? c" #'checkdoc-comments + "C-c ? C" #'checkdoc-ispell-comments + "C-c ? SPC" #'checkdoc-rogue-spaces) (easy-menu-define nil checkdoc-minor-mode-map "Checkdoc Minor Mode Menu." diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el index 8a5c3d3730c..9d9c91e510e 100644 --- a/lisp/emacs-lisp/crm.el +++ b/lisp/emacs-lisp/crm.el @@ -87,28 +87,23 @@ It should be a regexp that does not match the list of completion candidates. The default value is `crm-default-separator'.") -(defvar crm-local-completion-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map minibuffer-local-completion-map) - (define-key map [remap minibuffer-complete] #'crm-complete) - (define-key map [remap minibuffer-complete-word] #'crm-complete-word) - (define-key map [remap minibuffer-completion-help] #'crm-completion-help) - map) - "Local keymap for minibuffer multiple input with completion. -Analog of `minibuffer-local-completion-map'.") - -(defvar crm-local-must-match-map - (let ((map (make-sparse-keymap))) - ;; We'd want to have multiple inheritance here. - (set-keymap-parent map minibuffer-local-must-match-map) - (define-key map [remap minibuffer-complete] #'crm-complete) - (define-key map [remap minibuffer-complete-word] #'crm-complete-word) - (define-key map [remap minibuffer-completion-help] #'crm-completion-help) - (define-key map [remap minibuffer-complete-and-exit] - #'crm-complete-and-exit) - map) - "Local keymap for minibuffer multiple input with exact match completion. -Analog of `minibuffer-local-must-match-map' for crm.") +(defvar-keymap crm-local-completion-map + :doc "Local keymap for minibuffer multiple input with completion. +Analog of `minibuffer-local-completion-map'." + :parent minibuffer-local-completion-map + " " #'crm-complete + " " #'crm-complete-word + " " #'crm-completion-help) + +(defvar-keymap crm-local-must-match-map + :doc "Local keymap for minibuffer multiple input with exact match completion. +Analog of `minibuffer-local-must-match-map' for crm." + ;; We'd want to have multiple inheritance here. + :parent minibuffer-local-must-match-map + " " #'crm-complete + " " #'crm-complete-word + " " #'crm-completion-help + " " #'crm-complete-and-exit) (defvar crm-completion-table nil "An alist whose elements' cars are strings, or an obarray. diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index c4929eb2b01..460057b3afd 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -560,52 +560,53 @@ The environment used is the one when entering the activation frame at point." 'backtrace-toggle-locals "28.1") -(defvar debugger-mode-map - (let ((map (make-keymap))) - (set-keymap-parent map backtrace-mode-map) - (define-key map "b" 'debugger-frame) - (define-key map "c" 'debugger-continue) - (define-key map "j" 'debugger-jump) - (define-key map "r" 'debugger-return-value) - (define-key map "u" 'debugger-frame-clear) - (define-key map "d" 'debugger-step-through) - (define-key map "l" 'debugger-list-functions) - (define-key map "q" 'debugger-quit) - (define-key map "e" 'debugger-eval-expression) - (define-key map "R" 'debugger-record-expression) - (define-key map [mouse-2] 'push-button) - (easy-menu-define nil map "" - '("Debugger" - ["Step through" debugger-step-through - :help "Proceed, stepping through subexpressions of this expression"] - ["Continue" debugger-continue - :help "Continue, evaluating this expression without stopping"] - ["Jump" debugger-jump - :help "Continue to exit from this frame, with all debug-on-entry suspended"] - ["Eval Expression..." debugger-eval-expression - :help "Eval an expression, in an environment like that outside the debugger"] - ["Display and Record Expression" debugger-record-expression - :help "Display a variable's value and record it in `*Backtrace-record*' buffer"] - ["Return value..." debugger-return-value - :help "Continue, specifying value to return."] - "--" - ["Debug frame" debugger-frame - :help "Request entry to debugger when this frame exits"] - ["Cancel debug frame" debugger-frame-clear - :help "Do not enter debugger when this frame exits"] - ["List debug on entry functions" debugger-list-functions - :help "Display a list of all the functions now set to debug on entry"] - "--" - ["Next Line" next-line - :help "Move cursor down"] - ["Help for Symbol" backtrace-help-follow-symbol - :help "Show help for symbol at point"] - ["Describe Debugger Mode" describe-mode - :help "Display documentation for debugger-mode"] - "--" - ["Quit" debugger-quit - :help "Quit debugging and return to top level"])) - map)) +(defvar-keymap debugger-mode-map + :full t + :parent backtrace-mode-map + "b" #'debugger-frame + "c" #'debugger-continue + "j" #'debugger-jump + "r" #'debugger-return-value + "u" #'debugger-frame-clear + "d" #'debugger-step-through + "l" #'debugger-list-functions + "q" #'debugger-quit + "e" #'debugger-eval-expression + "R" #'debugger-record-expression + + "" #'push-button + + :menu + '("Debugger" + ["Step through" debugger-step-through + :help "Proceed, stepping through subexpressions of this expression"] + ["Continue" debugger-continue + :help "Continue, evaluating this expression without stopping"] + ["Jump" debugger-jump + :help "Continue to exit from this frame, with all debug-on-entry suspended"] + ["Eval Expression..." debugger-eval-expression + :help "Eval an expression, in an environment like that outside the debugger"] + ["Display and Record Expression" debugger-record-expression + :help "Display a variable's value and record it in `*Backtrace-record*' buffer"] + ["Return value..." debugger-return-value + :help "Continue, specifying value to return."] + "--" + ["Debug frame" debugger-frame + :help "Request entry to debugger when this frame exits"] + ["Cancel debug frame" debugger-frame-clear + :help "Do not enter debugger when this frame exits"] + ["List debug on entry functions" debugger-list-functions + :help "Display a list of all the functions now set to debug on entry"] + "--" + ["Next Line" next-line + :help "Move cursor down"] + ["Help for Symbol" backtrace-help-follow-symbol + :help "Show help for symbol at point"] + ["Describe Debugger Mode" describe-mode + :help "Display documentation for debugger-mode"] + "--" + ["Quit" debugger-quit + :help "Quit debugging and return to top level"])) (put 'debugger-mode 'mode-class 'special) diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index b05ec3a7683..1a1d58d6e36 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -3809,74 +3809,72 @@ be installed in `emacs-lisp-mode-map'.") ;; The following isn't a GUD binding. (define-key emacs-lisp-mode-map "\C-x\C-a\C-m" 'edebug-set-initial-mode)) -(defvar edebug-mode-map - (let ((map (copy-keymap emacs-lisp-mode-map))) - ;; control - (define-key map " " 'edebug-step-mode) - (define-key map "n" 'edebug-next-mode) - (define-key map "g" 'edebug-go-mode) - (define-key map "G" 'edebug-Go-nonstop-mode) - (define-key map "t" 'edebug-trace-mode) - (define-key map "T" 'edebug-Trace-fast-mode) - (define-key map "c" 'edebug-continue-mode) - (define-key map "C" 'edebug-Continue-fast-mode) - - ;;(define-key map "f" 'edebug-forward) not implemented - (define-key map "f" 'edebug-forward-sexp) - (define-key map "h" 'edebug-goto-here) - - (define-key map "I" 'edebug-instrument-callee) - (define-key map "i" 'edebug-step-in) - (define-key map "o" 'edebug-step-out) - - ;; quitting and stopping - (define-key map "q" 'top-level) - (define-key map "Q" 'edebug-top-level-nonstop) - (define-key map "a" 'abort-recursive-edit) - (define-key map "S" 'edebug-stop) - - ;; breakpoints - (define-key map "b" 'edebug-set-breakpoint) - (define-key map "u" 'edebug-unset-breakpoint) - (define-key map "U" 'edebug-unset-breakpoints) - (define-key map "B" 'edebug-next-breakpoint) - (define-key map "x" 'edebug-set-conditional-breakpoint) - (define-key map "X" 'edebug-set-global-break-condition) - (define-key map "D" 'edebug-toggle-disable-breakpoint) - - ;; evaluation - (define-key map "r" 'edebug-previous-result) - (define-key map "e" 'edebug-eval-expression) - (define-key map "\C-x\C-e" 'edebug-eval-last-sexp) - (define-key map "E" 'edebug-visit-eval-list) - - ;; views - (define-key map "w" 'edebug-where) - (define-key map "v" 'edebug-view-outside) ;; maybe obsolete?? - (define-key map "p" 'edebug-bounce-point) - (define-key map "P" 'edebug-view-outside) ;; same as v - (define-key map "W" 'edebug-toggle-save-windows) - - ;; misc - (define-key map "?" 'edebug-help) - (define-key map "d" 'edebug-pop-to-backtrace) - - (define-key map "-" 'negative-argument) - - ;; statistics - (define-key map "=" 'edebug-temp-display-freq-count) - - ;; GUD bindings - (define-key map "\C-c\C-s" 'edebug-step-mode) - (define-key map "\C-c\C-n" 'edebug-next-mode) - (define-key map "\C-c\C-c" 'edebug-go-mode) - - (define-key map "\C-x " 'edebug-set-breakpoint) - (define-key map "\C-c\C-d" 'edebug-unset-breakpoint) - (define-key map "\C-c\C-t" - (lambda () (interactive) (edebug-set-breakpoint t))) - (define-key map "\C-c\C-l" 'edebug-where) - map)) +(defvar-keymap edebug-mode-map + :parent emacs-lisp-mode-map + ;; control + "SPC" #'edebug-step-mode + "n" #'edebug-next-mode + "g" #'edebug-go-mode + "G" #'edebug-Go-nonstop-mode + "t" #'edebug-trace-mode + "T" #'edebug-Trace-fast-mode + "c" #'edebug-continue-mode + "C" #'edebug-Continue-fast-mode + + ;;"f" #'edebug-forward ; not implemented + "f" #'edebug-forward-sexp + "h" #'edebug-goto-here + + "I" #'edebug-instrument-callee + "i" #'edebug-step-in + "o" #'edebug-step-out + + ;; quitting and stopping + "q" #'top-level + "Q" #'edebug-top-level-nonstop + "a" #'abort-recursive-edit + "S" #'edebug-stop + + ;; breakpoints + "b" #'edebug-set-breakpoint + "u" #'edebug-unset-breakpoint + "U" #'edebug-unset-breakpoints + "B" #'edebug-next-breakpoint + "x" #'edebug-set-conditional-breakpoint + "X" #'edebug-set-global-break-condition + "D" #'edebug-toggle-disable-breakpoint + + ;; evaluation + "r" #'edebug-previous-result + "e" #'edebug-eval-expression + "C-x C-e" #'edebug-eval-last-sexp + "E" #'edebug-visit-eval-list + + ;; views + "w" #'edebug-where + "v" #'edebug-view-outside ; maybe obsolete?? + "p" #'edebug-bounce-point + "P" #'edebug-view-outside ; same as v + "W" #'edebug-toggle-save-windows + + ;; misc + "?" #'edebug-help + "d" #'edebug-pop-to-backtrace + + "-" #'negative-argument + + ;; statistics + "=" #'edebug-temp-display-freq-count + + ;; GUD bindings + "C-c C-s" #'edebug-step-mode + "C-c C-n" #'edebug-next-mode + "C-c C-c" #'edebug-go-mode + + "C-x SPC" #'edebug-set-breakpoint + "C-c C-d" #'edebug-unset-breakpoint + "C-c C-t" (lambda () (interactive) (edebug-set-breakpoint t)) + "C-c C-l" #'edebug-where) ;; Autoloading these global bindings doesn't make sense because ;; they cannot be used anyway unless Edebug is already loaded and active. @@ -3891,38 +3889,35 @@ be installed in `emacs-lisp-mode-map'.") (define-obsolete-variable-alias 'global-edebug-map 'edebug-global-map "28.1") -(defvar edebug-global-map - (let ((map (make-sparse-keymap))) - - (define-key map " " 'edebug-step-mode) - (define-key map "g" 'edebug-go-mode) - (define-key map "G" 'edebug-Go-nonstop-mode) - (define-key map "t" 'edebug-trace-mode) - (define-key map "T" 'edebug-Trace-fast-mode) - (define-key map "c" 'edebug-continue-mode) - (define-key map "C" 'edebug-Continue-fast-mode) - - ;; breakpoints - (define-key map "b" 'edebug-set-breakpoint) - (define-key map "u" 'edebug-unset-breakpoint) - (define-key map "U" 'edebug-unset-breakpoints) - (define-key map "x" 'edebug-set-conditional-breakpoint) - (define-key map "X" 'edebug-set-global-break-condition) - (define-key map "D" 'edebug-toggle-disable-breakpoint) - - ;; views - (define-key map "w" 'edebug-where) - (define-key map "W" 'edebug-toggle-save-windows) - - ;; quitting - (define-key map "q" 'top-level) - (define-key map "Q" 'edebug-top-level-nonstop) - (define-key map "a" 'abort-recursive-edit) - - ;; statistics - (define-key map "=" 'edebug-display-freq-count) - map) - "Global map of edebug commands, available from any buffer.") +(defvar-keymap edebug-global-map + :doc "Global map of edebug commands, available from any buffer." + "SPC" #'edebug-step-mode + "g" #'edebug-go-mode + "G" #'edebug-Go-nonstop-mode + "t" #'edebug-trace-mode + "T" #'edebug-Trace-fast-mode + "c" #'edebug-continue-mode + "C" #'edebug-Continue-fast-mode + + ;; breakpoints + "b" #'edebug-set-breakpoint + "u" #'edebug-unset-breakpoint + "U" #'edebug-unset-breakpoints + "x" #'edebug-set-conditional-breakpoint + "X" #'edebug-set-global-break-condition + "D" #'edebug-toggle-disable-breakpoint + + ;; views + "w" #'edebug-where + "W" #'edebug-toggle-save-windows + + ;; quitting + "q" #'top-level + "Q" #'edebug-top-level-nonstop + "a" #'abort-recursive-edit + + ;; statistics + "=" #'edebug-display-freq-count) (when edebug-global-prefix (global-unset-key edebug-global-prefix) @@ -4093,16 +4088,14 @@ May only be called from within `edebug--recursive-edit'." -(defvar edebug-eval-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map lisp-interaction-mode-map) - (define-key map "\C-c\C-w" 'edebug-where) - (define-key map "\C-c\C-d" 'edebug-delete-eval-item) - (define-key map "\C-c\C-u" 'edebug-update-eval-list) - (define-key map "\C-x\C-e" 'edebug-eval-last-sexp) - (define-key map "\C-j" 'edebug-eval-print-last-sexp) - map) - "Keymap for Edebug Eval mode. Superset of Lisp Interaction mode.") +(defvar-keymap edebug-eval-mode-map + :doc "Keymap for Edebug Eval mode. Superset of Lisp Interaction mode." + :parent lisp-interaction-mode-map + "C-c C-w" #'edebug-where + "C-c C-d" #'edebug-delete-eval-item + "C-c C-u" #'edebug-update-eval-list + "C-x C-e" #'edebug-eval-last-sexp + "C-j" #'edebug-eval-print-last-sexp) (put 'edebug-eval-mode 'mode-class 'special) diff --git a/lisp/emacs-lisp/eieio-custom.el b/lisp/emacs-lisp/eieio-custom.el index ebb6f2cd8c8..4b8b4275f1a 100644 --- a/lisp/emacs-lisp/eieio-custom.el +++ b/lisp/emacs-lisp/eieio-custom.el @@ -329,11 +329,9 @@ Argument OBJ is the object that has been customized." Optional argument GROUP is the sub-group of slots to display." (eieio-customize-object obj group)) -(defvar eieio-custom-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map widget-keymap) - map) - "Keymap for EIEIO Custom mode.") +(defvar-keymap eieio-custom-mode-map + :doc "Keymap for EIEIO Custom mode." + :parent widget-keymap) (define-derived-mode eieio-custom-mode fundamental-mode "EIEIO Custom" "Major mode for customizing EIEIO objects. diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el index 385ddb3f414..03c5b94e3b4 100644 --- a/lisp/emacs-lisp/elp.el +++ b/lisp/emacs-lisp/elp.el @@ -472,13 +472,11 @@ original definition, use \\[elp-restore-function] or \\[elp-restore-all]." (insert atstr)) (insert "\n")))) -(defvar elp-results-symname-map - (let ((map (make-sparse-keymap))) - (define-key map [mouse-2] 'elp-results-jump-to-definition) - (define-key map [follow-link] 'mouse-face) - (define-key map "\C-m" 'elp-results-jump-to-definition) - map) - "Keymap used on the function name column." ) +(defvar-keymap elp-results-symname-map + :doc "Keymap used on the function name column." + "" #'elp-results-jump-to-definition + "" 'mouse-face + "RET" #'elp-results-jump-to-definition) (defun elp-results-jump-to-definition (&optional event) "Jump to the definition of the function at point." diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 65f76a4fa35..c559dd427cb 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -753,17 +753,16 @@ font-lock keywords will not be case sensitive." (progn (forward-sexp 1) (point))))))) -(defvar lisp-mode-shared-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map prog-mode-map) - (define-key map "\e\C-q" 'indent-sexp) - (define-key map "\177" 'backward-delete-char-untabify) - ;; This gets in the way when viewing a Lisp file in view-mode. As - ;; long as [backspace] is mapped into DEL via the - ;; function-key-map, this should remain disabled!! - ;;;(define-key map [backspace] 'backward-delete-char-untabify) - map) - "Keymap for commands shared by all sorts of Lisp modes.") +(defvar-keymap lisp-mode-shared-map + :doc "Keymap for commands shared by all sorts of Lisp modes." + :parent prog-mode-map + "C-M-q" #'indent-sexp + "DEL" #'backward-delete-char-untabify + ;; This gets in the way when viewing a Lisp file in view-mode. As + ;; long as [backspace] is mapped into DEL via the + ;; function-key-map, this should remain disabled!! + ;;;"" #'backward-delete-char-untabify + ) (defcustom lisp-mode-hook nil "Hook run when entering Lisp mode." @@ -779,14 +778,12 @@ font-lock keywords will not be case sensitive." ;;; Generic Lisp mode. -(defvar lisp-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map lisp-mode-shared-map) - (define-key map "\e\C-x" 'lisp-eval-defun) - (define-key map "\C-c\C-z" 'run-lisp) - map) - "Keymap for ordinary Lisp mode. -All commands in `lisp-mode-shared-map' are inherited by this map.") +(defvar-keymap lisp-mode-map + :doc "Keymap for ordinary Lisp mode. +All commands in `lisp-mode-shared-map' are inherited by this map." + :parent lisp-mode-shared-map + "C-M-x" #'lisp-eval-defun + "C-c C-z" #'run-lisp) (easy-menu-define lisp-mode-menu lisp-mode-map "Menu for ordinary Lisp mode." diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index 24770fac67f..46b429ce6fe 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -216,19 +216,17 @@ Except for Lisp syntax this is the same as `reb-regexp'.") "Buffer to use for the RE Builder.") ;; Define the local "\C-c" keymap -(defvar reb-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-c\C-c" 'reb-toggle-case) - (define-key map "\C-c\C-q" 'reb-quit) - (define-key map "\C-c\C-w" 'reb-copy) - (define-key map "\C-c\C-s" 'reb-next-match) - (define-key map "\C-c\C-r" 'reb-prev-match) - (define-key map "\C-c\C-i" 'reb-change-syntax) - (define-key map "\C-c\C-e" 'reb-enter-subexp-mode) - (define-key map "\C-c\C-b" 'reb-change-target-buffer) - (define-key map "\C-c\C-u" 'reb-force-update) - map) - "Keymap used by the RE Builder.") +(defvar-keymap reb-mode-map + :doc "Keymap used by the RE Builder." + "C-c C-c" #'reb-toggle-case + "C-c C-q" #'reb-quit + "C-c C-w" #'reb-copy + "C-c C-s" #'reb-next-match + "C-c C-r" #'reb-prev-match + "C-c C-i" #'reb-change-syntax + "C-c C-e" #'reb-enter-subexp-mode + "C-c C-b" #'reb-change-target-buffer + "C-c C-u" #'reb-force-update) (easy-menu-define reb-mode-menu reb-mode-map "Menu for the RE Builder." @@ -263,12 +261,10 @@ Except for Lisp syntax this is the same as `reb-regexp'.") (setq-local blink-matching-paren nil) (reb-mode-common)) -(defvar reb-lisp-mode-map - (let ((map (make-sparse-keymap))) - ;; Use the same "\C-c" keymap as `reb-mode' and use font-locking from - ;; `emacs-lisp-mode' - (define-key map "\C-c" (lookup-key reb-mode-map "\C-c")) - map)) +(defvar-keymap reb-lisp-mode-map + ;; Use the same "\C-c" keymap as `reb-mode' and use font-locking from + ;; `emacs-lisp-mode' + "C-c" (keymap-lookup reb-mode-map "C-c")) (define-derived-mode reb-lisp-mode emacs-lisp-mode "RE Builder Lisp" @@ -278,16 +274,22 @@ Except for Lisp syntax this is the same as `reb-regexp'.") (require 'rx)) ; require rx anyway (reb-mode-common)) -(defvar reb-subexp-mode-map - (let ((m (make-keymap))) - (suppress-keymap m) - ;; Again share the "\C-c" keymap for the commands - (define-key m "\C-c" (lookup-key reb-mode-map "\C-c")) - (define-key m "q" 'reb-quit-subexp-mode) - (dotimes (digit 10) - (define-key m (int-to-string digit) 'reb-display-subexp)) - m) - "Keymap used by the RE Builder for the subexpression mode.") +(defvar-keymap reb-subexp-mode-map + :doc "Keymap used by the RE Builder for the subexpression mode." + :full t :suppress t + ;; Again share the "\C-c" keymap for the commands + "C-c" (keymap-lookup reb-mode-map "C-c") + "q" #'reb-quit-subexp-mode + "0" #'reb-display-subexp + "1" #'reb-display-subexp + "2" #'reb-display-subexp + "3" #'reb-display-subexp + "4" #'reb-display-subexp + "5" #'reb-display-subexp + "6" #'reb-display-subexp + "7" #'reb-display-subexp + "8" #'reb-display-subexp + "9" #'reb-display-subexp) (defun reb-mode-common () "Setup functions common to functions `reb-mode' and `reb-lisp-mode'." diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 7d815a3cedc..9868d8c4ec0 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -216,33 +216,28 @@ If ADVANCE is non-nil, move forward by one line afterwards." (while (re-search-forward re nil 'noerror) (tabulated-list-put-tag empty))))) -(defvar tabulated-list-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map (make-composed-keymap - button-buffer-map - special-mode-map)) - (define-key map "n" 'next-line) - (define-key map "p" 'previous-line) - (define-key map (kbd "M-") 'tabulated-list-previous-column) - (define-key map (kbd "M-") 'tabulated-list-next-column) - (define-key map "S" 'tabulated-list-sort) - (define-key map "}" 'tabulated-list-widen-current-column) - (define-key map "{" 'tabulated-list-narrow-current-column) - (define-key map [follow-link] 'mouse-face) - (define-key map [mouse-2] 'mouse-select-window) - map) - "Local keymap for `tabulated-list-mode' buffers.") - -(defvar tabulated-list-sort-button-map - (let ((map (make-sparse-keymap))) - (define-key map [header-line mouse-1] 'tabulated-list-col-sort) - (define-key map [header-line mouse-2] 'tabulated-list-col-sort) - (define-key map [mouse-1] 'tabulated-list-col-sort) - (define-key map [mouse-2] 'tabulated-list-col-sort) - (define-key map "\C-m" 'tabulated-list-sort) - (define-key map [follow-link] 'mouse-face) - map) - "Local keymap for `tabulated-list-mode' sort buttons.") +(defvar-keymap tabulated-list-mode-map + :doc "Local keymap for `tabulated-list-mode' buffers." + :parent (make-composed-keymap button-buffer-map + special-mode-map) + "n" #'next-line + "p" #'previous-line + "M-" #'tabulated-list-previous-column + "M-" #'tabulated-list-next-column + "S" #'tabulated-list-sort + "}" #'tabulated-list-widen-current-column + "{" #'tabulated-list-narrow-current-column + "" 'mouse-face + "" #'mouse-select-window) + +(defvar-keymap tabulated-list-sort-button-map + :doc "Local keymap for `tabulated-list-mode' sort buttons." + " " #'tabulated-list-col-sort + " " #'tabulated-list-col-sort + "" #'tabulated-list-col-sort + "" #'tabulated-list-col-sort + "RET" #'tabulated-list-sort + "" 'mouse-face) (defun tabulated-list-make-glyphless-char-display-table () "Make the `glyphless-char-display' table used for text-mode frames. diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el index aef18d0ba27..8c56108dcbc 100644 --- a/lisp/emacs-lisp/timer-list.el +++ b/lisp/emacs-lisp/timer-list.el @@ -81,13 +81,11 @@ ;; doing. Kids, don't try this at home! ;;;###autoload (put 'list-timers 'disabled "Beware: manually canceling timers can ruin your Emacs session.") -(defvar timer-list-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "c" 'timer-list-cancel) - (easy-menu-define nil map "" - '("Timers" - ["Cancel" timer-list-cancel t])) - map)) +(defvar-keymap timer-list-mode-map + "c" #'timer-list-cancel + :menu + '("Timers" + ["Cancel" timer-list-cancel t])) (define-derived-mode timer-list-mode tabulated-list-mode "Timer-List" "Mode for listing and controlling timers." -- cgit v1.2.3 From 3e7f6ff4b09760c92b1a6b1a193d08c52f37675a Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 6 Jul 2022 19:56:32 +0200 Subject: Prefer defcustom :safe to putting 'safe-local-variable' * lisp/emacs-lisp/lisp-mode.el (lisp-indent-offset) (lisp-body-indent, emacs-lisp-docstring-fill-column): * lisp/files.el (version-control): * lisp/progmodes/modula2.el (m2-indent): * lisp/progmodes/octave.el (octave-block-offset): * lisp/progmodes/sh-script.el (sh-basic-offset): * lisp/progmodes/tcl.el (tcl-indent-level) (tcl-continued-indent-level): * lisp/simple.el (fill-prefix): * lisp/textmodes/fill.el (colon-double-space): * lisp/textmodes/paragraphs.el (paragraph-start) (paragraph-separate, sentence-end-double-space) (sentence-end-without-period, sentence-end-without-space) (sentence-end, sentence-end-base, page-delimiter) (paragraph-ignore-fill-prefix): * lisp/textmodes/tex-mode.el (tex-fontify-script): * lisp/vc/add-log.el (add-log-dont-create-changelog-file): * lisp/vc/vc-hooks.el (vc-follow-symlinks): Prefer defcustom :safe to putting 'safe-local-variable'. --- lisp/emacs-lisp/lisp-mode.el | 12 +++++------- lisp/files.el | 6 ++---- lisp/progmodes/modula2.el | 5 ++--- lisp/progmodes/octave.el | 4 ++-- lisp/progmodes/sh-script.el | 2 +- lisp/progmodes/tcl.el | 8 ++++---- lisp/simple.el | 4 ++-- lisp/textmodes/fill.el | 4 ++-- lisp/textmodes/paragraphs.el | 30 +++++++++++++++--------------- lisp/textmodes/tex-mode.el | 2 +- lisp/vc/add-log.el | 3 +-- lisp/vc/vc-hooks.el | 4 ++-- 12 files changed, 39 insertions(+), 45 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index c559dd427cb..68528e199f8 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -838,9 +838,8 @@ or to switch back to an existing one." (defcustom lisp-indent-offset nil "If non-nil, indent second line of expressions that many more columns." :group 'lisp - :type '(choice (const nil) integer)) -(put 'lisp-indent-offset 'safe-local-variable - (lambda (x) (or (null x) (integerp x)))) + :type '(choice (const nil) integer) + :safe (lambda (x) (or (null x) (integerp x)))) (defcustom lisp-indent-function 'lisp-indent-function "A function to be called by `calculate-lisp-indent'. @@ -1252,8 +1251,8 @@ Lisp function does not specify a special indentation." (defcustom lisp-body-indent 2 "Number of columns to indent the second line of a `(def...)' form." :group 'lisp - :type 'integer) -(put 'lisp-body-indent 'safe-local-variable 'integerp) + :type 'integer + :safe #'integerp) (defun lisp-indent-specform (count state indent-point normal-indent) (let ((containing-form-start (elt state 1)) @@ -1414,9 +1413,8 @@ Any non-integer value means do not use a different value of `fill-column' when filling docstrings." :type '(choice (integer) (const :tag "Use the current `fill-column'" t)) + :safe (lambda (x) (or (eq x t) (integerp x))) :group 'lisp) -(put 'emacs-lisp-docstring-fill-column 'safe-local-variable - (lambda (x) (or (eq x t) (integerp x)))) (defun lisp-fill-paragraph (&optional justify) "Like \\[fill-paragraph], but handle Emacs Lisp comments and docstrings. diff --git a/lisp/files.el b/lisp/files.el index f84fe7e085b..992f9879437 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -304,16 +304,14 @@ When nil, make them for files that have some already. The value `never' means do not make them." :type '(choice (const :tag "Never" never) (const :tag "If existing" nil) - (other :tag "Always" t)) + (other :tag "Always" t)) + :safe #'version-control-safe-local-p :group 'backup) (defun version-control-safe-local-p (x) "Return whether X is safe as local value for `version-control'." (or (booleanp x) (equal x 'never))) -(put 'version-control 'safe-local-variable - #'version-control-safe-local-p) - (defcustom dired-kept-versions 2 "When cleaning directory, number of versions to keep." :type 'natnum diff --git a/lisp/progmodes/modula2.el b/lisp/progmodes/modula2.el index a8d644dba0e..e668570ba17 100644 --- a/lisp/progmodes/modula2.el +++ b/lisp/progmodes/modula2.el @@ -101,9 +101,8 @@ (defcustom m2-indent 5 "This variable gives the indentation in Modula-2 mode." - :type 'integer) -(put 'm2-indent 'safe-local-variable - (lambda (v) (or (null v) (integerp v)))) + :type 'integer + :safe (lambda (v) (or (null v) (integerp v)))) (defconst m2-smie-grammar ;; An official definition can be found as "M2R10.pdf". This grammar does diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 7b7c675873b..721dfa51ad3 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -197,8 +197,8 @@ newline or semicolon after an else or end keyword." (defcustom octave-block-offset 2 "Extra indentation applied to statements in Octave block structures." - :type 'integer) -(put 'octave-block-offset 'safe-local-variable 'integerp) + :type 'integer + :safe #'integerp) (defvar octave-block-comment-start (concat (make-string 2 octave-comment-char) " ") diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 71fb0cd2e00..be9f325d93d 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1156,8 +1156,8 @@ Can be set to a number, or to nil which means leave it as is." "The default indentation increment. This value is used for the `+' and `-' symbols in an indentation variable." :type 'integer + :safe #'integerp :group 'sh-indentation) -(put 'sh-basic-offset 'safe-local-variable 'integerp) (defcustom sh-indent-comment t "How a comment line is to be indented. diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el index 8c179879ce2..7dae14f9e02 100644 --- a/lisp/progmodes/tcl.el +++ b/lisp/progmodes/tcl.el @@ -120,13 +120,13 @@ (defcustom tcl-indent-level 4 "Indentation of Tcl statements with respect to containing block." - :type 'integer) -(put 'tcl-indent-level 'safe-local-variable #'integerp) + :type 'integer + :safe #'integerp) (defcustom tcl-continued-indent-level 4 "Indentation of continuation line relative to first line of command." - :type 'integer) -(put 'tcl-continued-indent-level 'safe-local-variable #'integerp) + :type 'integer + :safe #'integerp) (defcustom tcl-auto-newline nil "Non-nil means automatically newline before and after braces you insert." diff --git a/lisp/simple.el b/lisp/simple.el index e79487eba86..6313ce81ef9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8609,10 +8609,10 @@ constitute a word." (defcustom fill-prefix nil "String for filling to insert at front of new line, or nil for none." :type '(choice (const :tag "None" nil) - string) + string) + :safe #'string-or-null-p :group 'fill) (make-variable-buffer-local 'fill-prefix) -(put 'fill-prefix 'safe-local-variable 'string-or-null-p) (defcustom auto-fill-inhibit-regexp nil "Regexp to match lines that should not be auto-filled." diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 88a8395c88a..23ba1a24f1f 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -46,8 +46,8 @@ A value of nil means that any change in indentation starts a new paragraph." (defcustom colon-double-space nil "Non-nil means put two spaces after a colon when filling." - :type 'boolean) -(put 'colon-double-space 'safe-local-variable #'booleanp) + :type 'boolean + :safe #'booleanp) (defcustom fill-separate-heterogeneous-words-with-space nil "Non-nil means to use a space to separate words of a different kind. diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index 98eb494823d..cd726ad4776 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -96,8 +96,8 @@ lines that start paragraphs from lines that separate them. If the variable `use-hard-newlines' is non-nil, then only lines following a hard newline are considered to match." - :type 'regexp) -(put 'paragraph-start 'safe-local-variable #'stringp) + :type 'regexp + :safe #'stringp) ;; paragraph-start requires a hard newline, but paragraph-separate does not: ;; It is assumed that paragraph-separate is distinctive enough to be believed @@ -113,8 +113,8 @@ This is matched against the text at the left margin, which is not necessarily the beginning of the line, so it should not use \"^\" as an anchor. This ensures that the paragraph functions will work equally within a region of text indented by a margin setting." - :type 'regexp) -(put 'paragraph-separate 'safe-local-variable #'stringp) + :type 'regexp + :safe #'stringp) (defcustom sentence-end-double-space t "Non-nil means a single space does not end a sentence. @@ -125,8 +125,8 @@ This value is used by the function `sentence-end' to construct the regexp describing the end of a sentence, when the value of the variable `sentence-end' is nil. See Info node `(elisp)Standard Regexps'." :type 'boolean + :safe #'booleanp :group 'fill) -(put 'sentence-end-double-space 'safe-local-variable #'booleanp) (defcustom sentence-end-without-period nil "Non-nil means a sentence will end without a period. @@ -137,8 +137,8 @@ This value is used by the function `sentence-end' to construct the regexp describing the end of a sentence, when the value of the variable `sentence-end' is nil. See Info node `(elisp)Standard Regexps'." :type 'boolean + :safe #'booleanp :group 'fill) -(put 'sentence-end-without-period 'safe-local-variable #'booleanp) (defcustom sentence-end-without-space "。.?!" @@ -147,8 +147,8 @@ regexp describing the end of a sentence, when the value of the variable This value is used by the function `sentence-end' to construct the regexp describing the end of a sentence, when the value of the variable `sentence-end' is nil. See Info node `(elisp)Standard Regexps'." - :type 'string) -(put 'sentence-end-without-space 'safe-local-variable #'stringp) + :type 'string + :safe #'stringp) (defcustom sentence-end nil "Regexp describing the end of a sentence. @@ -158,14 +158,14 @@ All paragraph boundaries also end sentences, regardless. The value nil means to use the default value defined by the function `sentence-end'. You should always use this function to obtain the value of this variable." - :type '(choice regexp (const :tag "Use default value" nil))) -(put 'sentence-end 'safe-local-variable #'string-or-null-p) + :type '(choice regexp (const :tag "Use default value" nil)) + :safe #'string-or-null-p) (defcustom sentence-end-base "[.?!…‽][]\"'”’)}»›]*" "Regexp matching the basic end of a sentence, not including following space." :type 'regexp + :safe #'stringp :version "25.1") -(put 'sentence-end-base 'safe-local-variable #'stringp) (defun sentence-end () "Return the regexp describing the end of a sentence. @@ -192,14 +192,14 @@ in between. See Info node `(elisp)Standard Regexps'." (defcustom page-delimiter "^\014" "Regexp describing line-beginnings that separate pages." - :type 'regexp) -(put 'page-delimiter 'safe-local-variable #'stringp) + :type 'regexp + :safe #'stringp) (defcustom paragraph-ignore-fill-prefix nil "Non-nil means the paragraph commands are not affected by `fill-prefix'. This is desirable in modes where blank lines are the paragraph delimiters." - :type 'boolean) -(put 'paragraph-ignore-fill-prefix 'safe-local-variable #'booleanp) + :type 'boolean + :safe #'booleanp) ;; Silence the compiler. (defun forward-paragraph (&optional arg) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index e90d214a127..d34133f8564 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -248,9 +248,9 @@ Normally set to either `plain-tex-mode' or `latex-mode'." (defcustom tex-fontify-script t "If non-nil, fontify subscript and superscript strings." :type 'boolean + :safe #'booleanp :group 'tex :version "23.1") -(put 'tex-fontify-script 'safe-local-variable #'booleanp) (defcustom tex-font-script-display '(-0.2 0.2) "How much to lower and raise subscript and superscript content. diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index beaad2e835f..e02d84f1f56 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -789,10 +789,9 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'." If a ChangeLog file does not already exist, a non-nil value means to put log entries in a suitably named buffer." :type 'boolean + :safe #'booleanp :version "27.1") -(put 'add-log-dont-create-changelog-file 'safe-local-variable #'booleanp) - (defun add-log--pseudo-changelog-buffer-name (changelog-file-name) "Compute a suitable name for a non-file visiting ChangeLog buffer. CHANGELOG-FILE-NAME is the file name of the actual ChangeLog file diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index cc08767ade3..46e40f29c02 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -141,9 +141,9 @@ confirmation whether it should follow the link. If nil, the link is visited and a warning displayed." :type '(choice (const :tag "Ask for confirmation" ask) (const :tag "Visit link and warn" nil) - (const :tag "Follow link" t)) + (const :tag "Follow link" t)) + :safe #'null :group 'vc) -(put 'vc-follow-symlinks 'safe-local-variable #'null) (defcustom vc-display-status t "If non-nil, display revision number and lock status in mode line. -- cgit v1.2.3 From 8ab9102950e9476c0d0d1cbecfd7c1dd22141a5f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 11 Jul 2022 12:15:04 +0200 Subject: Fix `M-x lisp-fill-paragraph' * lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): Fix filling when called directly with `M-x lisp-fill-paragraph' instead of via `M-q' (bug#56476). --- lisp/emacs-lisp/lisp-mode.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 68528e199f8..c906ee6e31d 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -1466,7 +1466,10 @@ and initial semicolons." emacs-lisp-docstring-fill-column fill-column))) (let ((ppss (syntax-ppss)) - (start (point))) + (start (point)) + ;; Avoid recursion if we're being called directly with + ;; `M-x lisp-fill-paragraph' in an `emacs-lisp-mode' buffer. + (fill-paragraph-function t)) (save-excursion (save-restriction ;; If we're not inside a string, then do very basic -- cgit v1.2.3 From 55cc8b040b0e3c5f97fd1386d1e9c5a120be6340 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 8 Aug 2022 14:31:54 +0200 Subject: Make which-func-mode output less junk * lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): Use edebug specs to find the name (if they exist), and default to returning the top-level symbol if there isn't a define-like form (bug#49592). --- lisp/emacs-lisp/lisp-mode.el | 64 +++++++++++++++++++++++---------- lisp/progmodes/which-func.el | 3 ++ test/lisp/emacs-lisp/lisp-mode-tests.el | 23 ++++++++++++ 3 files changed, 72 insertions(+), 18 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index c906ee6e31d..2e7f019aa9e 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -728,30 +728,58 @@ font-lock keywords will not be case sensitive." len)))) (defun lisp-current-defun-name () - "Return the name of the defun at point, or nil." + "Return the name of the defun at point. +If there is no defun at point, return the first symbol from the +top-level form. If there is no top-level form, return nil. + +(\"defun\" here means \"form that defines something\", and is +decided heuristically.)" (save-excursion - (let ((location (point))) + (let ((location (point)) + name) ;; If we are now precisely at the beginning of a defun, make sure ;; beginning-of-defun finds that one rather than the previous one. - (or (eobp) (forward-char 1)) + (unless (eobp) + (forward-char 1)) (beginning-of-defun) ;; Make sure we are really inside the defun found, not after it. - (when (and (looking-at "\\s(") - (progn (end-of-defun) - (< location (point))) - (progn (forward-sexp -1) - (>= location (point)))) - (if (looking-at "\\s(") - (forward-char 1)) - ;; Skip the defining construct name, typically "defun" or + (when (and (looking-at "(") + (progn + (end-of-defun) + (< location (point))) + (progn + (forward-sexp -1) + (>= location (point)))) + (when (looking-at "(") + (forward-char 1)) + ;; Read the defining construct name, typically "defun" or ;; "defvar". - (forward-sexp 1) - ;; The second element is usually a symbol being defined. If it - ;; is not, use the first symbol in it. - (skip-chars-forward " \t\n'(") - (buffer-substring-no-properties (point) - (progn (forward-sexp 1) - (point))))))) + (let ((symbol (ignore-errors (read (current-buffer))))) + (when (and symbol (not (symbolp symbol))) + (setq symbol nil)) + ;; If there's an edebug spec, use that to determine what the + ;; name is. + (when symbol + (let ((spec (get symbol 'edebug-form-spec))) + (save-excursion + (when (and (eq (car spec) '&define) + (memq 'name spec)) + (pop spec) + (while (and spec (not name)) + (let ((candidate (ignore-errors (read (current-buffer))))) + (when (eq (pop spec) 'name) + (setq name candidate + spec nil)))))))) + ;; We didn't have an edebug spec (or couldn't find the + ;; name). If the symbol starts with \"def\", then it's + ;; likely that the next symbol is the name. + (when (and (not name) + (string-match-p "\\`def" (symbol-name symbol))) + (when-let ((candidate (ignore-errors (read (current-buffer))))) + (when (symbolp candidate) + (setq name candidate)))) + (when-let ((result (or name symbol))) + (symbol-name result))))))) (defvar-keymap lisp-mode-shared-map :doc "Keymap for commands shared by all sorts of Lisp modes." diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 2e8e8d23192..4fe4edc1648 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -61,6 +61,9 @@ ;;; Code: +;; So that we can use the edebug spec in `lisp-current-defun-name'. +(require 'edebug) + ;; Variables for customization ;; --------------------------- ;; diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index fd1af75ba3f..d3e78aa1d7e 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el @@ -330,5 +330,28 @@ Expected initialization file: `%s'\" (faceup-clean-buffer) (should (faceup-test-font-lock-buffer 'emacs-lisp-mode faceup))))) +(ert-deftest test-lisp-current-defun-name () + (require 'edebug) + (with-temp-buffer + (emacs-lisp-mode) + (insert "(defun foo ()\n'bar)\n") + (goto-char 5) + (should (equal (lisp-current-defun-name) "foo"))) + (with-temp-buffer + (emacs-lisp-mode) + (insert "(define-flabbergast-test zot ()\n'bar)\n") + (goto-char 5) + (should (equal (lisp-current-defun-name) "zot"))) + (with-temp-buffer + (emacs-lisp-mode) + (insert "(progn\n ;; comment\n ;; about that\n (define-key ...)\n )") + (goto-char 5) + (should (equal (lisp-current-defun-name) "progn"))) + (with-temp-buffer + (emacs-lisp-mode) + (insert "(defblarg \"a\" 'b)") + (goto-char 5) + (should (equal (lisp-current-defun-name) "defblarg")))) + (provide 'lisp-mode-tests) ;;; lisp-mode-tests.el ends here -- cgit v1.2.3 From 909931cb9ad7251393a81076e9020225fe82845e Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 8 Aug 2022 15:52:53 +0200 Subject: Further lisp-current-defun-name tweaks * lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): Further tweaks to finding the symbol being defined (defalias). --- lisp/emacs-lisp/lisp-mode.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 2e7f019aa9e..82afa31ef12 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -776,8 +776,12 @@ decided heuristically.)" (when (and (not name) (string-match-p "\\`def" (symbol-name symbol))) (when-let ((candidate (ignore-errors (read (current-buffer))))) - (when (symbolp candidate) - (setq name candidate)))) + (cond + ((symbolp candidate) + (setq name candidate)) + ((and (consp candidate) + (symbolp (car (delete 'quote candidate)))) + (setq name (car (delete 'quote candidate))))))) (when-let ((result (or name symbol))) (symbol-name result))))))) -- cgit v1.2.3 From fe4fd160a20e2935b9a6aba4dc5dfbb5e26fdfe1 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Tue, 9 Aug 2022 03:55:14 +0200 Subject: Another lisp-current-defun-name tweak * lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): Avoid error when edebug spec is the symbol t. --- lisp/emacs-lisp/lisp-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 82afa31ef12..1bc2c0ece6d 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -762,7 +762,7 @@ decided heuristically.)" (when symbol (let ((spec (get symbol 'edebug-form-spec))) (save-excursion - (when (and (eq (car spec) '&define) + (when (and (eq (car-safe spec) '&define) (memq 'name spec)) (pop spec) (while (and spec (not name)) -- cgit v1.2.3 From b2bf91003db3bc2171c566ed710ec34d4a55c064 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 9 Aug 2022 19:19:29 +0200 Subject: Further lisp-current-defun-name tweaks * lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): Tweak so that cl-defmethod and friends work again. --- lisp/emacs-lisp/lisp-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 1bc2c0ece6d..c31fbec640c 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -774,7 +774,7 @@ decided heuristically.)" ;; name). If the symbol starts with \"def\", then it's ;; likely that the next symbol is the name. (when (and (not name) - (string-match-p "\\`def" (symbol-name symbol))) + (string-match-p "\\(\\`\\|-\\)def" (symbol-name symbol))) (when-let ((candidate (ignore-errors (read (current-buffer))))) (cond ((symbolp candidate) -- cgit v1.2.3 From 90b4ee6575e79da9922433dca17f14e9303676ca Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 15 Aug 2022 07:30:11 +0200 Subject: Further lisp-current-defun-name tweaks * lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): Further tweaks to make (autoload 'foo) work again. Perhaps this should all be reverted to the original version and then given a new rething. --- lisp/emacs-lisp/lisp-mode.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index c31fbec640c..c56a9660e7c 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -760,7 +760,9 @@ decided heuristically.)" ;; If there's an edebug spec, use that to determine what the ;; name is. (when symbol - (let ((spec (get symbol 'edebug-form-spec))) + (let ((spec (or (get symbol 'edebug-form-spec) + (and (eq (get symbol 'lisp-indent-function) 'defun) + (get 'defun 'edebug-form-spec))))) (save-excursion (when (and (eq (car-safe spec) '&define) (memq 'name spec)) @@ -768,6 +770,9 @@ decided heuristically.)" (while (and spec (not name)) (let ((candidate (ignore-errors (read (current-buffer))))) (when (eq (pop spec) 'name) + (when (and (consp candidate) + (symbolp (car (delete 'quote candidate)))) + (setq candidate (car (delete 'quote candidate)))) (setq name candidate spec nil)))))))) ;; We didn't have an edebug spec (or couldn't find the @@ -783,7 +788,7 @@ decided heuristically.)" (symbolp (car (delete 'quote candidate)))) (setq name (car (delete 'quote candidate))))))) (when-let ((result (or name symbol))) - (symbol-name result))))))) + (and (symbolp result) (symbol-name result)))))))) (defvar-keymap lisp-mode-shared-map :doc "Keymap for commands shared by all sorts of Lisp modes." -- cgit v1.2.3 From 48b0f2606b91dd2a063bef992a2beb13e0f6281b Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 23 Aug 2022 12:26:24 +0200 Subject: Revert the changes to lisp-current-defun-name * lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): Revert back to the old version before bug#49592. The new approach just doesn't work well enough -- we don't really have the data to know that, say, `make-obsolete-variable' is about the second symbol and not the first. --- lisp/emacs-lisp/lisp-mode.el | 73 +++++++++++--------------------------------- 1 file changed, 18 insertions(+), 55 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index c56a9660e7c..c906ee6e31d 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -728,67 +728,30 @@ font-lock keywords will not be case sensitive." len)))) (defun lisp-current-defun-name () - "Return the name of the defun at point. -If there is no defun at point, return the first symbol from the -top-level form. If there is no top-level form, return nil. - -(\"defun\" here means \"form that defines something\", and is -decided heuristically.)" + "Return the name of the defun at point, or nil." (save-excursion - (let ((location (point)) - name) + (let ((location (point))) ;; If we are now precisely at the beginning of a defun, make sure ;; beginning-of-defun finds that one rather than the previous one. - (unless (eobp) - (forward-char 1)) + (or (eobp) (forward-char 1)) (beginning-of-defun) ;; Make sure we are really inside the defun found, not after it. - (when (and (looking-at "(") - (progn - (end-of-defun) - (< location (point))) - (progn - (forward-sexp -1) - (>= location (point)))) - (when (looking-at "(") - (forward-char 1)) - ;; Read the defining construct name, typically "defun" or + (when (and (looking-at "\\s(") + (progn (end-of-defun) + (< location (point))) + (progn (forward-sexp -1) + (>= location (point)))) + (if (looking-at "\\s(") + (forward-char 1)) + ;; Skip the defining construct name, typically "defun" or ;; "defvar". - (let ((symbol (ignore-errors (read (current-buffer))))) - (when (and symbol (not (symbolp symbol))) - (setq symbol nil)) - ;; If there's an edebug spec, use that to determine what the - ;; name is. - (when symbol - (let ((spec (or (get symbol 'edebug-form-spec) - (and (eq (get symbol 'lisp-indent-function) 'defun) - (get 'defun 'edebug-form-spec))))) - (save-excursion - (when (and (eq (car-safe spec) '&define) - (memq 'name spec)) - (pop spec) - (while (and spec (not name)) - (let ((candidate (ignore-errors (read (current-buffer))))) - (when (eq (pop spec) 'name) - (when (and (consp candidate) - (symbolp (car (delete 'quote candidate)))) - (setq candidate (car (delete 'quote candidate)))) - (setq name candidate - spec nil)))))))) - ;; We didn't have an edebug spec (or couldn't find the - ;; name). If the symbol starts with \"def\", then it's - ;; likely that the next symbol is the name. - (when (and (not name) - (string-match-p "\\(\\`\\|-\\)def" (symbol-name symbol))) - (when-let ((candidate (ignore-errors (read (current-buffer))))) - (cond - ((symbolp candidate) - (setq name candidate)) - ((and (consp candidate) - (symbolp (car (delete 'quote candidate)))) - (setq name (car (delete 'quote candidate))))))) - (when-let ((result (or name symbol))) - (and (symbolp result) (symbol-name result)))))))) + (forward-sexp 1) + ;; The second element is usually a symbol being defined. If it + ;; is not, use the first symbol in it. + (skip-chars-forward " \t\n'(") + (buffer-substring-no-properties (point) + (progn (forward-sexp 1) + (point))))))) (defvar-keymap lisp-mode-shared-map :doc "Keymap for commands shared by all sorts of Lisp modes." -- cgit v1.2.3