From 018a80541a96eee764fe929a11a3e8590df4500f Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 17 Apr 2014 08:42:14 +0200 Subject: [PATCH] Small refactoring * lisp/org.el (org-make-link-regexps): Use `regexp-opt' instead of `mapconcat' and `regexp-quote'. --- lisp/org.el | 102 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b59c8e8e6..617829dbd 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5593,59 +5593,55 @@ stacked delimiters is N. Escaping delimiters is not possible." (defun org-make-link-regexps () "Update the link regular expressions. This should be called after the variable `org-link-types' has changed." - (setq org-link-types-re - (concat - "\\`\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):") - org-link-re-with-space - (concat - "?") - org-link-re-with-space2 - (concat - "?") - org-link-re-with-space3 - (concat - "") - org-plain-link-re - (concat - "\\<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" - (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")) - ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") - org-bracket-link-regexp - "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" - org-bracket-link-analytic-regexp - (concat - "\\[\\[" - "\\(\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):\\)?" - "\\([^]]+\\)" - "\\]" - "\\(\\[" "\\([^]]+\\)" "\\]\\)?" - "\\]") - org-bracket-link-analytic-regexp++ - (concat - "\\[\\[" - "\\(\\(" (mapconcat 'regexp-quote (cons "coderef" org-link-types) "\\|") "\\):\\)?" - "\\([^]]+\\)" - "\\]" - "\\(\\[" "\\([^]]+\\)" "\\]\\)?" - "\\]") - org-any-link-re - (concat "\\(" org-bracket-link-regexp "\\)\\|\\(" - org-angle-link-re "\\)\\|\\(" - org-plain-link-re "\\)"))) + (let ((types-re (regexp-opt org-link-types t))) + (setq org-link-types-re + (concat "\\`" types-re ":") + org-link-re-with-space + (concat "?") + org-link-re-with-space2 + (concat "?") + org-link-re-with-space3 + (concat "") + org-plain-link-re + (concat + "\\<" types-re ":" + (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")) + ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") + org-bracket-link-regexp + "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" + org-bracket-link-analytic-regexp + (concat + "\\[\\[" + "\\(" types-re ":\\)?" + "\\([^]]+\\)" + "\\]" + "\\(\\[" "\\([^]]+\\)" "\\]\\)?" + "\\]") + org-bracket-link-analytic-regexp++ + (concat + "\\[\\[" + "\\(" (regexp-opt (cons "coderef" org-link-types) t) ":\\)?" + "\\([^]]+\\)" + "\\]" + "\\(\\[" "\\([^]]+\\)" "\\]\\)?" + "\\]") + org-any-link-re + (concat "\\(" org-bracket-link-regexp "\\)\\|\\(" + org-angle-link-re "\\)\\|\\(" + org-plain-link-re "\\)")))) (org-make-link-regexps) -- 2.11.4.GIT