1 ;;; org-bullets.el --- Show bullets in org-mode as UTF-8 characters
4 ;;; URL: https://github.com/sabof/org-bullets
6 ;; This file is NOT part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 3, or (at
11 ;; your option) any later version.
13 ;; This program is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;; General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program ; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
25 ;; The project is hosted at https://github.com/sabof/org-bullets
26 ;; The latest version, and all the relevant information can be found there.
30 (eval-when-compile (require 'cl
))
32 (defgroup org-bullets nil
33 "Display bullets as UTF-8 characters"
34 :group
'org-appearance
)
36 ;; A nice collection of unicode bullets:
37 ;; http://nadeausoftware.com/articles/2007/11/latency_friendly_customized_bullets_using_unicode_characters
38 (defcustom org-bullets-bullet-list
44 ;; ♥ ● ◇ ✚ ✜ ☯ ◆ ♠ ♣ ♦ ☢ ❀ ◆ ◖ ▶
48 "This variable contains the list of bullets.
49 It can contain any number of symbols, which will be repeated."
51 :type
'(repeat (string :tag
"Bullet character")))
53 (defcustom org-bullets-face-name nil
54 "This variable allows the org-mode bullets face to be
55 overridden. If set to a name of a face, that face will be
56 used. Otherwise the face of the heading level will be used."
60 (defvar org-bullets-bullet-map
68 "Mouse events for bullets.
69 Should this be undesirable, one can remove them with
71 \(setcdr org-bullets-bullet-map nil\)")
73 (defun org-bullets-level-char (level)
76 (length org-bullets-bullet-list
))
77 org-bullets-bullet-list
)))
80 (define-minor-mode org-bullets-mode
81 "UTF8 Bullets for org-mode"
85 (0 (let (( level
(- (match-end 0) (match-beginning 0) 1)))
86 (compose-region (- (match-end 0) 2)
88 (org-bullets-level-char level
))
89 (when (facep org-bullets-face-name
)
90 (put-text-property (- (match-end 0) 2)
93 org-bullets-face-name
))
94 (put-text-property (match-beginning 0)
96 'face
(list :foreground
98 'default
:background
)))
99 (put-text-property (match-beginning 0)
102 org-bullets-bullet-map
)
105 (progn (font-lock-add-keywords nil keyword
)
106 (font-lock-fontify-buffer))
108 (goto-char (point-min))
109 (font-lock-remove-keywords nil keyword
)
110 (while (re-search-forward "^\\*+ " nil t
)
111 (decompose-region (match-beginning 0) (match-end 0)))
112 (font-lock-fontify-buffer))
115 (provide 'org-bullets
)
117 ;;; org-bullets.el ends here