emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Nathaniel Flath <flat0103@gmail.com>
Cc: Bernt Hansen <bernt@norang.ca>,
	Jacob Mitchell <jacob.d.mitchell@gmail.com>,
	emacs-orgmode@gnu.org
Subject: Re: Re: [PATCH] Alphabetical ordered lists
Date: Tue, 21 Sep 2010 14:48:54 +0200	[thread overview]
Message-ID: <393C5110-E4D3-4B36-8F4E-4F94B5AA0F93@gmail.com> (raw)
In-Reply-To: <AANLkTi=JORE+E7Hz_HU-_kmQ9UKPnq5da5iTm2xtG_4_@mail.gmail.com>

Hi everyone,

I would like to know if there are more people interested in this, and  
if there are people who are willing to test this patch, to make sure  
nothing breaks.

Nicolas, can you in particular please take a look at this - I believe  
you earlier said that you saw problems with it.

Thanks!

- Carsten

On Sep 18, 2010, at 9:43 AM, Nathaniel Flath wrote:

> Hey,
> I gave another shot at this, now that my computer is no longer dead.
> I believe it fixes the issues described earlier - let me know of any
> feedback.
> (Also - I don't know how to get GMail to attach this as anything other
> than application/octet-stream, so the text is in the message as well.
> Nathaniel Flath
>
>
> Attachment:
>
> diff --git a/lisp/org-list.el b/lisp/org-list.el
> index d9fc24e..88d5a9b 100644
> --- a/lisp/org-list.el
> +++ b/lisp/org-list.el
> @@ -287,14 +287,14 @@ It depends on `org-empty-line-terminates-plain- 
> lists'."
>   "Return the correct regular expression for plain lists.
> If GENERAL is non-nil, return the general regexp independent of the  
> value
> of `org-plain-list-ordered-item-terminator'."
> -  (cond
> -   ((or general (eq org-plain-list-ordered-item-terminator t))
> -    "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\ 
> \|$\\)")
> -   ((= org-plain-list-ordered-item-terminator ?.)
> -    "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\ 
> \|$\\)")
> +(cond
> + ((or general (eq org-plain-list-ordered-item-terminator t))
> +  "\\([ \t]*\\([-+]\\|\\([0-9A-Za-z]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \ 
> \|$\\)")
> +  ((= org-plain-list-ordered-item-terminator ?.)
> +   "\\([ \t]*\\([-+]\\|\\([0-9A-Za-z]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \ 
> \|$\\)")
>    ((= org-plain-list-ordered-item-terminator ?\))
> -    "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$ 
> \\)")
> -   (t (error "Invalid value of `org-plain-list-ordered-item- 
> terminator'"))))
> +    "\\([ \t]*\\([-+]\\|\\([0-9A-Za-z]+)\\)\\)\\|[ \t]+\\*\\)\\( \\| 
> $\\)")
> +    (t (error "Invalid value of `org-plain-list-ordered-item- 
> terminator'"))))
>
> (defconst org-item-beginning-re (concat "^" (org-item-re))
>   "Regexp matching the beginning of a plain list item.")
> @@ -530,7 +530,7 @@ List ending is determined by the indentation of  
> text. See
>        (save-excursion
> 	 (goto-char (match-end 0))
>          ;; Ignore counter if any
> -         (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\ 
> \)?")
> +         (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9A-Za-z]+\\] 
> [ \t]*\\)?")
>            (goto-char (match-end 0)))
> 	 (looking-at regexp))))
>
> @@ -1135,11 +1135,11 @@ bullet string and bullet counter, if any."
>     (list (point-at-bol)
>           (org-get-indentation)
>           (progn
> -            (looking-at "^[ \t]*\\([-+*0-9.)]+[ \t]+\\)")
> +            (looking-at "^[ \t]*\\([-+*0-9A-Za-z.)]+[ \t]+\\)")
>             (match-string 1))
>           (progn
>             (goto-char (match-end 0))
> -            (and (looking-at "\\[@\\(?:start:\\)?\\([0-9]+\\)\\]")
> +            (and (looking-at "\\[@\\(?:start:\\)?\\([0-9A-Za-z]+\\)\ 
> \]")
>                  (match-string 1))))))
>
> (defun org-list-struct (begin end top bottom &optional outdent)
> @@ -1259,8 +1259,10 @@ This function modifies STRUCT."
> 		     (let ((counter (nth 3 item))
> 			   (bullet (org-list-bullet-string (nth 2 item))))
> 		       (cond
> -			((and (string-match "[0-9]+" bullet) counter)
> +			((and (string-match "[0-9A-Za-z]+" bullet) counter)
> 			 (replace-match counter nil nil bullet))
> +			((string-match "[A-Za-z]+" bullet)
> +			 (replace-match "a" nil nil bullet))
> 			((string-match "[0-9]+" bullet)
> 			 (replace-match "1" nil nil bullet))
> 			(t bullet)))))
> @@ -1268,7 +1270,7 @@ This function modifies STRUCT."
> 		    (setcdr item (list (nth 1 item) bullet (nth 3 item)))))
> 	 (get-bul (lambda (item bullet)
> 		    (let* ((counter (nth 3 item)))
> -		      (if (and counter (string-match "[0-9]+" bullet))
> +		      (if (and counter (string-match "[0-9A-Za-z]+" bullet))
> 			  (replace-match counter nil nil bullet)
> 			bullet))))
> 	 (fix-bul
> @@ -1582,13 +1584,50 @@ It determines the number of whitespaces to
> append by looking at
>           " ")))
>      nil nil bullet 1)))
>
> +(defun org-increment-string (str cap)
> +  "Increments str (a->a, b->b, z->aa, aa->ab etc).  If cap is non- 
> nil, then
> +   the letters are capitalized."
> +  (let ((res (org-convert-num-to-alpha-str
> +	      (1+ (org-convert-alpha-str-to-num str 1 (length str) cap))  
> cap))
> +	(z (if cap ?Z ?z))
> +	(b (if cap ?B ?b))
> +	(a (if cap ?A ?a)))
> +    (if (and(= (string-to-char str) z)
> +            (= (string-to-char res) b))
> +        (concat (if cap "A" "a")  (substring res 1))
> +      (concat (make-string (- (length str) (length res)) a)  res))))
> +
> +(defun org-convert-alpha-str-to-num (str n pos cap)
> +  "Converts the substring consisting of locations pos to pos-n to a
> +   numeric representation."
> +  (let ((a (if cap ?A ?a)))
> +    (if (= pos 1) (* (- (string-to-char str) a) n)
> +      (+ (* (- (nth (1- pos) (string-to-list str)) a) n)
> +	 (org-convert-alpha-str-to-num str (* 26 n) (1- pos) cap)))))
> +
> +(defun org-convert-num-to-alpha-str (n cap)
> +  "Converts the number n to a alphabetical, base-26 representation."
> +  (if (= n 0) ""
> +    (concat (org-convert-num-to-alpha-str (/ n 26) cap)
> +            (string (+ (if cap ?A ?a) (% n 26))))))
> +
> (defun org-list-inc-bullet-maybe (bullet)
>   "Increment BULLET if applicable."
> -  (if (string-match "[0-9]+" bullet)
> +  (let ((case-fold-search nil))
> +    (cond
> +     ((string-match "[0-9]+" bullet)
>       (replace-match
>        (number-to-string (1+ (string-to-number (match-string 0  
> bullet))))
> -       nil nil bullet)
> -    bullet))
> +       nil nil bullet))
> +     ((string-match "[a-z]+" bullet)
> +      (replace-match
> +       (org-increment-string (match-string 0 bullet) nil)
> +       nil nil bullet))
> +     ((string-match "[A-Z]+" bullet)
> +      (replace-match
> +       (org-increment-string (match-string 0 bullet) t)
> +       nil nil bullet))
> +     (t bullet))))
>
> (defun org-list-repair (&optional force-bullet top bottom)
>   "Make sure all items are correctly indented, with the right bullet.
> @@ -1980,7 +2019,7 @@ compare entries."
> 			   (goto-char (org-end-of-item-before-blank end))))
> 	     (value-to-sort
> 	      (lambda ()
> -		(when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t] 
> +")
> +		(when (looking-at "[ \t]*[-+*0-9A-Za-z.)]+\\([ \t]+\\[[- X]\\]\\)? 
> [ \t]+")
> 		  (cond
> 		   ((= dcst ?n)
> 		    (string-to-number (buffer-substring (match-end 0)
> @@ -2028,7 +2067,7 @@ sublevels as a list of strings."
>     (while (org-search-forward-unenclosed org-item-beginning-re end t)
>       (save-excursion
> 	(beginning-of-line)
> -	(setq ltype (cond ((looking-at-p "^[ \t]*[0-9]") 'ordered)
> +	(setq ltype (cond ((looking-at-p "^[ \t]*[0-9A-Za-z]") 'ordered)
> 			  ((org-at-item-description-p) 'descriptive)
> 			  (t 'unordered))))
>       (let* ((indent1 (org-get-indentation))
> @@ -2037,7 +2076,7 @@ sublevels as a list of strings."
> 					       (org-end-of-item-or-at-child end))))
> 	     (nextindent (if (= (point) end) 0 (org-get-indentation)))
> 	     (item (if (string-match
> -			"^\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\([xX ]\\)\\]"
> +			"^\\(?:\\[@\\(?:start:\\)?[0-9A-Za-z]+\\][ \t]*\\)?\\[\\([xX ]\\) 
> \\]"
> 			item)
> 		       (replace-match (if (equal (match-string 1 item) " ")
> 					  "CBOFF"
>
>
> On Fri, Aug 27, 2010 at 6:01 AM, Nathaniel Flath  
> <flat0103@gmail.com> wrote:
>> I was going to fix the issues described in the first reply - not
>> enough items in particular - and resubmit soon.  I got a bit
>> distracted by finals.  I'll see if I can figure out the export
>> problem, as well.
>>
>> Thanks,
>> Nathaniel Flath
>>
>> On Fri, Aug 27, 2010 at 5:44 AM, Jacob Mitchell
>> <jacob.d.mitchell@gmail.com> wrote:
>>>
>>>
>>> On Fri, Aug 27, 2010 at 6:53 AM, Bernt Hansen <bernt@norang.ca>  
>>> wrote:
>>>>
>>>> Carsten Dominik <carsten.dominik@gmail.com> writes:
>>>>
>>>>> On Jul 29, 2010, at 10:27 PM, Nathaniel Flath wrote:
>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> One thing that had been bugging me was the inability to have an
>>>>>> ordered list of the form:
>>>>>>
>>>>>> a.  Item 1
>>>>>> b.  Item 2
>>>>>> c.  Item 3
>>>>>>
>>>>>> The following patch enables this, with lists going from a-z and  
>>>>>> A-Z.
>>>>>> Let me know if there are any issues with it.
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am not really sure we need these.  They cause problems when  
>>>>> lists get
>>>>> really long - also you patch does not further than "z", after  
>>>>> that I
>>>>> get "{".
>>>>>
>>>>> Furthermore the export backends implement their own numbering
>>>>> rules anyway.  So it seems to me that we do not need this  
>>>>> addition.
>>>>>
>>>>> Any other votes here?
>>>>
>>>> I'm not currently missing this feature.  I think it definitely  
>>>> would
>>>> have to handle more entries if this was to be included in org-mode.
>>>
>>> I agree, that would be nice.
>>>
>>>>
>>>> Maybe going something like
>>>>
>>>>  a.
>>>>  b.
>>>>  ...
>>>>  z.
>>>>  aa.
>>>>  ab.
>>>>  ...
>>>>  az.
>>>>  ba.
>>>>  bb.
>>>>  ...
>>>>  zz.
>>>>  ... and if you really need more entries than that (unlikely) you  
>>>> can
>>>>  do
>>>>  aaa.
>>>>  aab.
>>>>  ...
>>>>  and just keep going indefinitely.
>>>
>>> As a practical matter we should consider whether it's worth making a
>>> non-terminating sequence that can be handled by the exporters.   
>>> LaTeX's
>>> enumerate package doesn't like going beyond (z):
>>>
>>> \documentclass[letterpaper]{article}
>>> \usepackage{enumerate}
>>>
>>> \begin{document}
>>> \begin{enumerate}[(z)]
>>> \item
>>> ...
>>> \end{document}
>>>
>>> The items beyond the 26th are mapped to "()".
>>>
>>> Of course there are going to be ways around these issues, but the  
>>> question
>>> is whether it's desirable enough to implement and maintain that.   
>>> Either way
>>> is fine with me--I'm new on the mailing list and haven't done any
>>> development for org-mode yet.
>>>
>>> -Jake
>>>>
>>>> -Bernt
>>>>
>>>> _______________________________________________
>>>> Emacs-orgmode mailing list
>>>> Please use `Reply All' to send replies to the list.
>>>> Emacs-orgmode@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>>
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>>
>>>
>>
> <ordered-list.patch>

- Carsten

  reply	other threads:[~2010-09-21 12:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29 20:27 [PATCH] Alphabetical ordered lists Nathaniel Flath
2010-07-29 21:07 ` Nick Dokos
2010-08-01 18:33   ` David Maus
2010-08-02  9:31 ` Nicolas Goaziou
2010-08-27  8:11 ` Carsten Dominik
2010-08-27 10:53   ` Bernt Hansen
2010-08-27 12:44     ` Jacob Mitchell
2010-08-27 13:01       ` Nathaniel Flath
2010-09-18  7:43         ` Nathaniel Flath
2010-09-21 12:48           ` Carsten Dominik [this message]
2010-09-21 16:46             ` Nicolas Goaziou
2010-09-26 17:36             ` Nicolas Goaziou
2010-09-26 22:16               ` Nathaniel Flath
2010-09-27  6:55                 ` Nicolas Goaziou
2010-09-28 16:12                   ` Carsten Dominik
2010-09-29 15:49                     ` Carsten Dominik
2010-09-29 16:50                       ` Nathaniel Flath
2010-09-29 17:46                       ` Nicolas Goaziou
2010-10-01  1:13                         ` Nathaniel Flath
2010-10-04  8:33                           ` Carsten Dominik
2010-10-04 17:18                             ` Nicolas Goaziou
2010-10-05  0:07                               ` Sebastian Rose
2010-10-05  0:21                                 ` Nathaniel Flath
2010-10-05  7:40                               ` Carsten Dominik
2010-10-21  4:44                                 ` Nathaniel Flath
2010-10-22  5:30                                   ` Nathaniel Flath
2010-10-22  8:13                                     ` Carsten Dominik
2010-10-23  1:04                                       ` Nathaniel Flath
2010-10-26  8:21                                     ` Nicolas Goaziou
2010-10-26  8:23                                       ` Carsten Dominik
2010-10-28  7:17                                         ` Nathaniel Flath
2010-11-11  7:16                                           ` Nathaniel Flath
2010-11-11  8:57                                             ` Nicolas Goaziou
2010-11-13 15:16                                             ` Nicolas Goaziou
2010-11-22  4:45                                               ` Nathaniel Flath
2010-11-22 13:37                                                 ` Bernt Hansen
2010-11-22 18:37                                                 ` Nicolas Goaziou
2010-11-27  4:39                                                   ` Nathaniel Flath
2010-12-11  2:41                                                     ` Nathaniel Flath
2010-12-20 18:25                                                       ` Nicolas Goaziou
2011-01-12 20:05                                                         ` Nathaniel Flath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=393C5110-E4D3-4B36-8F4E-4F94B5AA0F93@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=flat0103@gmail.com \
    --cc=jacob.d.mitchell@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).