diff options
| author | Paul Eggert | 2019-03-27 11:36:13 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-03-27 11:37:47 -0700 |
| commit | 92acab73e0dd3921b53eac4f3fba327b7aa4d3aa (patch) | |
| tree | d853281b0ef547f99b74994bb70caecac9a3f778 | |
| parent | a35a1f6a9406bc98b4ab83489e5dc7843ffacfb6 (diff) | |
| download | emacs-92acab73e0dd3921b53eac4f3fba327b7aa4d3aa.tar.gz emacs-92acab73e0dd3921b53eac4f3fba327b7aa4d3aa.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/regexp-opt.el | 6 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 4 | ||||
| -rw-r--r-- | 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 fce6a47d989..d883752d712 100644 --- a/lisp/emacs-lisp/regexp-opt.el +++ b/lisp/emacs-lisp/regexp-opt.el | |||
| @@ -86,9 +86,9 @@ | |||
| 86 | ;;;###autoload | 86 | ;;;###autoload |
| 87 | (defun regexp-opt (strings &optional paren keep-order) | 87 | (defun regexp-opt (strings &optional paren keep-order) |
| 88 | "Return a regexp to match a string in the list STRINGS. | 88 | "Return a regexp to match a string in the list STRINGS. |
| 89 | Each string should be unique in STRINGS and should not contain | 89 | Each member of STRINGS is treated as a fixed string, not as a regexp. |
| 90 | any regexps, quoted or not. Optional PAREN specifies how the | 90 | Optional PAREN specifies how the returned regexp is surrounded by |
| 91 | returned regexp is surrounded by grouping constructs. | 91 | grouping constructs. |
| 92 | 92 | ||
| 93 | If STRINGS is the empty list, the return value is a regexp that | 93 | If STRINGS is the empty list, the return value is a regexp that |
| 94 | never matches anything. | 94 | never matches anything. |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index e34487de273..d1fa5c7f120 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -67,7 +67,6 @@ | |||
| 67 | (load "erc-loaddefs" nil t) | 67 | (load "erc-loaddefs" nil t) |
| 68 | 68 | ||
| 69 | (eval-when-compile (require 'cl-lib)) | 69 | (eval-when-compile (require 'cl-lib)) |
| 70 | (require 'cl-seq) | ||
| 71 | (require 'font-lock) | 70 | (require 'font-lock) |
| 72 | (require 'pp) | 71 | (require 'pp) |
| 73 | (require 'thingatpt) | 72 | (require 'thingatpt) |
| @@ -2523,8 +2522,7 @@ Returns NICK unmodified unless `erc-lurker-trim-nicks' is | |||
| 2523 | non-nil." | 2522 | non-nil." |
| 2524 | (if erc-lurker-trim-nicks | 2523 | (if erc-lurker-trim-nicks |
| 2525 | (replace-regexp-in-string | 2524 | (replace-regexp-in-string |
| 2526 | (regexp-opt (cl-delete-duplicates | 2525 | (regexp-opt-charset (string-to-list erc-lurker-ignore-chars)) |
| 2527 | (mapcar #'char-to-string erc-lurker-ignore-chars))) | ||
| 2528 | "" nick) | 2526 | "" nick) |
| 2529 | nick)) | 2527 | nick)) |
| 2530 | 2528 | ||
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el index 7f88e30120d..81dc11de763 100644 --- a/lisp/mail/footnote.el +++ b/lisp/mail/footnote.el | |||
| @@ -64,7 +64,6 @@ | |||
| 64 | ;;; Code: | 64 | ;;; Code: |
| 65 | 65 | ||
| 66 | (eval-when-compile (require 'cl-lib)) | 66 | (eval-when-compile (require 'cl-lib)) |
| 67 | (require 'cl-seq) | ||
| 68 | (defvar filladapt-token-table) | 67 | (defvar filladapt-token-table) |
| 69 | 68 | ||
| 70 | (defgroup footnote nil | 69 | (defgroup footnote nil |
| @@ -364,9 +363,9 @@ Use Unicode characters for footnoting." | |||
| 364 | ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק"))) | 363 | ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק"))) |
| 365 | 364 | ||
| 366 | (defconst footnote-hebrew-numeric-regex | 365 | (defconst footnote-hebrew-numeric-regex |
| 367 | (concat "[" (cl-delete-duplicates | 366 | (let ((numchars (string-to-list |
| 368 | (apply #'concat (apply #'append footnote-hebrew-numeric))) | 367 | (apply #'concat (apply #'append footnote-hebrew-numeric))))) |
| 369 | "']+")) | 368 | (concat (regexp-opt-charset (cons ?' numchars)) "+"))) |
| 370 | ;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?") | 369 | ;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?") |
| 371 | 370 | ||
| 372 | (defun footnote--hebrew-numeric (n) | 371 | (defun footnote--hebrew-numeric (n) |
| @@ -464,6 +463,11 @@ Conversion is done based upon the current selected style." | |||
| 464 | (nth 0 footnote-style-alist))))) | 463 | (nth 0 footnote-style-alist))))) |
| 465 | (concat | 464 | (concat |
| 466 | ;; Hack to avoid repetition of repetition. | 465 | ;; Hack to avoid repetition of repetition. |
| 466 | ;; FIXME: I'm not sure the added * makes sense at all; there is | ||
| 467 | ;; always a single number within the footnote-{start,end}-tag pairs. | ||
| 468 | ;; Worse, the code goes on and adds yet another + later on, in | ||
| 469 | ;; footnote-refresh-footnotes, just in case. That makes even less sense. | ||
| 470 | ;; Likely, both the * and the extra + should go away. | ||
| 467 | (if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp) | 471 | (if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp) |
| 468 | (substring regexp 0 -1) | 472 | (substring regexp 0 -1) |
| 469 | regexp) | 473 | regexp) |