aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-02-20 15:45:44 +0100
committerMattias EngdegÄrd2020-02-20 16:05:18 +0100
commit770f76f050376bbd77a3cc8cf44db57cf855a27c (patch)
tree9cfc115c6130b67939865c7e56d92075eff6484a /lisp/progmodes
parent8dc4034ed6f86455c294f22a3d345b00cd4aa143 (diff)
downloademacs-770f76f050376bbd77a3cc8cf44db57cf855a27c.tar.gz
emacs-770f76f050376bbd77a3cc8cf44db57cf855a27c.zip
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.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-mode.el2
-rw-r--r--lisp/progmodes/idlw-shell.el2
-rw-r--r--lisp/progmodes/ruby-mode.el2
-rw-r--r--lisp/progmodes/sh-script.el2
-rw-r--r--lisp/progmodes/verilog-mode.el18
5 files changed, 13 insertions, 13 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 7496684d939..9c62b2bb065 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2671,7 +2671,7 @@ Key bindings:
2671;; since it's practically impossible to write a regexp that reliably 2671;; since it's practically impossible to write a regexp that reliably
2672;; matches such a construct. Other tools are necessary. 2672;; matches such a construct. Other tools are necessary.
2673(defconst c-Java-defun-prompt-regexp 2673(defconst c-Java-defun-prompt-regexp
2674 "^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()\^?=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f\v]*\\)+\\)?\\s-*") 2674 "^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()\^?=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f\v]*\\)+\\)?\\s-*")
2675 2675
2676(easy-menu-define c-java-menu java-mode-map "Java Mode Commands" 2676(easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
2677 (cons "Java" (c-lang-const c-mode-menu java))) 2677 (cons "Java" (c-lang-const c-mode-menu java)))
diff --git a/lisp/progmodes/idlw-shell.el b/lisp/progmodes/idlw-shell.el
index dba70cb2821..6770fbe8abc 100644
--- a/lisp/progmodes/idlw-shell.el
+++ b/lisp/progmodes/idlw-shell.el
@@ -1598,7 +1598,7 @@ number.")
1598 "A regular expression to match any IDL error.") 1598 "A regular expression to match any IDL error.")
1599 1599
1600(defvar idlwave-shell-halting-error 1600(defvar idlwave-shell-halting-error
1601 "^% .*\n\\([^%].*\n\\)*% Execution halted at:\\(\\s-*\\S-+\\s-*[0-9]+\\s-*.*\\)\n" 1601 "^% .*\n\\([^%].*\n\\)*% Execution halted at:\\(\\s-*\\S-+\\s-*[0-9]+.*\\)\n"
1602 "A regular expression to match errors which halt execution.") 1602 "A regular expression to match errors which halt execution.")
1603 1603
1604(defvar idlwave-shell-cant-continue-error 1604(defvar idlwave-shell-cant-continue-error
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 5da5577c108..e16225c7fa9 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -801,7 +801,7 @@ The style of the comment is controlled by `ruby-encoding-magic-comment-style'."
801 (let ((coding-system (ruby--detect-encoding))) 801 (let ((coding-system (ruby--detect-encoding)))
802 (when coding-system 802 (when coding-system
803 (if (looking-at "^#!") (beginning-of-line 2)) 803 (if (looking-at "^#!") (beginning-of-line 2))
804 (cond ((looking-at "\\s *#\\s *.*\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)") 804 (cond ((looking-at "\\s *#.*\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)")
805 ;; update existing encoding comment if necessary 805 ;; update existing encoding comment if necessary
806 (unless (string= (match-string 2) coding-system) 806 (unless (string= (match-string 2) coding-system)
807 (goto-char (match-beginning 2)) 807 (goto-char (match-beginning 2))
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index a241a1e69ba..044d7820ee3 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1096,7 +1096,7 @@ subshells can nest."
1096 (")" (0 (sh-font-lock-paren (match-beginning 0)))) 1096 (")" (0 (sh-font-lock-paren (match-beginning 0))))
1097 ;; Highlight (possibly nested) subshells inside "" quoted 1097 ;; Highlight (possibly nested) subshells inside "" quoted
1098 ;; regions correctly. 1098 ;; regions correctly.
1099 ("\"\\(?:\\(?:[^\\\"]\\|\\\\.\\)*?\\)??\\(\\$(\\|`\\)" 1099 ("\"\\(?:[^\\\"]\\|\\\\.\\)*?\\(\\$(\\|`\\)"
1100 (1 (ignore 1100 (1 (ignore
1101 (if (nth 8 (save-excursion (syntax-ppss (match-beginning 0)))) 1101 (if (nth 8 (save-excursion (syntax-ppss (match-beginning 0))))
1102 (goto-char (1+ (match-beginning 0))) 1102 (goto-char (1+ (match-beginning 0)))
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 460957b7161..cc601601193 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -958,8 +958,8 @@ See `compilation-error-regexp-alist-alist' for the formatting. For XEmacs.")
958 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t) 958 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t)
959 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) 959 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
960 ;; verilog-verilator 960 ;; verilog-verilator
961 (".*%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t) 961 (".*\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t)
962 (".*%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t) 962 (".*\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t)
963 ;; verilog-leda 963 ;; verilog-leda
964 ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 bold t) 964 ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 bold t)
965 ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 2 bold t) 965 ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 2 bold t)
@@ -5345,7 +5345,7 @@ becomes:
5345 (interactive) 5345 (interactive)
5346 (save-excursion 5346 (save-excursion
5347 (beginning-of-line) 5347 (beginning-of-line)
5348 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$") 5348 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\).*$")
5349 (replace-match (format 5349 (replace-match (format
5350 ;; %3s makes numbers 1-999 line up nicely 5350 ;; %3s makes numbers 1-999 line up nicely
5351 "\\1//Verilint %3s off // WARNING: \\3" 5351 "\\1//Verilint %3s off // WARNING: \\3"
@@ -6788,7 +6788,7 @@ Do not count named blocks or case-statements."
6788 ((looking-at verilog-named-block-re) 6788 ((looking-at verilog-named-block-re)
6789 (current-column)) 6789 (current-column))
6790 ((and (not (looking-at verilog-extended-case-re)) 6790 ((and (not (looking-at verilog-extended-case-re))
6791 (looking-at "^[^:;]+[ \t]*:")) 6791 (looking-at "^[^:;]+:"))
6792 (verilog-re-search-forward ":" nil t) 6792 (verilog-re-search-forward ":" nil t)
6793 (skip-chars-forward " \t") 6793 (skip-chars-forward " \t")
6794 (current-column)) 6794 (current-column))
@@ -7782,7 +7782,7 @@ If search fails, other files are checked based on
7782 "Return point if within translate-off region, else nil." 7782 "Return point if within translate-off region, else nil."
7783 (and (save-excursion 7783 (and (save-excursion
7784 (re-search-backward 7784 (re-search-backward
7785 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>") 7785 (concat "//.*" verilog-directive-regexp "\\(on\\|off\\)\\>")
7786 nil t)) 7786 nil t))
7787 (equal "off" (match-string 2)) 7787 (equal "off" (match-string 2))
7788 (point))) 7788 (point)))
@@ -7790,14 +7790,14 @@ If search fails, other files are checked based on
7790(defun verilog-start-translate-off (limit) 7790(defun verilog-start-translate-off (limit)
7791 "Return point before translate-off directive if before LIMIT, else nil." 7791 "Return point before translate-off directive if before LIMIT, else nil."
7792 (when (re-search-forward 7792 (when (re-search-forward
7793 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") 7793 (concat "//.*" verilog-directive-regexp "off\\>")
7794 limit t) 7794 limit t)
7795 (match-beginning 0))) 7795 (match-beginning 0)))
7796 7796
7797(defun verilog-back-to-start-translate-off (limit) 7797(defun verilog-back-to-start-translate-off (limit)
7798 "Return point before translate-off directive if before LIMIT, else nil." 7798 "Return point before translate-off directive if before LIMIT, else nil."
7799 (when (re-search-backward 7799 (when (re-search-backward
7800 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") 7800 (concat "//.*" verilog-directive-regexp "off\\>")
7801 limit t) 7801 limit t)
7802 (match-beginning 0))) 7802 (match-beginning 0)))
7803 7803
@@ -7805,7 +7805,7 @@ If search fails, other files are checked based on
7805 "Return point after translate-on directive if before LIMIT, else nil." 7805 "Return point after translate-on directive if before LIMIT, else nil."
7806 7806
7807 (re-search-forward (concat 7807 (re-search-forward (concat
7808 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t)) 7808 "//.*" verilog-directive-regexp "on\\>") limit t))
7809 7809
7810(defun verilog-match-translate-off (limit) 7810(defun verilog-match-translate-off (limit)
7811 "Match a translate-off block, setting `match-data' and returning t, else nil. 7811 "Match a translate-off block, setting `match-data' and returning t, else nil.
@@ -9982,7 +9982,7 @@ Or, just the existing dirnames themselves if there are no wildcards."
9982 (while dirnames 9982 (while dirnames
9983 (setq dirname (car dirnames) 9983 (setq dirname (car dirnames)
9984 dirnames (cdr dirnames)) 9984 dirnames (cdr dirnames))
9985 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ; root 9985 (cond ((string-match (concat "^\\(\\|[^*?]*[/\\]\\)" ; root
9986 "\\([^/\\]*[*?][^/\\]*\\)" ; filename with *? 9986 "\\([^/\\]*[*?][^/\\]*\\)" ; filename with *?
9987 "\\(.*\\)") ; rest 9987 "\\(.*\\)") ; rest
9988 dirname) 9988 dirname)