[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-superstar 27e90eece5 124/162: Implement org-indent com
From: |
Stefan Kangas |
Subject: |
[nongnu] elpa/org-superstar 27e90eece5 124/162: Implement org-indent compatibility |
Date: |
Fri, 31 Dec 2021 19:35:36 -0500 (EST) |
branch: elpa/org-superstar
commit 27e90eece5f580fd23a3073f313159c63cec2250
Author: D. Williams <d.williams@posteo.net>
Commit: D. Williams <d.williams@posteo.net>
Implement org-indent compatibility
Org Indent now causes the "true" first inline task star to be hidden,
as is expected.
The first inline task star embedded into the indentation now displays
as if it were a regular bullet.
Org Superstar restarts Indent automatically if needed.
The first star is now caught by an independent regex. Maybe less
efficient, but free of regex gotchas and edge cases.
---
org-superstar.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 60 insertions(+), 10 deletions(-)
diff --git a/org-superstar.el b/org-superstar.el
index c65d8615e9..618e614652 100644
--- a/org-superstar.el
+++ b/org-superstar.el
@@ -78,6 +78,11 @@
(require 'org-element)
(require 'wid-edit)
+(declare-function org-indent-mode "org-indent" (arg))
+(defvar org-indent-mode)
+(defvar org-inlinetask-show-first-star)
+(defvar org-indent-inlinetask-first-star)
+
(defgroup org-superstar nil
"Use UTF8 bullets for headlines and plain lists."
:group 'org-appearance)
@@ -709,11 +714,52 @@ is used instead of the regular bullet to avoid errors.
This function uses ‘org-superstar-inlinetask-p’ to avoid
prettifying bullets in (for example) source blocks."
- (when (org-superstar-inlinetask-p)
- (let ((star-beg (match-beginning 3)))
+ (cond
+ ((and (featurep 'org-indent) org-indent-mode)
+ 'org-hide)
+ ((org-superstar-inlinetask-p)
+ (let ((star-beg (match-beginning 4)))
(compose-region star-beg (1+ star-beg)
(org-superstar--fbullet))
- 'org-superstar-first)))
+ 'org-superstar-first))
+ (org-hide-leading-stars 'org-hide)
+ (t 'org-superstar-leading)))
+
+(defun org-superstar--prettify-indent ()
+ "Set up ‘org-indent-inlinetask-first-star’ buffer-locally.
+Restart Org Indent Mode to enforce the change to take effect, if
+enabled. This way, ‘org-indent-mode’ uses the correct bullet
+instead of a star. If Org Indent is not loaded, this function
+does nothing.
+
+See also ‘org-superstar-first-inlinetask-bullet’."
+ (when (featurep 'org-indent)
+ (let ((bullet-components (org-superstar--fbullet))
+ (bullet "*"))
+ (cond
+ ((characterp bullet-components)
+ (setq bullet (string bullet-components)))
+ ;; bullet-components must be a string => compsoe!
+ (t
+ (setq bullet
+ (compose-string bullet nil nil
+ bullet-components))))
+ (setq-local org-indent-inlinetask-first-star
+ (org-add-props bullet '(face org-superstar-first))))
+ (when (and org-indent-mode
+ (featurep 'org-inlinetask))
+ (org-indent-mode 0)
+ (org-indent-mode 1))))
+
+(defun org-superstar--unprettify-indent ()
+ "Revert ‘org-indent-inlinetask-first-star’ to default value.
+If Org Indent Mode is enabled, also restart it if necessary."
+ (when (featurep 'org-indent)
+ (kill-local-variable 'org-indent-inlinetask-first-star)
+ (when (and org-indent-mode
+ (featurep 'org-inlinetask))
+ (org-indent-mode 0)
+ (org-indent-mode 1))))
(defun org-superstar--make-invisible (subexp)
"Make part of the text matched by the last search invisible.
@@ -763,11 +809,13 @@ cleanup routines."
(2 (org-superstar--make-invisible 2))))
,@(when (featurep 'org-inlinetask)
'((2 (org-superstar--prettify-other-hbullet)
- prepend)))
+ prepend))))
+ ("^\\(?4:\\*\\)\\(?:\\*\\{2,\\}\\) "
,@(when (and (featurep 'org-inlinetask)
- org-inlinetask-show-first-star)
- '((3 (org-superstar--prettify-first-bullet))))
- ))))
+ org-inlinetask-show-first-star
+ (not org-superstar-remove-leading-stars))
+ '((4 (org-superstar--prettify-first-bullet)
+ t)))))))
(defun org-superstar--fontify-buffer ()
"Fontify the buffer."
@@ -797,8 +845,9 @@ cleanup routines."
(font-lock-add-keywords nil org-superstar--font-lock-keywords
'append)
(org-superstar--fontify-buffer)
- (add-to-invisibility-spec '(org-superstar-hide)))
- ;; Clean up nd exit.
+ (add-to-invisibility-spec '(org-superstar-hide))
+ (org-superstar--prettify-indent))
+ ;; Clean up and exit.
(t
(remove-from-invisibility-spec '(org-superstar-hide))
(font-lock-remove-keywords nil org-superstar--font-lock-keywords)
@@ -806,7 +855,8 @@ cleanup routines."
(default-value 'org-superstar--font-lock-keywords))
(org-superstar--unprettify-ibullets)
(org-superstar--unprettify-hbullets)
- (org-superstar--fontify-buffer))))
+ (org-superstar--fontify-buffer)
+ (org-superstar--unprettify-indent))))
(defun org-superstar-restart ()
"Re-enable Org Superstar mode, if the mode is enabled."
- [nongnu] elpa/org-superstar 72cc899d87 130/162: Updating sample file, (continued)
- [nongnu] elpa/org-superstar 72cc899d87 130/162: Updating sample file, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 3935ecf7b4 137/162: Add example files for Issue #21, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 84362aeccb 140/162: Updating README to promote new template repo., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 046f845dfe 142/162: Add TODO test case., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar d2abbbb714 156/162: disable org-superstar in org source code block, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 2cd3f1e74b 160/162: Merge pull request #31 from andersjohansson/avoid-empty-font-lock-keyword, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 01dad8e3ca 030/162: removed ridiculous warning., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 762fa160fd 114/162: Clarified position of string value in custom interface., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 930a887430 111/162: Add support for extra-wide headline bullets + terminal fallback., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 66e593a8b7 102/162: Support advanced composition for TODO item bullets., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 27e90eece5 124/162: Implement org-indent compatibility,
Stefan Kangas <=
- [nongnu] elpa/org-superstar 48660e9269 120/162: Updated news regarding Doom and Spacemacs, updated FAQ., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar cfb98c0de6 123/162: updating .gitignore, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 6673412725 132/162: Updating README to signify changes, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 2800b83e88 133/162: Version Bump., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 7f83636db2 136/162: Update README for absolutely astonishing 33k+ dls on MELPA, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar a5af8b6ddf 141/162: Remove example files from #21., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 417b81772a 147/162: Support defining a default TODO bullet, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 3efb5f76cb 146/162: Allow hiding leading bullet for all todo keywords, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 6cdb79e5fa 148/162: Bugfix: Stop interpreting normal headings as TODO items., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 806b699b7d 149/162: Merge branch 'master' into volatile, Stefan Kangas, 2021/12/31