From b1f8498269061b13130bbbbc933f347d27f7fa59 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 13:38:43 +0200 Subject: [PATCH 1/7] Fix whitespace --- jira-markup-mode.el | 78 ++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index 29bdfc0..090ca4e 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -666,16 +666,16 @@ This helps improve font locking for block constructs such as pre blocks." ;;; Element Insertion ========================================================= (defun jira-markup-wrap-or-insert (s1 s2) - "Insert the strings S1 and S2. + "Insert the strings S1 and S2. If Transient Mark mode is on and a region is active, wrap the strings S1 and S2 around the region." - (if (and transient-mark-mode mark-active) - (let ((a (region-beginning)) (b (region-end))) - (goto-char a) - (insert s1) - (goto-char (+ b (length s1))) - (insert s2)) - (insert s1 s2))) + (if (and transient-mark-mode mark-active) + (let ((a (region-beginning)) (b (region-end))) + (goto-char a) + (insert s1) + (goto-char (+ b (length s1))) + (insert s2)) + (insert s1 s2))) (defun jira-markup-insert-hr () "Insert a horizonal rule using `jira-markup-hr-string'." @@ -689,7 +689,7 @@ and S2 around the region." ;; Following blank line (backward-char) (unless (looking-at "\n\n") - (insert "\n"))) + (insert "\n"))) (defun jira-markup-insert-bold () "Insert markup for a bold word or phrase. @@ -744,7 +744,7 @@ paragraph." (insert text)) (insert (concat "]: " url)) (unless (> (length url) 0) - (setq end (point))) + (setq end (point))) (when (> (length title) 0) (insert (concat " \"" title "\""))) (insert "\n") @@ -854,7 +854,7 @@ of each line." (goto-char end) (if (not (or (looking-at "\n\n") (and (equal (1+ end) (point-max)) (looking-at "\n")))) - (insert "\n")) + (insert "\n")) ;; Insert PREFIX (goto-char beg) (beginning-of-line) @@ -924,8 +924,8 @@ default indentation level." ;; Previous non-list-marker indent (setq pos (jira-markup-prev-non-list-indent)) (when pos - (setq positions (cons pos positions)) - (setq positions (cons (+ pos tab-width) positions))) + (setq positions (cons pos positions)) + (setq positions (cons (+ pos tab-width) positions))) ;; Indentation of the previous line + tab-width (cond @@ -1066,12 +1066,12 @@ returned by `match-data'. Note that the potential wiki link name must be available via `match-string'." (let ((case-fold-search nil)) (and (thing-at-point-looking-at jira-markup-regex-wiki-link) - (or (not buffer-file-name) - (not (string-equal (buffer-file-name) - (jira-markup-convert-wiki-link-to-filename + (or (not buffer-file-name) + (not (string-equal (buffer-file-name) + (jira-markup-convert-wiki-link-to-filename (jira-markup-wiki-link-link))))) - (not (save-match-data - (save-excursion)))))) + (not (save-match-data + (save-excursion)))))) (defun jira-markup-wiki-link-link () "Return the link part of the wiki link using current match data. @@ -1147,15 +1147,15 @@ and highlight accordingly." (goto-char from) (while (re-search-forward jira-markup-regex-wiki-link to t) (let ((highlight-beginning (match-beginning 0)) - (highlight-end (match-end 0)) - (file-name - (jira-markup-convert-wiki-link-to-filename + (highlight-end (match-end 0)) + (file-name + (jira-markup-convert-wiki-link-to-filename (jira-markup-wiki-link-link)))) (if (file-exists-p file-name) - (jira-markup-highlight-wiki-link - highlight-beginning highlight-end jira-markup-link-face) - (jira-markup-highlight-wiki-link - highlight-beginning highlight-end jira-markup-missing-link-face))))) + (jira-markup-highlight-wiki-link + highlight-beginning highlight-end jira-markup-link-face) + (jira-markup-highlight-wiki-link + highlight-beginning highlight-end jira-markup-missing-link-face))))) (defun jira-markup-extend-changed-region (from to) "Extend region given by FROM and TO so that we can fontify all links. @@ -1165,14 +1165,14 @@ newline after." (goto-char from) (re-search-backward "\n" nil t) (let ((new-from (point-min)) - (new-to (point-max))) + (new-to (point-max))) (if (not (= (point) from)) - (setq new-from (point))) + (setq new-from (point))) ;; do the same thing for the first new line after 'to (goto-char to) (re-search-forward "\n" nil t) (if (not (= (point) to)) - (setq new-to (point))) + (setq new-to (point))) (list new-from new-to))) (defun jira-markup-check-change-for-wiki-link (from to change) @@ -1182,13 +1182,13 @@ CHANGE is the number of bytes of pre-change text replaced by the given range." (interactive "nfrom: \nnto: \nnchange: ") (let* ((inhibit-quit t) - (modified (buffer-modified-p)) - (buffer-undo-list t) - (inhibit-read-only t) - (inhibit-point-motion-hooks t) - (inhibit-modification-hooks t) - (current-point (point)) - deactivate-mark) + (modified (buffer-modified-p)) + (buffer-undo-list t) + (inhibit-read-only t) + (inhibit-point-motion-hooks t) + (inhibit-modification-hooks t) + (current-point (point)) + deactivate-mark) (unwind-protect (save-match-data (save-restriction @@ -1270,9 +1270,9 @@ This is an exact copy of `line-number-at-pos' for use in emacs21." ;; Prepare hooks for XEmacs compatibility (when (featurep 'xemacs) - (make-local-hook 'after-change-functions) - (make-local-hook 'font-lock-extend-region-functions) - (make-local-hook 'window-configuration-change-hook)) + (make-local-hook 'after-change-functions) + (make-local-hook 'font-lock-extend-region-functions) + (make-local-hook 'window-configuration-change-hook)) ;; Multiline font lock (add-hook 'font-lock-extend-region-functions @@ -1285,7 +1285,7 @@ This is an exact copy of `line-number-at-pos' for use in emacs21." ;; creating one of the wiki link documents. Make sure we get ;; refontified when we come back. (add-hook 'window-configuration-change-hook - 'jira-markup-fontify-buffer-wiki-links t t) + 'jira-markup-fontify-buffer-wiki-links t t) ;; do the initial link fontification (jira-markup-fontify-buffer-wiki-links)) From 83ed1190997377b02fd01dffdc6094600bfcc614 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 13:39:11 +0200 Subject: [PATCH 2/7] Fix font-lock group references --- jira-markup-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index 090ca4e..1864c2b 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -451,8 +451,8 @@ text.") '((1 jira-markup-reference-face t) (2 jira-markup-url-face t) (3 jira-markup-link-title-face t))) - (cons jira-markup-regex-strong '(2 jira-markup-bold-face)) - (cons jira-markup-regex-emphasis '(2 jira-markup-italic-face)) + (cons jira-markup-regex-strong 'jira-markup-bold-face) + (cons jira-markup-regex-emphasis 'jira-markup-italic-face) ) "Syntax highlighting for Jira-Markup files.") From fb92f6e55175d32d8b16da8438a3f2c0bc462207 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 13:49:38 +0200 Subject: [PATCH 3/7] Use non-greedy regular expressions for markup --- jira-markup-mode.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index 1864c2b..3178ccc 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -348,11 +348,11 @@ Otherwise, they will be treated as [[PageName|alias text]]." ; text effects (defconst jira-markup-regex-strong - "\\s-+\\*.*\\*\\s-+" + "\\s-+\\*.*?\\*\\s-+" "Regular expression for matching *strong* text.") (defconst jira-markup-regex-emphasis - "\\s-+_.*_\\s-+" + "\\s-+_.*?_\\s-+" "Regular expression for matching _emphasized_ text.") ; new @@ -362,27 +362,27 @@ Otherwise, they will be treated as [[PageName|alias text]]." ; new (defconst jira-markup-regex-deleted - "\\s-+-.*-\\s-" + "\\s-+-.*?-\\s-" "Regular expression for matching -deleted- text.") ; new (defconst jira-markup-regex-inserted - "\\s-+\\+.*\\+\\s-+" + "\\s-+\\+.*?\\+\\s-+" "Regular expression for matching +inserted+ text.") ; new (defconst jira-markup-regex-superscript - "\\s-+^.*^\\s-+" + "\\s-+^.*?^\\s-+" "Regular expression for matching ^superscript^ text.") ; new (defconst jira-markup-regex-subscript - "\\s-+~.*~\\s-+" + "\\s-+~.*?~\\s-+" "Regular expression for matching ~subscript~ text.") ; new (defconst jira-markup-regex-monospaced - "\\s-+{{.*}}\\s-+" + "\\s-+{{.*?}}\\s-+" "Regular expression for matching {{monospaced}} text.") (defconst jira-markup-regex-blockquote From 23654e26d32af845467453c4679fce2af308d044 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 13:53:15 +0200 Subject: [PATCH 4/7] Add face for deleted text --- jira-markup-mode.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index 3178ccc..6dbc45b 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -162,6 +162,9 @@ Otherwise, they will be treated as [[PageName|alias text]]." (defvar jira-markup-inline-code-face 'jira-markup-inline-code-face "Face name to use for inline code.") +(defvar jira-markup-deleted-face 'jira-markup-deleted-face + "Face name to use for deleted code.") + (defvar jira-markup-list-face 'jira-markup-list-face "Face name to use for list markers.") @@ -241,6 +244,11 @@ Otherwise, they will be treated as [[PageName|alias text]]." "Face for inline code." :group 'jira-markup-faces) +(defface jira-markup-deleted-face + '((t (:inherit shadow :strike-through "red"))) + "Face for deleted code." + :group 'jira-markup-faces) + (defface jira-markup-list-face '((t (:inherit font-lock-builtin-face))) "Face for list item markers." From 5cd7a0c7871c810e627506a6348124641534cf97 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 13:53:21 +0200 Subject: [PATCH 5/7] Add more markup to font lock keywords --- jira-markup-mode.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index 6dbc45b..5459b2d 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -449,6 +449,8 @@ text.") (cons jira-markup-regex-uri 'jira-markup-link-face) (cons jira-markup-regex-email 'jira-markup-link-face) (cons jira-markup-regex-list 'jira-markup-list-face) + (cons jira-markup-regex-monospaced 'jira-markup-inline-code-face) + (cons jira-markup-regex-deleted 'jira-markup-deleted-face) (cons jira-markup-regex-link-inline '((1 jira-markup-link-face t) (2 jira-markup-url-face t))) From baba26314e360d34b4204231250e939bb7708de2 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 13:54:12 +0200 Subject: [PATCH 6/7] Do not strike through whitespace --- jira-markup-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index 5459b2d..c520e3b 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -370,7 +370,7 @@ Otherwise, they will be treated as [[PageName|alias text]]." ; new (defconst jira-markup-regex-deleted - "\\s-+-.*?-\\s-" + "\\s-+\\(-.*?-\\)\\s-" "Regular expression for matching -deleted- text.") ; new @@ -450,7 +450,7 @@ text.") (cons jira-markup-regex-email 'jira-markup-link-face) (cons jira-markup-regex-list 'jira-markup-list-face) (cons jira-markup-regex-monospaced 'jira-markup-inline-code-face) - (cons jira-markup-regex-deleted 'jira-markup-deleted-face) + (list jira-markup-regex-deleted 1 'jira-markup-deleted-face) (cons jira-markup-regex-link-inline '((1 jira-markup-link-face t) (2 jira-markup-url-face t))) From 866f4742d0b7c6522f5a7ca55cce1782e0e79856 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 21 Aug 2018 14:03:53 +0200 Subject: [PATCH 7/7] Use backquote to build the keywords list --- jira-markup-mode.el | 58 +++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/jira-markup-mode.el b/jira-markup-mode.el index c520e3b..9fa70d8 100644 --- a/jira-markup-mode.el +++ b/jira-markup-mode.el @@ -433,37 +433,33 @@ text.") "Regular expression for matching indentation of list items.") (defvar jira-markup-mode-font-lock-keywords-basic - (list - '(jira-markup-match-pre-blocks 0 jira-markup-pre-face t t) - '(jira-markup-match-fenced-code-blocks 0 jira-markup-pre-face t t) - (cons jira-markup-regex-blockquote 'jira-markup-blockquote-face) - (cons jira-markup-regex-header-1 'jira-markup-header-face-1) - (cons jira-markup-regex-header-2 'jira-markup-header-face-2) - (cons jira-markup-regex-header-3 'jira-markup-header-face-3) - (cons jira-markup-regex-header-4 'jira-markup-header-face-4) - (cons jira-markup-regex-header-5 'jira-markup-header-face-5) - (cons jira-markup-regex-header-6 'jira-markup-header-face-6) - (cons jira-markup-regex-hr 'jira-markup-header-face) - (cons jira-markup-regex-code '(2 jira-markup-inline-code-face)) - (cons jira-markup-regex-angle-uri 'jira-markup-link-face) - (cons jira-markup-regex-uri 'jira-markup-link-face) - (cons jira-markup-regex-email 'jira-markup-link-face) - (cons jira-markup-regex-list 'jira-markup-list-face) - (cons jira-markup-regex-monospaced 'jira-markup-inline-code-face) - (list jira-markup-regex-deleted 1 'jira-markup-deleted-face) - (cons jira-markup-regex-link-inline - '((1 jira-markup-link-face t) - (2 jira-markup-url-face t))) - (cons jira-markup-regex-link-reference - '((1 jira-markup-link-face t) - (2 jira-markup-reference-face t))) - (cons jira-markup-regex-reference-definition - '((1 jira-markup-reference-face t) - (2 jira-markup-url-face t) - (3 jira-markup-link-title-face t))) - (cons jira-markup-regex-strong 'jira-markup-bold-face) - (cons jira-markup-regex-emphasis 'jira-markup-italic-face) - ) + `((jira-markup-match-pre-blocks 0 jira-markup-pre-face t t) + (jira-markup-match-fenced-code-blocks 0 jira-markup-pre-face t t) + (,jira-markup-regex-blockquote . jira-markup-blockquote-face) + (,jira-markup-regex-header-1 . jira-markup-header-face-1) + (,jira-markup-regex-header-2 . jira-markup-header-face-2) + (,jira-markup-regex-header-3 . jira-markup-header-face-3) + (,jira-markup-regex-header-4 . jira-markup-header-face-4) + (,jira-markup-regex-header-5 . jira-markup-header-face-5) + (,jira-markup-regex-header-6 . jira-markup-header-face-6) + (,jira-markup-regex-hr . jira-markup-header-face) + (,jira-markup-regex-code . (2 jira-markup-inline-code-face)) + (,jira-markup-regex-angle-uri . jira-markup-link-face) + (,jira-markup-regex-uri . jira-markup-link-face) + (,jira-markup-regex-email . jira-markup-link-face) + (,jira-markup-regex-list . jira-markup-list-face) + (,jira-markup-regex-monospaced . jira-markup-inline-code-face) + (,jira-markup-regex-deleted 1 jira-markup-deleted-face) + (,jira-markup-regex-link-inline (1 jira-markup-link-face t) + (2 jira-markup-url-face t)) + (,jira-markup-regex-link-reference (1 jira-markup-link-face t) + (2 jira-markup-reference-face t)) + (,jira-markup-regex-reference-definition (1 jira-markup-reference-face t) + (2 jira-markup-url-face t) + (3 jira-markup-link-title-face t)) + (,jira-markup-regex-strong . jira-markup-bold-face) + (,jira-markup-regex-emphasis . jira-markup-italic-face) + ) "Syntax highlighting for Jira-Markup files.") (defvar jira-markup-mode-font-lock-keywords