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 one-character strings.
50 For levels beyond the size of the list, the stars will be
51 displayed using the first items again."
53 :type
'(repeat (string :tag
"Bullet character")))
55 (defcustom org-bullets-face-name nil
56 "Allows to override `org-mode' bullets face.
57 If set to a name of a face, that face will be used.
58 Otherwise the face of the heading level will be used."
62 (defvar org-bullets-bullet-map
65 (mouse-2 .
(lambda (e)
69 "Mouse events for bullets.
70 If this is undesirable, one can remove them with
72 \(setcdr org-bullets-bullet-map nil\)")
74 (defun org-bullets-level-char (level)
75 "Return a character corresponding to LEVEL."
78 (length org-bullets-bullet-list
))
79 org-bullets-bullet-list
)))
82 (define-minor-mode org-bullets-mode
83 "UTF-8 bullets for `org-mode'."
86 `((,org-outline-regexp-bol
87 (0 (let (( level
(- (match-end 0) (match-beginning 0) 1)))
88 (compose-region (- (match-end 0) 2)
90 (org-bullets-level-char level
))
91 (when (facep org-bullets-face-name
)
92 (put-text-property (- (match-end 0) 2)
95 org-bullets-face-name
))
96 (put-text-property (match-beginning 0)
98 'face
(list :foreground
100 'default
:background
)))
101 (put-text-property (match-beginning 0)
104 org-bullets-bullet-map
)
107 (progn (font-lock-add-keywords nil keyword
)
108 (font-lock-fontify-buffer))
110 (goto-char (point-min))
111 (font-lock-remove-keywords nil keyword
)
112 (while (re-search-forward org-outline-regexp-bol nil t
)
113 (decompose-region (match-beginning 0) (match-end 0)))
114 (font-lock-fontify-buffer)))))
116 (provide 'org-bullets
)
119 ;; coding: utf-8-emacs
122 ;;; org-bullets.el ends here