1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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.
This commit is contained in:
Mattias Engdegård 2022-07-04 14:52:50 +02:00
parent 544361d37f
commit 1268902db1
12 changed files with 141 additions and 162 deletions

View file

@ -37,25 +37,24 @@
;;; Lexical analysis ;;; Lexical analysis
;; ;;
(defconst semantic-java-number-regexp (defconst semantic-java-number-regexp
(eval-when-compile (concat "\\("
(concat "\\(" "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
"\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" "\\|"
"\\|" "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>"
"\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" "\\|"
"\\|" "\\<[0-9]+[.][fFdD]\\>"
"\\<[0-9]+[.][fFdD]\\>" "\\|"
"\\|" "\\<[0-9]+[.]"
"\\<[0-9]+[.]" "\\|"
"\\|" "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
"[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" "\\|"
"\\|" "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>"
"\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" "\\|"
"\\|" "\\<0[xX][[:xdigit:]]+[lL]?\\>"
"\\<0[xX][[:xdigit:]]+[lL]?\\>" "\\|"
"\\|" "\\<[0-9]+[lLfFdD]?\\>"
"\\<[0-9]+[lLfFdD]?\\>" "\\)"
"\\)" )
))
"Lexer regexp to match Java number terminals. "Lexer regexp to match Java number terminals.
Following is the specification of Java number literals. Following is the specification of Java number literals.

View file

@ -574,25 +574,24 @@ may need to be overridden for some special languages.")
(defvar-local semantic-lex-number-expression (defvar-local semantic-lex-number-expression
;; This expression was written by David Ponce for Java, and copied ;; This expression was written by David Ponce for Java, and copied
;; here for C and any other similar language. ;; here for C and any other similar language.
(eval-when-compile (concat "\\("
(concat "\\(" "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
"\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" "\\|"
"\\|" "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>"
"\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>" "\\|"
"\\|" "\\<[0-9]+[.][fFdD]\\>"
"\\<[0-9]+[.][fFdD]\\>" "\\|"
"\\|" "\\<[0-9]+[.]"
"\\<[0-9]+[.]" "\\|"
"\\|" "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
"[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>" "\\|"
"\\|" "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>"
"\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>" "\\|"
"\\|" "\\<0[xX][[:xdigit:]]+[lL]?\\>"
"\\<0[xX][[:xdigit:]]+[lL]?\\>" "\\|"
"\\|" "\\<[0-9]+[lLfFdD]?\\>"
"\\<[0-9]+[lLfFdD]?\\>" "\\)"
"\\)" )
))
"Regular expression for matching a number. "Regular expression for matching a number.
If this value is nil, no number extraction is done during lex. If this value is nil, no number extraction is done during lex.
This expression tries to match C and Java like numbers. This expression tries to match C and Java like numbers.

View file

@ -378,10 +378,9 @@ instead."
function) function)
(setq tentative-defun t)) (setq tentative-defun t))
((string-match ((string-match
(eval-when-compile (concat "\\`\\("
(concat "\\`\\(" (regexp-opt '("with" "without" "do"))
(regexp-opt '("with" "without" "do")) "\\)-")
"\\)-"))
function) function)
(setq method '(&lambda &body)))))) (setq method '(&lambda &body))))))
;; backwards compatibility. Bletch. ;; backwards compatibility. Bletch.

View file

@ -100,48 +100,45 @@
(list (list
(list nil (list nil
(purecopy (concat "^\\s-*(" (purecopy (concat "^\\s-*("
(eval-when-compile (regexp-opt
(regexp-opt '("defun" "defmacro"
'("defun" "defmacro" ;; Elisp.
;; Elisp. "defun*" "defsubst" "define-inline"
"defun*" "defsubst" "define-inline" "define-advice" "defadvice" "define-skeleton"
"define-advice" "defadvice" "define-skeleton" "define-compilation-mode" "define-minor-mode"
"define-compilation-mode" "define-minor-mode" "define-global-minor-mode"
"define-global-minor-mode" "define-globalized-minor-mode"
"define-globalized-minor-mode" "define-derived-mode" "define-generic-mode"
"define-derived-mode" "define-generic-mode" "ert-deftest"
"ert-deftest" "cl-defun" "cl-defsubst" "cl-defmacro"
"cl-defun" "cl-defsubst" "cl-defmacro" "cl-define-compiler-macro" "cl-defgeneric"
"cl-define-compiler-macro" "cl-defgeneric" "cl-defmethod"
"cl-defmethod" ;; CL.
;; CL. "define-compiler-macro" "define-modify-macro"
"define-compiler-macro" "define-modify-macro" "defsetf" "define-setf-expander"
"defsetf" "define-setf-expander" "define-method-combination"
"define-method-combination" ;; CLOS and EIEIO
;; CLOS and EIEIO "defgeneric" "defmethod")
"defgeneric" "defmethod") t)
t))
"\\s-+\\(" (rx lisp-mode-symbol) "\\)")) "\\s-+\\(" (rx lisp-mode-symbol) "\\)"))
2) 2)
;; Like the previous, but uses a quoted symbol as the name. ;; Like the previous, but uses a quoted symbol as the name.
(list nil (list nil
(purecopy (concat "^\\s-*(" (purecopy (concat "^\\s-*("
(eval-when-compile (regexp-opt
(regexp-opt '("defalias" "define-obsolete-function-alias")
'("defalias" "define-obsolete-function-alias") t)
t))
"\\s-+'\\(" (rx lisp-mode-symbol) "\\)")) "\\s-+'\\(" (rx lisp-mode-symbol) "\\)"))
2) 2)
(list (purecopy "Variables") (list (purecopy "Variables")
(purecopy (concat "^\\s-*(" (purecopy (concat "^\\s-*("
(eval-when-compile (regexp-opt
(regexp-opt '(;; Elisp
'(;; Elisp "defconst" "defcustom"
"defconst" "defcustom" ;; CL
;; CL "defconstant"
"defconstant" "defparameter" "define-symbol-macro")
"defparameter" "define-symbol-macro") t)
t))
"\\s-+\\(" (rx lisp-mode-symbol) "\\)")) "\\s-+\\(" (rx lisp-mode-symbol) "\\)"))
2) 2)
;; For `defvar'/`defvar-local', we ignore (defvar FOO) constructs. ;; For `defvar'/`defvar-local', we ignore (defvar FOO) constructs.
@ -152,18 +149,17 @@
1) 1)
(list (purecopy "Types") (list (purecopy "Types")
(purecopy (concat "^\\s-*(" (purecopy (concat "^\\s-*("
(eval-when-compile (regexp-opt
(regexp-opt '(;; Elisp
'(;; Elisp "defgroup" "deftheme"
"defgroup" "deftheme" "define-widget" "define-error"
"define-widget" "define-error" "defface" "cl-deftype" "cl-defstruct"
"defface" "cl-deftype" "cl-defstruct" ;; CL
;; CL "deftype" "defstruct"
"deftype" "defstruct" "define-condition" "defpackage"
"define-condition" "defpackage" ;; CLOS and EIEIO
;; CLOS and EIEIO "defclass")
"defclass") t)
t))
"\\s-+'?\\(" (rx lisp-mode-symbol) "\\)")) "\\s-+'?\\(" (rx lisp-mode-symbol) "\\)"))
2)) 2))
@ -273,8 +269,7 @@ to a package-local <package>-loaddefs.el file.")
;; FIXME: Move to elisp-mode.el. ;; FIXME: Move to elisp-mode.el.
(catch 'found (catch 'found
(while (re-search-forward (while (re-search-forward
(eval-when-compile (concat "(\\(" (rx lisp-mode-symbol) "\\)\\_>")
(concat "(\\(" (rx lisp-mode-symbol) "\\)\\_>"))
limit t) limit t)
(let ((sym (intern-soft (match-string 1)))) (let ((sym (intern-soft (match-string 1))))
(when (and (or (special-form-p sym) (macrop sym)) (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.") "Gaudy highlighting from Emacs Lisp mode used in Backtrace mode.")
(defun lisp-string-in-doc-position-p (listbeg startpos) (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 LISTBEG is the position of the start of the innermost list
containing STARTPOS." containing STARTPOS."
(let* ((firstsym (and listbeg (let* ((firstsym (and listbeg
(save-excursion (save-excursion
(goto-char listbeg) (goto-char listbeg)
(and (looking-at (and (looking-at
(eval-when-compile (concat "([ \t\n]*\\("
(concat "([ \t\n]*\\(" (rx lisp-mode-symbol) "\\)"))
(rx lisp-mode-symbol) "\\)")))
(match-string 1))))) (match-string 1)))))
(docelt (and firstsym (docelt (and firstsym
(function-get (intern-soft firstsym) (function-get (intern-soft firstsym)

View file

@ -61,8 +61,7 @@
(defun shorthands-font-lock-shorthands (limit) (defun shorthands-font-lock-shorthands (limit)
(when read-symbol-shorthands (when read-symbol-shorthands
(while (re-search-forward (while (re-search-forward
(eval-when-compile (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>")
(concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>"))
limit t) limit t)
(let* ((existing (get-text-property (match-beginning 1) 'face)) (let* ((existing (get-text-property (match-beginning 1) 'face))
(probe (and (not (memq existing '(font-lock-comment-face (probe (and (not (memq existing '(font-lock-comment-face

View file

@ -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)) (setq version (process-get proc 'socks-server-protocol))
(cond (cond
((equal version 'http) ((equal version 'http)
(setq request (format (eval-when-compile (setq request (format (concat
(concat "CONNECT %s:%d HTTP/1.0\r\n"
"CONNECT %s:%d HTTP/1.0\r\n" "User-Agent: Emacs/SOCKS v1.0\r\n"
"User-Agent: Emacs/SOCKS v1.0\r\n" "\r\n")
"\r\n"))
(cond (cond
((equal atype socks-address-type-name) address) ((equal atype socks-address-type-name) address)
(t (t

View file

@ -108,30 +108,27 @@
(macro-keywords-2 (macro-keywords-2
"\\(primarydef\\|secondarydef\\|tertiarydef\\)") "\\(primarydef\\|secondarydef\\|tertiarydef\\)")
(args-keywords (args-keywords
(eval-when-compile (regexp-opt
(regexp-opt '("expr" "suffix" "text" "primary" "secondary" "tertiary")
'("expr" "suffix" "text" "primary" "secondary" "tertiary") t))
t)))
(type-keywords (type-keywords
(eval-when-compile (regexp-opt
(regexp-opt '("boolean" "color" "numeric" "pair" "path" "pen" "picture"
'("boolean" "color" "numeric" "pair" "path" "pen" "picture" "string" "transform" "newinternal")
"string" "transform" "newinternal") t))
t)))
(syntactic-keywords (syntactic-keywords
(eval-when-compile (regexp-opt
(regexp-opt '("for" "forever" "forsuffixes" "endfor"
'("for" "forever" "forsuffixes" "endfor" "step" "until" "upto" "downto" "thru" "within"
"step" "until" "upto" "downto" "thru" "within" "iff" "if" "elseif" "else" "fi" "exitif" "exitunless"
"iff" "if" "elseif" "else" "fi" "exitif" "exitunless" "let" "def" "vardef" "enddef" "mode_def"
"let" "def" "vardef" "enddef" "mode_def" "true" "false" "known" "unknown" "and" "or" "not"
"true" "false" "known" "unknown" "and" "or" "not" "save" "interim" "inner" "outer" "relax"
"save" "interim" "inner" "outer" "relax" "begingroup" "endgroup" "expandafter" "scantokens"
"begingroup" "endgroup" "expandafter" "scantokens" "generate" "input" "endinput" "end" "bye"
"generate" "input" "endinput" "end" "bye" "message" "errmessage" "errhelp" "special" "numspecial"
"message" "errmessage" "errhelp" "special" "numspecial" "readstring" "readfrom" "write")
"readstring" "readfrom" "write") t))
t)))
) )
(list (list
;; embedded TeX code in btex ... etex ;; embedded TeX code in btex ... etex

View file

@ -440,12 +440,11 @@ Useful for shells like zsh that has this feature."
(push (point) begins) (push (point) begins)
(let ((arg ())) (let ((arg ()))
(while (looking-at (while (looking-at
(eval-when-compile (concat
(concat "\\(?:[^\s\t\n\\\"';]+"
"\\(?:[^\s\t\n\\\"';]+" "\\|'\\([^']*\\)'?"
"\\|'\\([^']*\\)'?" "\\|\"\\(\\(?:[^\"\\]\\|\\\\.\\)*\\)\"?"
"\\|\"\\(\\(?:[^\"\\]\\|\\\\.\\)*\\)\"?" "\\|\\\\\\(\\(?:.\\|\n\\)?\\)\\)"))
"\\|\\\\\\(\\(?:.\\|\n\\)?\\)\\)")))
(goto-char (match-end 0)) (goto-char (match-end 0))
(cond (cond
((match-beginning 3) ;Backslash escape. ((match-beginning 3) ;Backslash escape.

View file

@ -600,12 +600,11 @@ Do \\[describe-key] on the following bindings to discover what they do.
(setq-local tildify-foreach-region-function (setq-local tildify-foreach-region-function
(apply-partially (apply-partially
'tildify-foreach-ignore-environments 'tildify-foreach-ignore-environments
`((,(eval-when-compile `((,(concat
(concat "<\\("
"<\\(" (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var"
(regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var" "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR"))
"PRE" "DFN" "CODE" "SAMP" "KBD" "VAR")) "\\)\\>[^>]*>")
"\\)\\>[^>]*>"))
. ("</" 1 ">")) . ("</" 1 ">"))
("<! *--" . "-- *>") ("<! *--" . "-- *>")
("<" . ">")))) ("<" . ">"))))

View file

@ -983,14 +983,13 @@ Inherits `shell-mode-map' with a few additions.")
(when (and slash (not comment)) (when (and slash (not comment))
(setq mode (setq mode
(if (looking-at (if (looking-at
(eval-when-compile (concat
(concat (regexp-opt '("documentstyle" "documentclass"
(regexp-opt '("documentstyle" "documentclass" "begin" "subsection" "section"
"begin" "subsection" "section" "part" "chapter" "newcommand"
"part" "chapter" "newcommand" "renewcommand" "RequirePackage")
"renewcommand" "RequirePackage") 'words)
'words) "\\|NeedsTeXFormat{LaTeX"))
"\\|NeedsTeXFormat{LaTeX")))
(if (and (looking-at (if (and (looking-at
"document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")
;; SliTeX is almost never used any more nowadays. ;; 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 (apply-partially
#'tildify-foreach-ignore-environments #'tildify-foreach-ignore-environments
`(("\\\\\\\\" . "") ; do not remove this `(("\\\\\\\\" . "") ; do not remove this
(,(eval-when-compile (,(concat "\\\\begin{\\("
(concat "\\\\begin{\\(" (regexp-opt '("verbatim" "math" "displaymath"
(regexp-opt '("verbatim" "math" "displaymath" "equation" "eqnarray" "eqnarray*"))
"equation" "eqnarray" "eqnarray*")) "\\)}")
"\\)}"))
. ("\\\\end{" 1 "}")) . ("\\\\end{" 1 "}"))
("\\\\verb\\*?\\(.\\)" . (1)) ("\\\\verb\\*?\\(.\\)" . (1))
("\\$\\$?" . (0)) ("\\$\\$?" . (0))
@ -2126,11 +2124,10 @@ If NOT-ALL is non-nil, save the `.dvi' file."
(defvar tex-compile-history nil) (defvar tex-compile-history nil)
(defvar tex-input-files-re (defvar tex-input-files-re
(eval-when-compile (concat "\\." (regexp-opt '("tex" "texi" "texinfo"
(concat "\\." (regexp-opt '("tex" "texi" "texinfo" "bbl" "ind" "sty" "cls") t)
"bbl" "ind" "sty" "cls") t) ;; Include files with no dots (for directories).
;; Include files with no dots (for directories). "\\'\\|\\`[^.]+\\'"))
"\\'\\|\\`[^.]+\\'")))
(defcustom tex-use-reftex t (defcustom tex-use-reftex t
"If non-nil, use RefTeX's list of files to determine what command to use." "If non-nil, use RefTeX's list of files to determine what command to use."

View file

@ -494,9 +494,8 @@ variable will be set to the representation."
(if (not (string-equal " " (or space tildify-space-string))) (if (not (string-equal " " (or space tildify-space-string)))
(when space (when space
(setq tildify-space-string space)) (setq tildify-space-string space))
(message (eval-when-compile (message (concat "Hard space is a single space character, tildify-"
(concat "Hard space is a single space character, tildify-" "mode won't have any effect, disabling."))
"mode won't have any effect, disabling.")))
(setq tildify-mode nil)))) (setq tildify-mode nil))))
(if tildify-mode (if tildify-mode
(add-hook 'post-self-insert-hook #'tildify-space nil t) (add-hook 'post-self-insert-hook #'tildify-space nil t)

View file

@ -171,13 +171,12 @@ file:///foo/bar.jpg"
;; https://www.freedesktop.org/wiki/Software/xdg-user-dirs/ ;; https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
(defconst xdg-line-regexp (defconst xdg-line-regexp
(eval-when-compile (rx "XDG_"
(rx "XDG_" (group-n 1 (or "DESKTOP" "DOWNLOAD" "TEMPLATES" "PUBLICSHARE"
(group-n 1 (or "DESKTOP" "DOWNLOAD" "TEMPLATES" "PUBLICSHARE" "DOCUMENTS" "MUSIC" "PICTURES" "VIDEOS"))
"DOCUMENTS" "MUSIC" "PICTURES" "VIDEOS")) "_DIR=\""
"_DIR=\"" (group-n 2 (or "/" "$HOME/") (*? (or (not (any "\"")) "\\\"")))
(group-n 2 (or "/" "$HOME/") (*? (or (not (any "\"")) "\\\""))) "\"")
"\""))
"Regexp matching non-comment lines in `xdg-user-dirs' config files.") "Regexp matching non-comment lines in `xdg-user-dirs' config files.")
(defvar xdg-user-dirs nil (defvar xdg-user-dirs nil