Commit 92acab73 authored by Paul Eggert's avatar Paul Eggert

Use regexp-opt-charset to improve regexp tweaks

* lisp/emacs-lisp/regexp-opt.el (regexp-opt):
Reword confusing sentence in doc string.
* lisp/erc/erc.el (erc-lurker-maybe-trim):
* lisp/mail/footnote.el (footnote-hebrew-numeric-regex):
Improve by using regexp-opt-charset.
parent a35a1f6a
Pipeline #1096 failed with stage
in 60 minutes and 1 second
...@@ -86,9 +86,9 @@ ...@@ -86,9 +86,9 @@
;;;###autoload ;;;###autoload
(defun regexp-opt (strings &optional paren keep-order) (defun regexp-opt (strings &optional paren keep-order)
"Return a regexp to match a string in the list STRINGS. "Return a regexp to match a string in the list STRINGS.
Each string should be unique in STRINGS and should not contain Each member of STRINGS is treated as a fixed string, not as a regexp.
any regexps, quoted or not. Optional PAREN specifies how the Optional PAREN specifies how the returned regexp is surrounded by
returned regexp is surrounded by grouping constructs. grouping constructs.
If STRINGS is the empty list, the return value is a regexp that If STRINGS is the empty list, the return value is a regexp that
never matches anything. never matches anything.
......
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
(load "erc-loaddefs" nil t) (load "erc-loaddefs" nil t)
(eval-when-compile (require 'cl-lib)) (eval-when-compile (require 'cl-lib))
(require 'cl-seq)
(require 'font-lock) (require 'font-lock)
(require 'pp) (require 'pp)
(require 'thingatpt) (require 'thingatpt)
...@@ -2523,8 +2522,7 @@ Returns NICK unmodified unless `erc-lurker-trim-nicks' is ...@@ -2523,8 +2522,7 @@ Returns NICK unmodified unless `erc-lurker-trim-nicks' is
non-nil." non-nil."
(if erc-lurker-trim-nicks (if erc-lurker-trim-nicks
(replace-regexp-in-string (replace-regexp-in-string
(regexp-opt (cl-delete-duplicates (regexp-opt-charset (string-to-list erc-lurker-ignore-chars))
(mapcar #'char-to-string erc-lurker-ignore-chars)))
"" nick) "" nick)
nick)) nick))
......
...@@ -64,7 +64,6 @@ ...@@ -64,7 +64,6 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'cl-lib)) (eval-when-compile (require 'cl-lib))
(require 'cl-seq)
(defvar filladapt-token-table) (defvar filladapt-token-table)
(defgroup footnote nil (defgroup footnote nil
...@@ -364,9 +363,9 @@ Use Unicode characters for footnoting." ...@@ -364,9 +363,9 @@ Use Unicode characters for footnoting."
("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק"))) ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק")))
(defconst footnote-hebrew-numeric-regex (defconst footnote-hebrew-numeric-regex
(concat "[" (cl-delete-duplicates (let ((numchars (string-to-list
(apply #'concat (apply #'append footnote-hebrew-numeric))) (apply #'concat (apply #'append footnote-hebrew-numeric)))))
"']+")) (concat (regexp-opt-charset (cons ?' numchars)) "+")))
;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?") ;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?")
(defun footnote--hebrew-numeric (n) (defun footnote--hebrew-numeric (n)
...@@ -464,6 +463,11 @@ Conversion is done based upon the current selected style." ...@@ -464,6 +463,11 @@ Conversion is done based upon the current selected style."
(nth 0 footnote-style-alist))))) (nth 0 footnote-style-alist)))))
(concat (concat
;; Hack to avoid repetition of repetition. ;; Hack to avoid repetition of repetition.
;; FIXME: I'm not sure the added * makes sense at all; there is
;; always a single number within the footnote-{start,end}-tag pairs.
;; Worse, the code goes on and adds yet another + later on, in
;; footnote-refresh-footnotes, just in case. That makes even less sense.
;; Likely, both the * and the extra + should go away.
(if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp) (if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp)
(substring regexp 0 -1) (substring regexp 0 -1)
regexp) regexp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment