From 8ab48ccd43446bbe447108153c2dbb742d81895b Mon Sep 17 00:00:00 2001 From: Alex Branham 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