1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-15 17:00:26 +00: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
;;
(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.

View File

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

View File

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

View File

@ -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 <package>-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)

View File

@ -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

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

View File

@ -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

View File

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

View File

@ -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"))
"\\)\\>[^>]*>")
. ("</" 1 ">"))
("<! *--" . "-- *>")
("<" . ">"))))

View File

@ -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."

View File

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

View File

@ -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