From 32b7b27acefe793209d27c3f959d46551cf744ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8hannes=20Lippmann?= Date: Fri, 10 Feb 2017 22:10:12 +0100 Subject: [PATCH 01/16] Remove code that tries to hide leading stars. This is already thought of in orgmode (see hide-leading-stars), we shouldn't reimplement it in org-bullets. Also it sort of didn't work in terminals. --- org-bullets.el | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index b161148..cd62d80 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -78,7 +78,7 @@ Should this be undesirable, one can remove them with ;;;###autoload (define-minor-mode org-bullets-mode - "UTF8 Bullets for org-mode" + "UTF8 Bullets for org-mode" nil nil nil (let* (( keyword `(("^\\*+ " @@ -99,11 +99,6 @@ Should this be undesirable, one can remove them with (- (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 From b4cef1a587d6809122725cc1997b187d69b9105b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8hannes=20Lippmann?= Date: Fri, 10 Feb 2017 22:39:25 +0100 Subject: [PATCH 02/16] Added documentation about hiding leading stars to README. --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ca3dd9..7a67165 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,11 @@ Copy the file somewhere in your load-path, then add to your .emacs: (require 'org-bullets) (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))) -select, do [M-x eval-region]. The *s will be replaced with utf-8 bullets next time you open an org file \ No newline at end of file +select, do [M-x eval-region]. The *s will be replaced with utf-8 bullets next time you open an org file + + +#### Hiding leading stars + +org-bullets used to hide the leading stars and only show the last one (as a bullet). This feature was removed since there already is a feature in org-mode which does exactly that (read about it [here](https://www.gnu.org/software/emacs/manual/html_node/org/Clean-view.html) and since it didn't work well for emacs running in a terminal. For enabling it add this to your .emacs: + + (setq org-hide-leading-stars t) From c9f34fa2ee76f8b50d4f7c7a8b5f713ae35fa79e Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 10:03:17 -0400 Subject: [PATCH 03/16] Add docstring * org-bullets.el (org-bullets-bullet-map): Fix documentation style. (org-bullets-level-char): Add docstring. --- org-bullets.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index cd62d80..50d4905 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -66,11 +66,15 @@ It can contain any number of symbols, which will be repeated." (mouse-set-point e) (org-cycle)))) "Mouse events for bullets. -Should this be undesirable, one can remove them with +Should this be undesirable, one can remove them with: -\(setcdr org-bullets-bullet-map nil\)") +\(setcdr org-bullets-bullet-map nil)") (defun org-bullets-level-char (level) + "Return the bullet character for LEVEL. + +The bullet character is periodic in that if LEVEL is greater than +the `org-bullets-bullet-list' lenght, the modulo is used." (string-to-char (nth (mod (1- level) (length org-bullets-bullet-list)) @@ -78,7 +82,7 @@ Should this be undesirable, one can remove them with ;;;###autoload (define-minor-mode org-bullets-mode - "UTF8 Bullets for org-mode" + "UTF8 Bullets for org-mode." nil nil nil (let* (( keyword `(("^\\*+ " From bf421428c8c2caf3158001c26ae7940cb1c9b689 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 10:06:25 -0400 Subject: [PATCH 04/16] Add customization options * org-bullets.el (org-bullets-face-name): Change customization type for nil or a face. This allows auto-completing a face. --- org-bullets.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index 50d4905..a779e23 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -51,11 +51,13 @@ It can contain any number of symbols, which will be repeated." :type '(repeat (string :tag "Bullet character"))) (defcustom org-bullets-face-name nil - "This variable allows the org-mode bullets face to be - overridden. If set to a name of a face, that face will be - used. Otherwise the face of the heading level will be used." + "Face to override `org-mode' bullets face. + +If set to a name of a face, that face will be used. When nil, do +not change the face used." :group 'org-bullets - :type 'symbol) + :type '(choice (const :tag "Off" nil) + (face :tag "Face"))) (defvar org-bullets-bullet-map '(keymap From 2fb1db0eaa784e80b9d59b7504dd54ee41a27f9b Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 10:07:41 -0400 Subject: [PATCH 05/16] Refactor fontification function calls * org-bullets.el (org-bullets-mode): Replace the use of the interactive-only function `font-lock-fontify-buffer` to `font-lock-flush`. --- org-bullets.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index a779e23..ae62964 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -113,14 +113,13 @@ the `org-bullets-bullet-list' lenght, the modulo is used." (if org-bullets-mode (progn (font-lock-add-keywords nil keyword) - (font-lock-fontify-buffer)) + (font-lock-flush)) (save-excursion (goto-char (point-min)) (font-lock-remove-keywords nil keyword) (while (re-search-forward "^\\*+ " nil t) (decompose-region (match-beginning 0) (match-end 0))) - (font-lock-fontify-buffer)) - ))) + (font-lock-flush))))) (provide 'org-bullets) From 4fc565a3c700e0c570d753428ff80466bb88382d Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 10:29:37 -0400 Subject: [PATCH 06/16] Add indentation --- org-bullets.el | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index ae62964..e01f8d7 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -62,11 +62,10 @@ not change the face used." (defvar org-bullets-bullet-map '(keymap (mouse-1 . org-cycle) - (mouse-2 - . (lambda (e) - (interactive "e") - (mouse-set-point e) - (org-cycle)))) + (mouse-2 . (lambda (e) + (interactive "e") + (mouse-set-point e) + (org-cycle)))) "Mouse events for bullets. Should this be undesirable, one can remove them with: @@ -86,30 +85,30 @@ the `org-bullets-bullet-list' lenght, the modulo is used." (define-minor-mode org-bullets-mode "UTF8 Bullets for org-mode." nil nil nil - (let* (( keyword - `(("^\\*+ " - (0 (let* (( level (- (match-end 0) (match-beginning 0) 1)) - ( is-inline-task - (and (boundp 'org-inlinetask-min-level) - (>= level org-inlinetask-min-level)))) - (compose-region (- (match-end 0) 2) - (- (match-end 0) 1) - (org-bullets-level-char level)) - (when is-inline-task - (compose-region (- (match-end 0) 3) - (- (match-end 0) 2) - (org-bullets-level-char level))) - (when (facep org-bullets-face-name) - (put-text-property (- (match-end 0) - (if is-inline-task 3 2)) - (- (match-end 0) 1) - 'face - org-bullets-face-name)) - (put-text-property (match-beginning 0) - (match-end 0) - 'keymap - org-bullets-bullet-map) - nil)))))) + (let* ((keyword + `(("^\\*+ " + (0 (let* ((level (- (match-end 0) (match-beginning 0) 1)) + (is-inline-task + (and (boundp 'org-inlinetask-min-level) + (>= level org-inlinetask-min-level)))) + (compose-region (- (match-end 0) 2) + (- (match-end 0) 1) + (org-bullets-level-char level)) + (when is-inline-task + (compose-region (- (match-end 0) 3) + (- (match-end 0) 2) + (org-bullets-level-char level))) + (when (facep org-bullets-face-name) + (put-text-property (- (match-end 0) + (if is-inline-task 3 2)) + (- (match-end 0) 1) + 'face + org-bullets-face-name)) + (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) From 8dd207d6ac8ae2693f56254c7a98bc9b988f4900 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 10:30:10 -0400 Subject: [PATCH 07/16] Remove unused import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove importing the `cl` feature since it’s not used anywhere --- org-bullets.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index e01f8d7..6e83295 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -27,8 +27,6 @@ ;;; Code: -(eval-when-compile (require 'cl)) - (defgroup org-bullets nil "Display bullets as UTF-8 characters" :group 'org-appearance) From 7ac3916bc702cc416b42638bc487c8a627986ec4 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 11:10:28 -0400 Subject: [PATCH 08/16] Add mouse-face to level region * org-bullets.el (org-bullets-mode): Use `add-text-properties` instead of `put-text-property`. Add higlight mouse-face and help-echo message. --- org-bullets.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index 6e83295..ed26c1f 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -102,10 +102,11 @@ the `org-bullets-bullet-list' lenght, the modulo is used." (- (match-end 0) 1) 'face org-bullets-face-name)) - (put-text-property (match-beginning 0) - (match-end 0) - 'keymap - org-bullets-bullet-map) + (add-text-properties (match-beginning 0) + (match-end 0) + (list 'keymap org-bullets-bullet-map + 'mouse-face 'highlight + 'help-echo "mouse-2: visibility cycling for Org mode")) nil)))))) (if org-bullets-mode (progn From 551e2fa617e18f431c1cf6e0681665f4ea9783a5 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 14:17:10 -0400 Subject: [PATCH 09/16] Add leading star options * org-bullets.el (org-bullets-compose-leading-stars): Add customization variable to set the composition behavior (replace characters). (org-bullets--char-series): Add function to calculate the current character from a series and the current level. (org-bullets-mode): Add the series variable. Add pattern matching case for setting the series variable according to `org-bullets-compose-leading-stars`. --- org-bullets.el | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/org-bullets.el b/org-bullets.el index ed26c1f..ac2fead 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -57,6 +57,19 @@ not change the face used." :type '(choice (const :tag "Off" nil) (face :tag "Face"))) +(defcustom org-bullets-compose-leading-stars + (and org-hide-leading-stars hide) + "Replace leading stars with the bullet character. + +This is different from `org-hide-leading-stars' in that it +replace the printed character instead of changing the face." + :group 'org-bullets + :type '(choice (const :tag "Keep leading stars" nil) + (const :tag "Hide leading stars" hide) + (const :tag "Use current level character" level) + (string :tag "Use custom character(s)"))) + + (defvar org-bullets-bullet-map '(keymap (mouse-1 . org-cycle) @@ -79,6 +92,14 @@ the `org-bullets-bullet-list' lenght, the modulo is used." (length org-bullets-bullet-list)) org-bullets-bullet-list))) +(defun org-bullets--char-series (string level) + "Private. + +Get the character in STRING at position LEVEL. + +If LEVEL is greater than the STRING series length, use the reminder." + (aref string (mod level (length string)))) + ;;;###autoload (define-minor-mode org-bullets-mode "UTF8 Bullets for org-mode." @@ -88,7 +109,8 @@ the `org-bullets-bullet-list' lenght, the modulo is used." (0 (let* ((level (- (match-end 0) (match-beginning 0) 1)) (is-inline-task (and (boundp 'org-inlinetask-min-level) - (>= level org-inlinetask-min-level)))) + (>= level org-inlinetask-min-level))) + (series)) (compose-region (- (match-end 0) 2) (- (match-end 0) 1) (org-bullets-level-char level)) @@ -102,6 +124,17 @@ the `org-bullets-bullet-list' lenght, the modulo is used." (- (match-end 0) 1) 'face org-bullets-face-name)) + + (pcase org-bullets-compose-leading-stars + ((pred stringp) (setq series org-bullets-compose-leading-stars)) + ('hide (setq series " ")) + ('level (setq series (apply #'concat org-bullets-bullet-list)))) + + (if series + (dotimes (pos (1- level)) + (compose-region (+ (match-beginning 0) pos) + (+ (match-beginning 0) pos 1) + (org-bullets--char-series series pos)))) (add-text-properties (match-beginning 0) (match-end 0) (list 'keymap org-bullets-bullet-map From 585f1d753abe084a79df401e778721ffd4aef9bc Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 15:22:20 -0400 Subject: [PATCH 10/16] Refactor bullet events * org-bullets.el (org-bullets--bullet-events): Rename `org-bullets-bullet-map` to `org-bullets--bullet-events` in order to include other event text-properties. (org-bullets-mode): Use `org-bullets--bullet-events` instead of hard-coding text properties. --- org-bullets.el | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index ac2fead..03ec89b 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -70,17 +70,18 @@ replace the printed character instead of changing the face." (string :tag "Use custom character(s)"))) -(defvar org-bullets-bullet-map +(defconst org-bullets--bullet-events '(keymap - (mouse-1 . org-cycle) - (mouse-2 . (lambda (e) - (interactive "e") - (mouse-set-point e) - (org-cycle)))) - "Mouse events for bullets. -Should this be undesirable, one can remove them with: + ((mouse-1 . org-cycle) + (mouse-2 . (lambda (e) + (interactive "e") + (mouse-set-point e) + (org-cycle)))) + mouse-face highlight + help-echo "mouse-2: visibility cycling for Org mode") + "Private. -\(setcdr org-bullets-bullet-map nil)") +Mouse events for bullets.") (defun org-bullets-level-char (level) "Return the bullet character for LEVEL. @@ -137,9 +138,7 @@ If LEVEL is greater than the STRING series length, use the reminder." (org-bullets--char-series series pos)))) (add-text-properties (match-beginning 0) (match-end 0) - (list 'keymap org-bullets-bullet-map - 'mouse-face 'highlight - 'help-echo "mouse-2: visibility cycling for Org mode")) + org-bullets--bullet-events) nil)))))) (if org-bullets-mode (progn From 308acbbf6342a8f745eeb51ea761b15761dec4c9 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 15:25:05 -0400 Subject: [PATCH 11/16] Add option to remove org-bullets events * org-bullets.el (org-bullets-mouse-events): Add this customization variable to disable mouse events easily. (org-bullets-mode): Refactor to only activate mouse events when `org-bullets-mouse-events` is set. --- org-bullets.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index 03ec89b..9dfb220 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -69,6 +69,10 @@ replace the printed character instead of changing the face." (const :tag "Use current level character" level) (string :tag "Use custom character(s)"))) +(defcustom org-bullets-mouse-events t + "Allow attaching mouse events to org bullets." + :group 'org-bullets + :type '(boolean :tag "Allow help-echo and click events" t)) (defconst org-bullets--bullet-events '(keymap @@ -136,9 +140,10 @@ If LEVEL is greater than the STRING series length, use the reminder." (compose-region (+ (match-beginning 0) pos) (+ (match-beginning 0) pos 1) (org-bullets--char-series series pos)))) - (add-text-properties (match-beginning 0) - (match-end 0) - org-bullets--bullet-events) + (when org-bullets-mouse-events + (add-text-properties (match-beginning 0) + (match-end 0) + org-bullets--bullet-events)) nil)))))) (if org-bullets-mode (progn From 25c65c0e585a0219364a3113b02ed9fceea488a8 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 15:32:57 -0400 Subject: [PATCH 12/16] Fix initial value error * org-bullets.el (org-bullets-face-name): Add quote to symbol. --- org-bullets.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-bullets.el b/org-bullets.el index 9dfb220..78376ec 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -58,7 +58,7 @@ not change the face used." (face :tag "Face"))) (defcustom org-bullets-compose-leading-stars - (and org-hide-leading-stars hide) + (and org-hide-leading-stars 'hide) "Replace leading stars with the bullet character. This is different from `org-hide-leading-stars' in that it From 60e996b2a5c055e63fbd9982b5f27548bd456771 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 15:35:12 -0400 Subject: [PATCH 13/16] Support lexical scoping --- org-bullets.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org-bullets.el b/org-bullets.el index 78376ec..73c1e7e 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -1,5 +1,5 @@ -;;; org-bullets.el --- Show bullets in org-mode as UTF-8 characters ;;; Version: 0.2.4 +;;; org-bullets.el --- Show bullets in org-mode as UTF-8 characters -*- lexical-binding: t -*- ;;; Author: sabof ;;; URL: https://github.com/sabof/org-bullets @@ -27,6 +27,9 @@ ;;; Code: +(require 'org) + + (defgroup org-bullets nil "Display bullets as UTF-8 characters" :group 'org-appearance) From 0d9490bceefda58ad49935a0a8a793fee9d0bd10 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 15:41:33 -0400 Subject: [PATCH 14/16] Add docstring --- org-bullets.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index 73c1e7e..2c4f270 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -32,7 +32,8 @@ (defgroup org-bullets nil "Display bullets as UTF-8 characters" - :group 'org-appearance) + :group 'org-appearance + :link '(url-link "https://github.com/sabof/org-bullets")) ;; A nice collection of unicode bullets: ;; http://nadeausoftware.com/articles/2007/11/latency_friendly_customized_bullets_using_unicode_characters @@ -47,6 +48,7 @@ ;; ► • ★ ▸ ) "This variable contains the list of bullets. + It can contain any number of symbols, which will be repeated." :group 'org-bullets :type '(repeat (string :tag "Bullet character"))) @@ -65,7 +67,10 @@ not change the face used." "Replace leading stars with the bullet character. This is different from `org-hide-leading-stars' in that it -replace the printed character instead of changing the face." +replace the printed character instead of changing the face. + +When `org-hide-leading-stars' is non nil, set use the hide +option." :group 'org-bullets :type '(choice (const :tag "Keep leading stars" nil) (const :tag "Hide leading stars" hide) @@ -73,7 +78,7 @@ replace the printed character instead of changing the face." (string :tag "Use custom character(s)"))) (defcustom org-bullets-mouse-events t - "Allow attaching mouse events to org bullets." + "Attach mouse events to org bullets." :group 'org-bullets :type '(boolean :tag "Allow help-echo and click events" t)) @@ -88,7 +93,7 @@ replace the printed character instead of changing the face." help-echo "mouse-2: visibility cycling for Org mode") "Private. -Mouse events for bullets.") +Mouse events to be attached to bullet text-properties.") (defun org-bullets-level-char (level) "Return the bullet character for LEVEL. @@ -110,7 +115,7 @@ If LEVEL is greater than the STRING series length, use the reminder." ;;;###autoload (define-minor-mode org-bullets-mode - "UTF8 Bullets for org-mode." + "Add UTF-8 Bullets for `org-mode'." nil nil nil (let* ((keyword `(("^\\*+ " From 5a21e91116f25bd50d450791a703c02dfd21ff88 Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 15:41:57 -0400 Subject: [PATCH 15/16] Bump version --- org-bullets.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-bullets.el b/org-bullets.el index 2c4f270..a9128cb 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -1,5 +1,5 @@ -;;; Version: 0.2.4 ;;; org-bullets.el --- Show bullets in org-mode as UTF-8 characters -*- lexical-binding: t -*- +;;; Version: 0.3.0 ;;; Author: sabof ;;; URL: https://github.com/sabof/org-bullets From 905378cd40abdee98964bf8c0d44b092572ac33f Mon Sep 17 00:00:00 2001 From: Etienne Date: Thu, 14 Sep 2017 16:11:16 -0400 Subject: [PATCH 16/16] Update packaging meta-data --- org-bullets.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/org-bullets.el b/org-bullets.el index a9128cb..454bd30 100644 --- a/org-bullets.el +++ b/org-bullets.el @@ -1,7 +1,9 @@ ;;; org-bullets.el --- Show bullets in org-mode as UTF-8 characters -*- lexical-binding: t -*- -;;; Version: 0.3.0 -;;; Author: sabof -;;; URL: https://github.com/sabof/org-bullets +;; Version: 0.3.0 +;; Package-Requires: ((emacs "25.0")) +;; Keywords: outlines, hypermedia, calendar, wp +;; Author: sabof +;; URL: https://github.com/sabof/org-bullets ;; This file is NOT part of GNU Emacs. ;; @@ -75,12 +77,14 @@ option." :type '(choice (const :tag "Keep leading stars" nil) (const :tag "Hide leading stars" hide) (const :tag "Use current level character" level) - (string :tag "Use custom character(s)"))) + (string :tag "Use custom character(s)")) + :package-version '(org-bullets . "0.3.0")) (defcustom org-bullets-mouse-events t "Attach mouse events to org bullets." :group 'org-bullets - :type '(boolean :tag "Allow help-echo and click events" t)) + :type '(boolean :tag "Allow help-echo and click events" t) + :package-version '(org-bullets . "0.3.0")) (defconst org-bullets--bullet-events '(keymap