[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-superstar 4b4ddd7c39 122/162: Honor ‘org-inlinetask-s
From: |
Stefan Kangas |
Subject: |
[nongnu] elpa/org-superstar 4b4ddd7c39 122/162: Honor ‘org-inlinetask-show-first-star’. |
Date: |
Fri, 31 Dec 2021 19:35:36 -0500 (EST) |
branch: elpa/org-superstar
commit 4b4ddd7c39b4f8b8106d1d4f602ff27450378d83
Author: D. Williams <d.williams@posteo.net>
Commit: D. Williams <d.williams@posteo.net>
Honor ‘org-inlinetask-show-first-star’.
Added various functions and custom variables to accomodate new
feature. This is the first step towards addressing issue #5.
Moved org-superstar-remove-leading-stars to a more appropriate
location.
---
org-superstar.el | 134 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 108 insertions(+), 26 deletions(-)
diff --git a/org-superstar.el b/org-superstar.el
index 297b083db7..c65d8615e9 100644
--- a/org-superstar.el
+++ b/org-superstar.el
@@ -174,6 +174,58 @@ variable for your changes to take effect."
(character :value ?◉
:format "Fallback character for terminal:
%v\n")))))
+(defun org-superstar--set-fbullet (symbol value)
+ "Set SYMBOL ‘org-superstar-first-inlinetask-bullet’ to VALUE.
+If set to a character, also set ‘org-superstar-first-inlinetask-fallback’."
+ (set-default symbol value)
+ (when (characterp value)
+ (set-default 'org-superstar-first-inlinetask-fallback value)))
+
+(defcustom org-superstar-first-inlinetask-bullet ?▶
+ "A special bullet used for the first star of an inline task.
+Normally, this variable is a character replacing the default
+star. If it’s a string, compose the replacement according to the
+rules of ‘compose-region’ for the COMPONENTS argument.
+
+This bullet is displayed using the dedicated face
+‘org-superstar-first’.
+
+This variable is only used for graphical displays.
+‘org-superstar-first-inlinetask-fallback’ is used for terminal
+displays instead.
+
+You should call ‘org-superstar-restart’ after changing this
+variable for your changes to take effect."
+ :group 'org-superstar
+ :type '(choice
+ (character :tag "Single character to display"
+ :format "\n%t: %v\n"
+ :value ?▶)
+ (string :tag "String of characters to compose replacement from"
+ :format "\n%t:\n%v"
+ :value "*"))
+ :set #'org-superstar--set-fbullet)
+
+(defcustom org-superstar-first-inlinetask-fallback
+ (cond ((characterp org-superstar-first-inlinetask-bullet)
+ org-superstar-first-inlinetask-bullet)
+ (t ?*))
+ "A special bullet used for the first star of an inline task.
+This variable is a character replacing the default star in
+terminal displays instead of ‘org-superstar-first-inlinetask-bullet’.
+
+If the leading bullet is set to a character before the package is
+loaded, this variable’s default value is set to that character as
+well. Setting the leading bullet to a character using the custom
+interface also automatically sets this variable.
+
+You should call ‘org-superstar-restart’ after changing this
+variable for your changes to take effect."
+ :group 'org-superstar
+ :type '(character :tag "Single character to display"
+ :format "\n%t: %v\n"
+ :value ?*))
+
;;;###autoload
(put 'org-superstar-leading-bullet
'safe-local-variable
@@ -320,6 +372,26 @@ keyword)."
There is usually no need to use this variable directly; instead,
use the command ‘org-superstar-toggle-lightweight-lists’.")
+(defcustom org-superstar-remove-leading-stars nil
+ "Non-nil means font-lock should hide leading star characters.
+
+A more radical version of ‘org-hide-leading-stars’, where the
+indentation caused by leading stars is completely removed. It
+works similar to ‘org-hide-emphasis-markers’.
+
+If Non-nil, this variable takes precedence over
+‘org-hide-leading-stars’.
+
+This variable only eliminates indentation caused directly by
+leading stars, meaning additional indentation should be
+preserved. For an example of this, see the minor-mode command
+‘org-indent-mode’.
+
+You should call ‘org-superstar-restart’ after changing this
+variable for your changes to take effect."
+ :group 'org-superstar
+ :type 'boolean)
+
;;; Faces
@@ -347,25 +419,11 @@ unspecified inherits the org-level-X faces for header
bullets."
"Face used to display prettified item bullets."
:group 'org-superstar)
-(defcustom org-superstar-remove-leading-stars nil
- "Non-nil means font-lock should hide leading star characters.
-
-A more radical version of ‘org-hide-leading-stars’, where the
-indentation caused by leading stars is completely removed. It
-works similar to ‘org-hide-emphasis-markers’.
-
-If Non-nil, this variable takes precedence over
-‘org-hide-leading-stars’.
-
-This variable only eliminates indentation caused directly by
-leading stars, meaning additional indentation should be
-preserved. For an example of this, see the minor-mode command
-‘org-indent-mode’.
-
-You should call ‘org-superstar-restart’ after changing this
-variable for your changes to take effect."
- :group 'org-superstar
- :type 'boolean)
+(defface org-superstar-first
+ '((default . (:inherit org-warning)))
+ "Face used to display the first bullet of an inline task.
+This face is only used when ‘org-inlinetask-show-first-star’ is
+non-nil.")
;;; Functions intended for users
@@ -483,8 +541,6 @@ N counts from zero. Headline bullets are specified in
(let ((bullet-entry
(elt org-superstar-headline-bullets-list n)))
(cond
- ;; Using characters for bullets is actually way more consistent
- ;; with the rest of the package, so why not just support it.
((characterp bullet-entry)
bullet-entry)
;; Strip bullets provided as strings down to their first char.
@@ -514,6 +570,12 @@ replaced by their corresponding entry in
‘org-superstar-item-bullet-alist’."
org-superstar-leading-bullet
org-superstar-leading-fallback))
+(defun org-superstar--fbullet ()
+ "Return the correct first inline task star for the current display."
+ (if (org-superstar-graphic-p)
+ org-superstar-first-inlinetask-bullet
+ org-superstar-first-inlinetask-fallback))
+
(defun org-superstar--heading-level ()
"Return the heading level of the currently matched headline."
(- (match-end 0) (match-beginning 0) 1))
@@ -606,7 +668,9 @@ prettifying bullets in (for example) source blocks."
(defun org-superstar--prettify-other-lbullet ()
"Prettify the first leading bullet after the headline bullet.
This function serves as an extension of
-‘org-superstar--prettify-leading-hbullets’.
+‘org-superstar--prettify-leading-hbullets’, only providing the
+correct face for the bullet, without doing any composing.
+
This function uses ‘org-superstar-headline-p’ to avoid
prettifying bullets in (for example) source blocks."
(cond ((org-superstar-headline-p)
@@ -617,8 +681,8 @@ prettifying bullets in (for example) source blocks."
(defun org-superstar--prettify-leading-hbullets ()
"Prettify the leading bullets of a header line.
Unless ‘org-hide-leading-stars’ is non-nil, each leading star is
-visually replaced by ‘org-superstar-leading-bullet’ and inherits
-face properties from ‘org-superstar-leading’.
+rendered as ‘org-superstar-leading-bullet’ and inherits face
+properties from ‘org-superstar-leading’.
If viewed from a terminal, ‘org-superstar-leading-fallback’ is
used instead of the regular leading bullet to avoid errors.
@@ -634,6 +698,23 @@ prettifying bullets in (for example) source blocks."
(org-superstar--lbullet)))
'org-superstar-leading)))
+(defun org-superstar--prettify-first-bullet ()
+ "Prettify the first bullet of an inline task.
+If ‘org-inlinetask-show-first-star’ is non-nil, the first star of
+an inlinetask is rendered as ‘org-superstar-first-inlinetask-bullet’
+and inherits face properties from ‘org-superstar-first’.
+
+If viewed from a terminal, ‘org-superstar-first-inlinetask-fallback’
+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)))
+ (compose-region star-beg (1+ star-beg)
+ (org-superstar--fbullet))
+ 'org-superstar-first)))
+
(defun org-superstar--make-invisible (subexp)
"Make part of the text matched by the last search invisible.
SUBEXP, a number, specifies which parenthesized expression in the
@@ -683,8 +764,9 @@ cleanup routines."
,@(when (featurep 'org-inlinetask)
'((2 (org-superstar--prettify-other-hbullet)
prepend)))
- ;; If requested, put another function here that formats the
- ;; first star of an inlinetask as a bullet.
+ ,@(when (and (featurep 'org-inlinetask)
+ org-inlinetask-show-first-star)
+ '((3 (org-superstar--prettify-first-bullet))))
))))
(defun org-superstar--fontify-buffer ()
- [nongnu] elpa/org-superstar c0dacd8562 052/162: updated README to reflect new version, (continued)
- [nongnu] elpa/org-superstar c0dacd8562 052/162: updated README to reflect new version, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar d94e141c36 069/162: Added a REVIEW marker., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 8a6215a10f 084/162: Merge pull request #6 from progfolio/fix-org-superstar-restart-docstring, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 092de74fb9 099/162: Fixed typo in README., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar f75220cd2d 089/162: Downgrade version requirements, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 3fbfc0a47e 092/162: Merge pull request #11 from integral-dw/issue-10, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar a995899117 115/162: Merge branch 'master' of github.com:integral-dw/org-superstar-mode, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 4897c333a8 105/162: Version bump: Update documentation and README accordingly to reflect new feature., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 026c54f1bf 100/162: Version bump: Add new option allowing a more efficient (but sloppy) display of list items, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 15b9c32eae 112/162: Version Bump., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 4b4ddd7c39 122/162: Honor ‘org-inlinetask-show-first-star’.,
Stefan Kangas <=
- [nongnu] elpa/org-superstar 7657a777fb 129/162: Adding inlinetask demos., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 94f35c20f8 135/162: Final cleanup before tagging, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 979d2dd199 161/162: Merge pull request #34 from taquangtrung/master, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 715a9681d3 087/162: Removing inconsistent use of apostrophe from README., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar da5c2208e9 085/162: Adding MELPA Stable badge, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 0d18d5ab99 090/162: Updating README to address issue #5., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 9c9c13280d 097/162: Added (tested) example for programmatically toggling lightweight-mode on startup., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar e225b78a5c 113/162: Updating README to reflect version change., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar abb8e863a1 109/162: Fix: Make org-superstar-headline-p non-interactive, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 2eed7bd4fe 098/162: Removed redundant sentence., Stefan Kangas, 2021/12/31