From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Mark E. Shoulson" Subject: Flexible plain list bullets Date: Wed, 18 Apr 2012 21:24:45 -0400 Message-ID: <4F8F695D.5090600@kli.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040200050502070803060204" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:33165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKg7J-0007GD-GD for emacs-orgmode@gnu.org; Wed, 18 Apr 2012 21:25:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKg7E-0002PQ-Sw for emacs-orgmode@gnu.org; Wed, 18 Apr 2012 21:25:01 -0400 Received: from pi.meson.org ([96.56.207.26]:41798) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SKg7E-00026l-MD for emacs-orgmode@gnu.org; Wed, 18 Apr 2012 21:24:56 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------040200050502070803060204 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

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

--------------040200050502070803060204 Content-Type: text/x-patch; name="0001-Lists-enable-customization-for-arbitrary-characters-.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0001-Lists-enable-customization-for-arbitrary-characters-.pa"; filename*1="tch" >From 5db3081b9487c09b17c7accfcf1b25f45002aa13 Mon Sep 17 00:00:00 2001 From: Mark Shoulson 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 "\\" @@ -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 --------------040200050502070803060204--