[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/svg-tag-mode 7266de9f9c 61/63: Simplified advice on org
From: |
ELPA Syncer |
Subject: |
[elpa] externals/svg-tag-mode 7266de9f9c 61/63: Simplified advice on org fontify blocks. |
Date: |
Mon, 27 Dec 2021 15:58:01 -0500 (EST) |
branch: externals/svg-tag-mode
commit 7266de9f9c59df3dc79118bd3c3fbed7f7116f8d
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Simplified advice on org fontify blocks.
---
svg-tag-mode.el | 52 +++++++++++++++++++++++++---------------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/svg-tag-mode.el b/svg-tag-mode.el
index fa1aa641a4..8607c8d48f 100644
--- a/svg-tag-mode.el
+++ b/svg-tag-mode.el
@@ -202,9 +202,11 @@ allows to create dynamic tags."
:background (face-background face nil 'default)
args))))
-(defun svg-tag--cursor-function (win position direction)
- "This function hides the tag when cursor is over it, allowing
- to edit it."
+(defun svg-tag--cursor-function (_win position direction)
+ "This function processes action at point. Action can be:
+- Display the textual tag in the echo area
+- Dispaly the textual tag inline (this allow to edit it
+- Do nothing"
(let ((beg (if (eq direction 'entered)
(previous-property-change (+ (point) 1))
(previous-property-change (+ position 1))))
@@ -239,27 +241,28 @@ allows to create dynamic tags."
(setq tag `(,tag (match-string 1))))
(setq tag ``(face nil
display ,,tag
- cursor-sensor-functions ,'(svg-tag--cursor-function)
cursor-sensor-functions (svg-tag--cursor-function)
,@(if ,callback '(pointer hand))
,@(if ,help `(help-echo ,,help))
+ ;; FIXME: Don't hard-code the internal representation
+ ;; of keymaps.
,@(if ,callback `(keymap (keymap (mouse-1 . ,,callback))))))
`(,pattern 1 ,tag)))
-(defun svg-tag--remove-text-properties (oldfun start end props &rest args)
+(defun svg-tag--remove-text-properties (oldfun start end props &rest args)
"This applies remove-text-properties with 'display removed from props"
(apply oldfun start end (svg-tag--plist-delete props 'display) args))
-(defun svg-tag--remove-text-properties-on (args)
- "This installs an advice around remove-text-properties"
- (advice-add 'remove-text-properties
- :around #'svg-tag--remove-text-properties))
-
-(defun svg-tag--remove-text-properties-off (args)
- "This removes the advice around remove-text-properties"
- (advice-remove 'remove-text-properties
- #'svg-tag--remove-text-properties))
-
+(defun svg-tag--org-fontify-meta-lines-and-blocks (oldfun &rest args)
+ "This installs our hack on remove-text-properties."
+ (unwind-protect
+ (progn
+ (advice-add 'remove-text-properties
+ :around #'svg-tag--remove-text-properties)
+ (apply oldfun args))
+ (advice-remove 'remove-text-properties
+ #'svg-tag--remove-text-properties)))
+
(defun svg-tag-mode-on ()
"Activate SVG tag mode."
(add-to-list 'font-lock-extra-managed-props 'display)
@@ -277,13 +280,11 @@ allows to create dynamic tags."
;; Make a copy of newly installed tags
(setq svg-tag--active-tags (copy-sequence svg-tag-tags))
- ;; Install advices on remove-text-properties (before & after). This
- ;; is a hack to prevent org mode from removing SVG tags that use the
- ;; 'display property
- (advice-add 'org-fontify-meta-lines-and-blocks
- :before #'svg-tag--remove-text-properties-on)
+ ;; Install an advice on org-fontify that will install a local advice
+ ;; on remove-text-properties. This is a hack to prevent org mode
+ ;; from removing SVG tags that use the 'display property
(advice-add 'org-fontify-meta-lines-and-blocks
- :after #'svg-tag--remove-text-properties-off)
+ :around #'svg-tag--org-fontify-meta-lines-and-blocks)
;; Flush buffer when entering read-only
(add-hook 'read-only-mode-hook
@@ -303,13 +304,10 @@ allows to create dynamic tags."
(mapcar #'svg-tag--build-keywords svg-tag--active-tags)))
(setq svg-tag--active-tags nil)
- ;; Remove advices on remove-text-properties (before & after)
+ ;; Remove advices on org-fontify-meta-lines-and-blocks
(advice-remove 'org-fontify-meta-lines-and-blocks
- #'svg-tag--remove-text-properties-on)
- (advice-remove 'org-fontify-meta-lines-and-blocks
- #'svg-tag--remove-text-properties-off)
- (remove-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
-
+ #'svg-tag--org-fontify-meta-lines-and-blocks)
+
;; Redisplay everything to hide tags
(message "SVG tag mode off")
(cursor-sensor-mode -1)
- [elpa] externals/svg-tag-mode 558ac3d3bd 54/63: Added edit mode (tag is hidden) when pointer is over a tag., (continued)
- [elpa] externals/svg-tag-mode 558ac3d3bd 54/63: Added edit mode (tag is hidden) when pointer is over a tag., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 72068052ff 19/63: Fixed default height, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 9ddf0e4f13 38/63: Rename screenshot, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode b865793671 53/63: Updated copyright notices., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 95b5404997 35/63: Merge pull request #13 from tarsiiformes/cleanup, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 861c68af89 40/63: Updated example 1 to new tags format., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode ee16277655 42/63: Added examples from documentation, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 8533c6c174 50/63: Added progress bar example., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode d9a803a92e 49/63: Added date without time format example., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 3e49ddcee2 57/63: Cancel tag editing in read-only or view mode., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 7266de9f9c 61/63: Simplified advice on org fontify blocks.,
ELPA Syncer <=
- [elpa] externals/svg-tag-mode 1d0d91bb00 46/63: Fixed layout, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 02d60e0a86 55/63: Fixed cursor selection., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode b5a00a5746 56/63: Bumped version number and fixed some documentation., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 85aed73bc6 58/63: Added custom option to let user decide on action at point., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode e2481ae15a 63/63: Modified example to highlight real org tags., ELPA Syncer, 2021/12/27