123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- (eval-when-compile (require 'cl))
- (defgroup org-bullets nil
- "Display bullets as UTF-8 characters."
- :group 'org-appearance)
- (defcustom org-bullets-bullet-list
- '(
- "◉"
- "○"
- "✸"
- "✿"
-
-
-
- )
- "This variable contains the list of bullets.
- It can contain any number of one-character strings.
- For levels beyond the size of the list, the stars will be
- displayed using the first items again."
- :group 'org-bullets
- :type '(repeat (string :tag "Bullet character")))
- (defcustom org-bullets-face-name nil
- "Allows to override `org-mode' bullets face.
- If set to a name of a face, that face will be used.
- Otherwise the face of the heading level will be used."
- :group 'org-bullets
- :type 'symbol)
- (defvar org-bullets-bullet-map
- '(keymap
- (mouse-1 . org-cycle)
- (mouse-2 . (lambda (e)
- (interactive "e")
- (mouse-set-point e)
- (org-cycle))))
- "Mouse events for bullets.
- If this is undesirable, one can remove them with
- \(setcdr org-bullets-bullet-map nil\)")
- (defun org-bullets-level-char (level)
- "Return a character corresponding to LEVEL."
- (string-to-char
- (nth (mod (1- level)
- (length org-bullets-bullet-list))
- org-bullets-bullet-list)))
- (define-minor-mode org-bullets-mode
- "UTF-8 bullets for `org-mode'."
- nil nil nil
- (let* ((keyword
- `((,org-outline-regexp-bol
- (0 (let (( level (- (match-end 0) (match-beginning 0) 1)))
- (compose-region (- (match-end 0) 2)
- (- (match-end 0) 1)
- (org-bullets-level-char level))
- (when (facep org-bullets-face-name)
- (put-text-property (- (match-end 0) 2)
- (- (match-end 0) 1)
- 'face
- org-bullets-face-name))
- (put-text-property (match-beginning 0)
- (- (match-end 0) 2)
- 'face (list :foreground
- (face-attribute
- 'default :background)))
- (put-text-property (match-beginning 0)
- (match-end 0)
- 'keymap
- org-bullets-bullet-map)
- nil))))))
- (if org-bullets-mode
- (progn (font-lock-add-keywords nil keyword)
- (font-lock-fontify-buffer))
- (save-excursion
- (goto-char (point-min))
- (font-lock-remove-keywords nil keyword)
- (while (re-search-forward org-outline-regexp-bol nil t)
- (decompose-region (match-beginning 0) (match-end 0)))
- (font-lock-fontify-buffer)))))
- (provide 'org-bullets)
|