mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-10 08:10:21 -08:00
Remove subsumed repetitions in regexps
Make regexps smaller and faster by removing terms that are superfluous by virtue of standing next to another term that matches more. See https://lists.gnu.org/archive/html/emacs-devel/2020-01/msg00949.html for details. * lisp/bs.el (bs--make-header-match-string): * lisp/gnus/deuglify.el (gnus-outlook-repair-attribution-block): * lisp/gnus/message.el (message-subject-trailing-was-ask-regexp) (message-subject-trailing-was-regexp): * lisp/informat.el (Info-validate): * lisp/net/browse-url.el (browse-url-button-regexp): * lisp/net/rcirc.el (rcirc-url-regexp): * lisp/org/ob-core.el (org-babel-remove-result): * lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap): * lisp/org/org-capture.el (org-capture-set-target-location): * lisp/org/org-table.el (org-table-expand-lhs-ranges): * lisp/org/org.el (org-maybe-keyword-time-regexp, org-ts-regexp) (org-ts-regexp-inactive, org-ts-regexp-both): * lisp/play/gametree.el (gametree-hack-file-layout): * lisp/progmodes/cc-mode.el (c-Java-defun-prompt-regexp): * lisp/progmodes/idlw-shell.el (idlwave-shell-halting-error): * lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding): * lisp/progmodes/verilog-mode.el (verilog-error-font-lock-keywords) (verilog-verilint-off, verilog-case-indent-level) (verilog-within-translate-off, verilog-start-translate-off) (verilog-back-to-start-translate-off, verilog-end-translate-off) (verilog-expand-dirnames): * lisp/term.el (term-control-seq-regexp): * lisp/textmodes/reftex-vars.el (featurep): * lisp/url/url-gw.el (url-open-telnet): * lisp/vc/ediff-ptch.el (ediff-context-diff-label-regexp): * lisp/vc/pcvs-parse.el (cvs-parse-status): * test/src/regex-emacs-tests.el (regex-tests-PCRE): Remove subsumed repetitions. * lisp/progmodes/sh-script.el (sh-syntax-propertize-function): Simplify repetition of a repetition.
This commit is contained in:
parent
8dc4034ed6
commit
770f76f050
23 changed files with 42 additions and 37 deletions
|
|
@ -2437,7 +2437,7 @@ INFO may provide the values of these header arguments (in the
|
|||
(when location
|
||||
(save-excursion
|
||||
(goto-char location)
|
||||
(when (looking-at (concat org-babel-result-regexp ".*$"))
|
||||
(when (looking-at org-babel-result-regexp)
|
||||
(delete-region
|
||||
(if keep-keyword (line-beginning-position 2)
|
||||
(save-excursion
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ its header arguments."
|
|||
|
||||
(defun org-babel-fortran-ensure-main-wrap (body params)
|
||||
"Wrap body in a \"program ... end program\" block if none exists."
|
||||
(if (string-match "^[ \t]*program[ \t]*.*" (capitalize body))
|
||||
(if (string-match "^[ \t]*program\\>" (capitalize body))
|
||||
(let ((vars (org-babel--get-vars params)))
|
||||
(when vars (error "Cannot use :vars if `program' statement is present"))
|
||||
body)
|
||||
|
|
|
|||
|
|
@ -1021,7 +1021,7 @@ Store them in the capture property list."
|
|||
(apply #'encode-time 0 0
|
||||
org-extend-today-until
|
||||
(cl-cdddr (decode-time prompt-time))))
|
||||
((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)"
|
||||
((string-match "\\([^ ]+\\)-[^ ]+[ ]+\\(.*\\)"
|
||||
org-read-date-final-answer)
|
||||
;; Replace any time range by its start.
|
||||
(apply #'encode-time
|
||||
|
|
|
|||
|
|
@ -3099,7 +3099,7 @@ function assumes the table is already analyzed (i.e., using
|
|||
(let ((lhs (car e))
|
||||
(rhs (cdr e)))
|
||||
(cond
|
||||
((string-match-p "\\`@-?[-+0-9]+\\$-?[0-9]+\\'" lhs)
|
||||
((string-match-p "\\`@[-+0-9]+\\$-?[0-9]+\\'" lhs)
|
||||
;; This just refers to one fixed field.
|
||||
(push e res))
|
||||
((string-match-p "\\`[a-zA-Z][_a-zA-Z0-9]*\\'" lhs)
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ Matched keyword is in group 1.")
|
|||
org-clock-string)
|
||||
t)
|
||||
"\\)?"
|
||||
" *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?[]>]"
|
||||
" *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^]\r\n>]*[]>]"
|
||||
"\\|"
|
||||
"<%%([^\r\n>]*>\\)")
|
||||
"Matches a timestamp, possibly preceded by a keyword.")
|
||||
|
|
@ -564,14 +564,14 @@ Effort estimates given in this property need to have the format H:MM.")
|
|||
|
||||
;;;; Timestamp
|
||||
|
||||
(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)>"
|
||||
(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*\\)>"
|
||||
"Regular expression for fast time stamp matching.")
|
||||
|
||||
(defconst org-ts-regexp-inactive
|
||||
"\\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]"
|
||||
"\\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*\\)\\]"
|
||||
"Regular expression for fast inactive time stamp matching.")
|
||||
|
||||
(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?\\)[]>]"
|
||||
(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^]\r\n>]*\\)[]>]"
|
||||
"Regular expression for fast time stamp matching.")
|
||||
|
||||
(defconst org-ts-regexp0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue