From: Alex Branham <alex.branham@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Support showing stars as pretty bullets
Date: Sun, 01 Apr 2018 15:59:51 -0500 [thread overview]
Message-ID: <874lkutzg8.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3351 bytes --]
Hello,
I've written this patch that makes use of prettify-symbols-mode to show
the stars in org headings as nice UTF bullets. There's already
org-bullet-mode[1] but that seems to have been abandoned, plus it isn't
included in org mode itself.
The one bug right now is that it'll show an asterisk as a UTF bullet if
it's _anywhere_ on a heading line. Is there an easy way to check if a
character is a part of the beginning stars? If this is something you'd
be interested in adding to org-mode, I can fix this part before the
change gets applied.
I've checked it out with and without org-indent-mode and hiding leading
stars. Everything seems to work well for me.
I've already signed the FSF copyright assignment papers.
Please cc me on replies since I'm not subscribed to the devel list :-)
Thanks,
Alex
Footnotes:
[1] https://github.com/sabof/org-bullets
------------------------------------------------------------
From 8ab48ccd43446bbe447108153c2dbb742d81895b Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@utexas.edu>
Date: Sun, 1 Apr 2018 15:49:31 -0500
Subject: [PATCH] Add support for showing stars as UTF bullets
* lisp/org.el(org-mode): Add local variables
* lisp/org.el(org-pretty-compose-p): New function
* lisp/org.el(org-prettify-alist): New variable
* etc/ORG-NEWS: Document new feature.
---
etc/ORG-NEWS | 3 +++
lisp/org.el | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0edd77115..bb57e9e82 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -228,6 +228,9 @@ parameters. See example bellow.
select sysdate from dual;
,#+END_SRC
#+END_SRC
+*** Add support for showing header stars as UTF-8 bullets
+This relies on ~prettify-symbols-mode~. To activate, either add this to
+~org-mode-hook~ or enable it globally with ~global-prettify-symbols-mode~.
** New functions
*** ~org-insert-structure-template~
diff --git a/lisp/org.el b/lisp/org.el
index 5e5087a59..35cc33c00 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5487,6 +5487,9 @@ The following commands are available:
(when org-startup-truncated (setq truncate-lines t))
(when org-startup-indented (require 'org-indent) (org-indent-mode 1))
(org-refresh-effort-properties)))
+ ;; Setup prettify mode
+ (setq-local prettify-symbols-alist org-prettify-alist)
+ (setq-local prettify-symbols-compose-predicate #'org-pretty-compose-p)
;; Try to set `org-hide' face correctly.
(let ((foreground (org-find-invisible-foreground)))
(when foreground
@@ -9551,6 +9554,18 @@ The cdr of LINK must be either a link description or nil."
(concat (format "%-45s" (substring desc 0 (min (length desc) 40)))
"<" (car link) ">")))
+(defvar-local org-prettify-alist '(("*" . ?•))
+ "An alist of symbols to prettify, see `prettify-symbols-alist'.
+Whether the symbol actually gets prettified is controlled by
+`org-pretty-compose-p', which see.")
+
+(defun org-pretty-compose-p (_start _end match)
+ "Return t if the symbol should be prettified.
+MATCH is the string match. See also
+`prettify-symbols-compose-predicate'."
+ (when (string= match "*")
+ (org-at-heading-p)))
+
;;;###autoload
(defun org-insert-link-global ()
"Insert a link like Org mode does.
--
2.16.3
[-- Attachment #2: 0001-Add-support-for-showing-stars-as-UTF-bullets.patch --]
[-- Type: text/x-patch, Size: 2398 bytes --]
From 8ab48ccd43446bbe447108153c2dbb742d81895b Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@utexas.edu>
Date: Sun, 1 Apr 2018 15:49:31 -0500
Subject: [PATCH] Add support for showing stars as UTF bullets
* lisp/org.el(org-mode): Add local variables
* lisp/org.el(org-pretty-compose-p): New function
* lisp/org.el(org-prettify-alist): New variable
* etc/ORG-NEWS: Document new feature.
---
etc/ORG-NEWS | 3 +++
lisp/org.el | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0edd77115..bb57e9e82 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -228,6 +228,9 @@ parameters. See example bellow.
select sysdate from dual;
,#+END_SRC
#+END_SRC
+*** Add support for showing header stars as UTF-8 bullets
+This relies on ~prettify-symbols-mode~. To activate, either add this to
+~org-mode-hook~ or enable it globally with ~global-prettify-symbols-mode~.
** New functions
*** ~org-insert-structure-template~
diff --git a/lisp/org.el b/lisp/org.el
index 5e5087a59..35cc33c00 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5487,6 +5487,9 @@ The following commands are available:
(when org-startup-truncated (setq truncate-lines t))
(when org-startup-indented (require 'org-indent) (org-indent-mode 1))
(org-refresh-effort-properties)))
+ ;; Setup prettify mode
+ (setq-local prettify-symbols-alist org-prettify-alist)
+ (setq-local prettify-symbols-compose-predicate #'org-pretty-compose-p)
;; Try to set `org-hide' face correctly.
(let ((foreground (org-find-invisible-foreground)))
(when foreground
@@ -9551,6 +9554,18 @@ The cdr of LINK must be either a link description or nil."
(concat (format "%-45s" (substring desc 0 (min (length desc) 40)))
"<" (car link) ">")))
+(defvar-local org-prettify-alist '(("*" . ?•))
+ "An alist of symbols to prettify, see `prettify-symbols-alist'.
+Whether the symbol actually gets prettified is controlled by
+`org-pretty-compose-p', which see.")
+
+(defun org-pretty-compose-p (_start _end match)
+ "Return t if the symbol should be prettified.
+MATCH is the string match. See also
+`prettify-symbols-compose-predicate'."
+ (when (string= match "*")
+ (org-at-heading-p)))
+
;;;###autoload
(defun org-insert-link-global ()
"Insert a link like Org mode does.
--
2.16.3
next reply other threads:[~2018-04-01 20:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-01 20:59 Alex Branham [this message]
2018-04-02 18:47 ` Support showing stars as pretty bullets Nicolas Goaziou
2018-04-03 0:41 ` Alex Branham
2018-04-03 1:11 ` William Denton
2018-04-03 6:39 ` Nicolas Goaziou
2018-04-03 14:30 ` Alex Branham
2018-04-03 20:33 ` Nicolas Goaziou
2018-04-04 22:14 ` Alex Branham
2018-04-05 12:50 ` Nicolas Goaziou
2018-04-10 16:00 ` Alex Branham
2018-04-14 10:20 ` Nicolas Goaziou
2018-04-14 13:10 ` Rasmus
2018-04-06 20:22 ` Rasmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874lkutzg8.fsf@gmail.com \
--to=alex.branham@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).