branch: externals/svg-tag-mode commit 3e49ddcee288750cf1403a90308f4bb25a94bc3d Author: Nicolas P. Rougier <nicolas.roug...@inria.fr> Commit: Nicolas P. Rougier <nicolas.roug...@inria.fr>
Cancel tag editing in read-only or view mode. --- examples/example-1.el | 11 +++++++---- svg-tag-mode.el | 8 ++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/example-1.el b/examples/example-1.el index 143b2378a2..a1e0988318 100644 --- a/examples/example-1.el +++ b/examples/example-1.el @@ -16,14 +16,17 @@ (require 'svg-tag-mode) (setq svg-tag-tags - '((":TODO:" . ((svg-tag-make "TODO" :face 'org-tag :inverse t :margin 0))) - (":NOTE:" . ((svg-tag-make "NOTE" :margin 0))) + '((":TODO:" . ((svg-tag-make "TODO" :face 'org-tag + :radius 0 :inverse t :margin 0))) + (":NOTE:" . ((svg-tag-make "NOTE" :face 'font-lock-comment-face + :inverse nil :margin 0 :radius 0))) ("\([0-9a-zA-Z]\)" . ((lambda (tag) (svg-tag-make tag :beg 1 :end -1 :radius 12)))) ("\([0-9a-zA-Z][0-9a-zA-Z]\)" . ((lambda (tag) (svg-tag-make tag :beg 1 :end -1 :radius 8)))) ("|[0-9a-zA-Z- ]+?|" . ((lambda (tag) - (svg-tag-make tag :margin 0 :beg 1 :end -1)))))) + (svg-tag-make tag :face 'font-lock-comment-face + :margin 0 :beg 1 :end -1)))))) (svg-tag-mode t) ;; :NOTE: SVG tag is a minor mode that displays a rounded box with outer @@ -40,7 +43,7 @@ ;; Save as .............. |C-x| |C-w| Cancel ............. |C-g| ;; Open a new file ...... |C-x| |C-f| Undo ............... |C-z| ;; Open recent .......... |C-x| |C-r| Close buffer ....... |C-x| |k| -;; Browse directory ......|C-x| |d| Quit ............... |C-x| |C-c| +;; Browse directory ..... |C-x| |d| Quit ............... |C-x| |C-c| ;; ;; ------------------------------------------------------------------------ ;; (1)(2)(3)(4)(5)(Z)(W)(12)(99) (A)(B)(C) diff --git a/svg-tag-mode.el b/svg-tag-mode.el index 2ea4b04801..c292d42728 100644 --- a/svg-tag-mode.el +++ b/svg-tag-mode.el @@ -198,8 +198,8 @@ allows to create dynamic tags." (next-property-change position)))) (if (eq direction 'left) (font-lock-flush beg end ) - (font-lock-unfontify-region beg end)) - + (if (and (not view-read-only) (not buffer-read-only)) + (font-lock-unfontify-region beg end))) ;; (if (eq direction 'entered) ;; (message (concat "TAG: " ;; (substring-no-properties @@ -264,6 +264,10 @@ allows to create dynamic tags." (advice-add 'org-fontify-meta-lines-and-blocks :after #'svg-tag--remove-text-properties-off) + ;; Flush buffer when entering read-only + (add-hook 'read-only-mode-hook + #'(lambda () (font-lock-flush (point-min) (point-max)))) + ;; Redisplay everything to show tags (message "SVG tag mode on") (cursor-sensor-mode 1)