|
Attached is a patch that adds a customization variable for setting which characters you can use as bullets in plain lists. Unicode has all kinds of pretty characters like ❧ or ☞ that would be good for bullets, why limit ourselves to just [-+*]? The variable's "set" function sets associated other related variables, regular expressions using it, treating "*" specially since it isn't a plain-list bullet at the beginning of a line. Care is taken that the character "-" does not wind up in the middle of the character range (but there isn't special processing for "]", and maybe there should be). I put in some example sets to choose from in the customization menu, though they probably will not be usable since I understand Org-mode still has to support emacs versions that don't support Unicode. Please take a look, see if it's worth adding, tell me what else I need to do if necessary. Thanks!
~mark |
>From 5db3081b9487c09b17c7accfcf1b25f45002aa13 Mon Sep 17 00:00:00 2001 From: Mark Shoulson <[email protected]> Date: Wed, 18 Apr 2012 20:55:41 -0400 Subject: [PATCH] Lists: enable customization for arbitrary characters for plain list bullets
* lisp/org-list.el (org-list-bulletcharlist): new custom variable
to set a list of characters for use as the bullets in plain lists.
Entails a few other variables set along with it.
---
lisp/org-list.el | 67 +++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 882ce3d..c751d1f 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -360,17 +360,60 @@ specifically, type `block' is determined by the variable
"Regex corresponding to the end of a list.
It depends on `org-empty-line-terminates-plain-lists'.")
-(defconst org-list-full-item-re
- (concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)"
- "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
- "\\(?:\\(\\[[ X-]\\]\\)\\(?:[ \t]+\\|$\\)\\)?"
- "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?")
+;; There shouldn't really have to be two different values here, since
+;; they need to be changed in sync...
+
+(defvar org-list-bullet-re)
+(defvar org-list-bullet-chars)
+(defvar org-list-full-item-re nil
"Matches a list item and puts everything into groups:
group 1: bullet
group 2: counter
group 3: checkbox
group 4: description tag")
+(defcustom org-list-bulletcharlist '(?+ ?- ?*)
+ "Characters used as unordered plain list bullets.
+If nil, defaults to (?- ?+ ?*), i.e. hyphen, plus, and *. If * is present,
+it only matches when not at the beginning of the line (it must be preceded
+by whitespace).
+
+Using letters as bullet characters is not recommended, as they also get
+interpreted as ordered lists."
+ :group 'org-plain-lists
+ :type '(choice (const nil)
+ (const :tag "(+ - *)" '(?+ ?- ?*))
+ (const :tag "(+ - * â£)" '(?+ ?- ?* ?â£))
+ (const :tag "(â ⦠⧠â¥)" '(?â ?⦠?â§ ?â¥))
+ (repeat character))
+ :set (lambda (name val)
+ (let* ((val (or val '(?- ?+ ?*)))
+ ;; - mustn't be in the middle! Place it in front.
+ (val (if (member ?- val)
+ (cons ?- (remove ?- val))
+ val))
+ (star-p (member ?* val))
+ (val (remove ?* val)))
+ (setq org-list-bullet-chars
+ (concat (eval `(string ,@val))
+ (when star-p "*")))
+ (setq org-list-full-item-re
+ (concat "^[ \t]*\\(\\(?:[" org-list-bullet-chars "]"
+ "\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)"
+ "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
+ "\\(?:\\(\\[[ X-]\\]\\)\\(?:[ \t]+\\|$\\)\\)?"
+ "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"))
+ ;; * is a special case
+ (setq org-list-bullet-re
+ (concat
+ "\\(?:"
+ (when star-p "[[:blank:]]+\\*")
+ (when (and star-p val) "\\|")
+ "[[:blank:]]*["
+ (when val (eval `(string ,@val)))
+ "]\\)")))
+ (set name val)))
+
(defun org-item-re ()
"Return the correct regular expression for plain lists."
(let ((term (cond
@@ -379,8 +422,8 @@ group 4: description tag")
((= org-plain-list-ordered-item-terminator ?.) "\\.")
(t "[.)]")))
(alpha (if org-alphabetical-lists "\\|[A-Za-z]" "")))
- (concat "\\([ \t]*\\([-+]\\|\\(\\([0-9]+" alpha "\\)" term
- "\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)")))
+ (concat "\\(" org-list-bullet-re "\\|[ \t]*\\(\\(\\([0-9]+" alpha "\\)" term
+ "\\)\\)\\)\\([ \t]+\\|$\\)")))
(defsubst org-item-beginning-re ()
"Regexp matching the beginning of a plain list item."
@@ -2229,7 +2272,7 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
(t (org-trim bullet))))
;; Compute list of possible bullets, depending on context.
(bullet-list
- (append '("-" "+" )
+ (append (mapcar 'char-to-string (string-to-list org-list-bullet-chars))
;; *-bullets are not allowed at column 0.
(unless (and bullet-rule-p
(looking-at "\\S-")) '("*"))
@@ -2403,7 +2446,9 @@ With optional prefix argument ALL, do this for the whole buffer."
(interactive "P")
(save-excursion
(let ((cookie-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
- (box-re "^[ \t]*\\([-+*]\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)")
+ (box-re (concat
+ "^[ \t]*\\([" org-list-bullet-chars "]"
+ "\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)"))
(recursivep
(or (not org-hierarchical-checkbox-statistics)
(string-match "\\<recursive\\>"
@@ -2812,7 +2857,9 @@ COMPARE-FUNC to compare entries."
(point) struct))))
(value-to-sort
(lambda ()
- (when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+")
+ (when (looking-at (concat
+ "[ \t]*\\(?:[" org-list-bullet-chars "]"
+ "\\|[0-9.)]\\)+\\([ \t]+\\[[- X]\\]\\)?[ \t]+"))
(cond
((= dcst ?n)
(string-to-number (buffer-substring (match-end 0)
--
1.7.7.6
