branch: elpa/textile-mode commit b52abc9ea316dded669105f643ee347b8ff8f5b1 Author: Matus Goljer <dota.k...@gmail.com> Commit: Matus Goljer <dota.k...@gmail.com>
Better link matching --- textile-mode.el | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/textile-mode.el b/textile-mode.el index c820c9ba43..755f772dec 100644 --- a/textile-mode.el +++ b/textile-mode.el @@ -135,12 +135,14 @@ non-matching parentheses" (defun textile-link-matcher () "Return the matcher regexp for a link" (concat - "\\(?:" - "\\(?:" "\".*?\"" "\\|" "\\[.*?\\]" "\\)?" - textile-url-regexp - "\\|" - "\".*?\":[^ \n\t]+" - "\\)")) + "\\(\".*?\"\\):" + "\\(?:" "\\(" textile-url-regexp "\\)" "\\|" "\\([^ \n\t]+\\)" "\\)")) + +(defun textile-link-alias-matcher () + "Return the matcher regexp for a link ali" + (concat + "\\(\\[.*?\\]\\)" + "\\(" textile-url-regexp "\\)")) (defun textile-image-matcher () "Return the matcher regexp for an image link" @@ -218,7 +220,14 @@ non-matching parentheses" `(,(textile-table-matcher) 0 'textile-table-face t t) ;; links - `(,(textile-link-matcher) 0 'textile-link-face t t) + `(,(textile-link-matcher) + (1 'textile-link-face) + (2 'textile-url-face t t) + (3 'textile-lang-face t t)) + `(,(textile-link-alias-matcher) + (1 'textile-lang-face) + (2 'textile-url-face)) + `(,textile-url-regexp 0 'textile-link-face) ;; <pre> blocks '("<pre>\\(.\\|\n\\)*?</pre>\n?" 0 'textile-pre-face t t) @@ -388,6 +397,11 @@ non-matching parentheses" "Face used to highlight links." :group 'textile-faces) +(defface textile-url-face + '((t (:inherit textile-link-face))) + "Face used to highlight links." + :group 'textile-faces) + (defface textile-image-face '((t (:foreground "pink"))) "Face used to highlight image links."