emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 92acab7: Use regexp-opt-charset to improve regexp t


From: Paul Eggert
Subject: [Emacs-diffs] master 92acab7: Use regexp-opt-charset to improve regexp tweaks
Date: Wed, 27 Mar 2019 14:37:53 -0400 (EDT)

branch: master
commit 92acab73e0dd3921b53eac4f3fba327b7aa4d3aa
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 lisp/emacs-lisp/regexp-opt.el |  6 +++---
 lisp/erc/erc.el               |  4 +---
 lisp/mail/footnote.el         | 12 ++++++++----
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index fce6a47..d883752 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -86,9 +86,9 @@
 ;;;###autoload
 (defun regexp-opt (strings &optional paren keep-order)
   "Return a regexp to match a string in the list STRINGS.
-Each string should be unique in STRINGS and should not contain
-any regexps, quoted or not.  Optional PAREN specifies how the
-returned regexp is surrounded by grouping constructs.
+Each member of STRINGS is treated as a fixed string, not as a regexp.
+Optional PAREN specifies how the returned regexp is surrounded by
+grouping constructs.
 
 If STRINGS is the empty list, the return value is a regexp that
 never matches anything.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index e34487d..d1fa5c7 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -67,7 +67,6 @@
 (load "erc-loaddefs" nil t)
 
 (eval-when-compile (require 'cl-lib))
-(require 'cl-seq)
 (require 'font-lock)
 (require 'pp)
 (require 'thingatpt)
@@ -2523,8 +2522,7 @@ Returns NICK unmodified unless `erc-lurker-trim-nicks' is
 non-nil."
   (if erc-lurker-trim-nicks
       (replace-regexp-in-string
-       (regexp-opt (cl-delete-duplicates
-                   (mapcar #'char-to-string erc-lurker-ignore-chars)))
+       (regexp-opt-charset (string-to-list erc-lurker-ignore-chars))
        "" nick)
     nick))
 
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el
index 7f88e30..81dc11d 100644
--- a/lisp/mail/footnote.el
+++ b/lisp/mail/footnote.el
@@ -64,7 +64,6 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
-(require 'cl-seq)
 (defvar filladapt-token-table)
 
 (defgroup footnote nil
@@ -364,9 +363,9 @@ Use Unicode characters for footnoting."
     ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק")))
 
 (defconst footnote-hebrew-numeric-regex
-  (concat "[" (cl-delete-duplicates
-              (apply #'concat (apply #'append footnote-hebrew-numeric)))
-         "']+"))
+  (let ((numchars (string-to-list
+                  (apply #'concat (apply #'append footnote-hebrew-numeric)))))
+    (concat (regexp-opt-charset (cons ?' numchars)) "+")))
 ;; (defconst footnote-hebrew-numeric-regex 
"\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?")
 
 (defun footnote--hebrew-numeric (n)
@@ -464,6 +463,11 @@ Conversion is done based upon the current selected style."
                           (nth 0 footnote-style-alist)))))
     (concat
      ;; 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)
         (substring regexp 0 -1)
        regexp)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]