Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to hide macro markers #40

Open
m-h-b-tu opened this issue Feb 8, 2022 · 3 comments
Open

Add support to hide macro markers #40

m-h-b-tu opened this issue Feb 8, 2022 · 3 comments

Comments

@m-h-b-tu
Copy link

m-h-b-tu commented Feb 8, 2022

Org can hide the macro markers using org-hide-macro-markers. This patch adds those to org-appear. I am sorry, I cannot make a pull request because of authentication issues.

diff --git a/org-appear.el b/org-appear.el
index 9541e62..d97bc15 100644
--- a/org-appear.el
+++ b/org-appear.el
@@ -88,6 +88,12 @@ Does not have an effect if `org-hidden-keywords' is nil."
   :type 'boolean
   :group 'org-appear)
 
+(defcustom org-appear-automacros nil
+  "Non-nil enables automatic toggling of macro markers.
+Does not have an effect if `org-hide-macro-markers' is nil."
+  :type 'boolean
+  :group 'org-appear)
+
 (defcustom org-appear-delay 0.0
   "Seconds of delay before toggling an element."
   :type 'number
@@ -149,7 +155,8 @@ nil if the cursor was not on an element.")
 			   superscript))
 	(entity-elements '(entity))
 	(link-elements '(link))
-	(keyword-elements '(keyword)))
+	(keyword-elements '(keyword))
+	(macro-elements '(macro)))
 
     ;; HACK: is there a better way to do this?
     (setq-local org-appear--prev-elem nil)
@@ -162,6 +169,8 @@ nil if the cursor was not on an element.")
       (setq org-appear-elements (append org-appear-elements entity-elements)))
     (when (and org-link-descriptive org-appear-autolinks)
       (setq org-appear-elements (append org-appear-elements link-elements)))
+    (when (and org-hide-macro-markers org-appear-automacros)
+      (setq org-appear-elements (append org-appear-elements macro-elements)))
     (when (and org-hidden-keywords org-appear-autokeywords)
       (setq org-appear-elements (append org-appear-elements keyword-elements)))))
 
@@ -290,6 +299,8 @@ Return nil if element cannot be parsed."
 			  'link)
 			 ((eq elem-type 'keyword)
 			  'keyword)
+			 ((eq elem-type 'macro)
+			  'macro)
 			 (t nil)))
 	 (elem-start (org-element-property :begin elem))
 	 (elem-end (org-element-property :end elem))
@@ -307,11 +318,13 @@ Return nil if element cannot be parsed."
 	       :visible-start ,(pcase elem-tag
 				 ('emph (1+ elem-start))
 				 ('script elem-content-start)
-				 ('link (or elem-content-start (+ elem-start 2))))
+				 ('link (or elem-content-start (+ elem-start 2)))
+				 ('macro (or elem-content-start (+ elem-start 3))))
 	       :visible-end ,(pcase elem-tag
 			       ('emph (1- elem-end-real))
 			       ('script elem-content-end)
-			       ('link (or elem-content-end (- elem-end-real 2))))))))
+			       ('link (or elem-content-end (- elem-end-real 2)))
+			       ('macro (or elem-content-end (- elem-end-real 3))))))))
 
 (defun org-appear--show-invisible (elem)
   "Silently remove invisible property from invisible parts of element ELEM."
@awth13
Copy link
Owner

awth13 commented Feb 15, 2022

Hi, @m-h-b-tu! Thank you for the suggestion and code!

I didn't know about the macro replacement feature in Org but, after reading up on it, your patch seems very useful indeed. I am going to test it and add it to the package.

@m-h-b-tu
Copy link
Author

That sounds great.

I use the patch in the form of advices on a daily basis without any problem.

@ilupin
Copy link

ilupin commented Jul 21, 2023

Hi, @awth13
I have used the patch for a while and it works well. Could it be merged? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants