From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scot Becker Subject: Re: [ANN] List improvement v.2 Date: Tue, 27 Jul 2010 13:51:24 +0100 Message-ID: References: <87ocdzw7gq.wl%n.goaziou@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0801377556==" Return-path: Received: from [140.186.70.92] (port=41019 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Odjil-0004mh-3g for emacs-orgmode@gnu.org; Tue, 27 Jul 2010 08:57:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Odjii-0006uP-Pd for emacs-orgmode@gnu.org; Tue, 27 Jul 2010 08:57:22 -0400 Received: from mail-qy0-f169.google.com ([209.85.216.169]:36373) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Odjii-0006u9-Ie for emacs-orgmode@gnu.org; Tue, 27 Jul 2010 08:57:20 -0400 Received: by qyk9 with SMTP id 9so2938318qyk.0 for ; Tue, 27 Jul 2010 05:57:19 -0700 (PDT) In-Reply-To: <87ocdzw7gq.wl%n.goaziou@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Org Mode List --===============0801377556== Content-Type: multipart/alternative; boundary=0015175ce1bc8a6d9b048c5e0a49 --0015175ce1bc8a6d9b048c5e0a49 Content-Type: text/plain; charset=ISO-8859-1 Nicolas and list friends This sounds great. And it seems you've made it easy to try by putting in in git. Since my git usage consists almost exclusively of pulling from the org-mode repository, and I've never dealt with testing branches, would one of you be so kind as to feed me the commands necessary to try this out in the easiest way possible. I keep current on the org 'master' repo. Should I pull a separate repo, or make a branch on the one I have? Assuming I find no reason to undo the changes, and assuming they are merged into the core after some weeks, and assuming that I want keep current on the main org repository, will I need to do anything if and when these changes get added to the core if I'm already testing them on the branch? I'm sure all of this is blissfully easy (git seems so clever), but I'd be glad to have someone explain how to do it in the easiest way. Scot On Thu, Jul 22, 2010 at 10:08 PM, Nicolas Goaziou wrote: > Hello, > > Here is a new, and probably final feature-wise, suggestion of list > improvement in Org Mode. > > Table of Contents > ================= > 1 What is it about again ? > 2 Is that all ? > 2.1 Preserving blank lines > 2.2 Timer lists > 2.3 Automatic rules > 2.4 `org-apply-on-list' > 3 Where can it be tried ? > > > 1 What is it about again ? > ~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > I redefined lists in Org Mode. Lists start, as before, at a bullet > (whose true regexp is at `org-item-beginning-re'), and end at either > `org-list-end-regexp', a new headline, or, obviously, end of buffer. > > `org-list-end-regexp' is customizable and defaults to 2 blank lines, > but `org-empty-line-terminates-plain-lists' has precedence over it. > Moreover, any `org-list-end-regexp' found in special blocks does not > end list. Here are two examples of valid lists: > > Case 1: `org-list-end-regexp' is at default value > > > - First item > > - Sub item > > #+BEGIN_EXAMPLE > Two blank lines below > > > Two blank lines above > #+END_SRC > > - Last sub item > > > List has ended at the beginning of this line. > > Case 2: `org-list-end-regexp' is "^[ \t]*___[ \t]*\n" > > > - item 1 > - item 2 > - sub-item > - sub-item 2 > - item 3 > __ > List has ended at the beginning of this line. > > Now, Org Mode knows when a list has ended and how to indent line > accordingly. In other words, you can `org-return-indent' three times > to exit a list and be at the right column to go on with the text. > > This new definition is also understood by exporters (LaTeX, DocBook, > HTML or ASCII) and `org-list-end-regexp' will appear in source as a > blank line, whatever its value is (as long as it starts with a caret > and ends with a newline character, as specified in doc-string). > > Another advantage is that you can have two lists of different types > in a row like in the example below: > > > - item > - item > > > 1. item > 2. item > > In this example, you can move (or cycle, or indent) items in the > second list without worrying about changing the first one. > > 2 Is that all ? > ~~~~~~~~~~~~~~~~ > > Yes and no. I tried as much as possible to keep compatibility with > previous implementation. But, as I was at it, I made a number of > minor improvements I am now going to describe. > > 2.1 Preserving blank lines > =========================== > > `org-move-item-up' and `org-move-item-down' will not eat blank > lines anymore. You can move an item up and down and stay assured > list will keep its integrity. > > The same is true for `org-sort-list' that would previously collapse > the list being sorted. Sorting is now safe. > > `org-insert-item', when 'plain-list-item is set to 'auto in > `org-blank-before-new-entry' (the default, I think), will work hard > to guess the appropriate number of blank lines to insert before the > item to come. The function is also much more predictable (in > previous version, trying to insert an item with point on a blank > line between 2 items would create a new headline). > > 2.2 Timer lists > ================ > > There are three improvements in timer lists (C-c C-x -). > > 1. When a new item is created, it should be properly indented and > not sticked to column 0 anymore, > > 2. When an item is inserted in a pre-existing timer list, it will > take profit of what has been done to `org-insert-item', > > 3. `org-sort-list' can now sort timer lists with the t and T > commands. > > /Note/: in order to preserve lists integrity, Org Mode will send an > error if you try to insert a timer list inside a list of another > type. > > 2.3 Automatic rules > ==================== > > I've added sets of rules (applied by default) that can improve > lists experience. You can deactivate them individually by > customizing `org-list-automatic-rules'. > > Bullet rule: Some may have noticed that you couldn't obtain * > as a bullet when cycling a list at column 0 or Org > would have taken them for headings. > > I extended the idea. Now, * bullet will be changed > to - if you outdent it to column 0. This and the > fact that LaTeX exporter now recognizes such lists > as valid make *-lists very usable. > > In the same register, cycling items of a > description list will not offer 1. or 1), as > ordered and description lists are incompatible. > > Checkbox rule: It replaces `org-provide-checkbox-statistics' > which has become obsolete. > > Indent rule: This set prevents user from breaking his list by > inadvertence, when indenting or outdenting items > and sub-trees. Only moves that keep list integrity > are allowed. > > The main advantage of it is when you insert a new > item and immediately press one or more TAB, > positions offered will all be meaningful. Quick > and efficient. > > As a special case, moving the top item of the list > will move the whole list with it. > > Insert rule: As a consequence of the new definition of lists, > items cannot be inserted inside a special block in > the middle of a list. With this rule activated, > item will be insert right before that special > block. If not, Org will only throw an error. > > Renumber rule: It replaces `org-auto-renumber-ordered-lists' > which has become obsolete. > > I think those rules make a sane default behavior (except for the > indent rule, perhaps). And they are easy to disable if one think > they get too much in the way. > > 2.4 `org-apply-on-list' > ======================== > > It's not much, but I added that small function, inspired from > `apply-of-rectangle', that might be of some use. It basically > applies a function passed as argument to each item of the list > (with a possible return value for functional usage). > > As an illustration, here is a small function that walks through a > list (and its sublists, if any), checking every item with a blank > checkbox whose body is matched by REGEXP. It returns the number of > items checked. > > > (defun my-check-o-matic (regexp) > ;; Function we are going to apply. > (let ((search-and-check > (lambda (count) > (let* ((body-end (save-excursion > (org-end-of-item-text-before-children))) > ;; Take care of any sublist first > (count (if (not (org-item-has-children-p)) > count > (goto-char body-end) > (org-apply-on-list search-and-check count)))) > ;; Tests and checking if the formers are successful > (if (and (save-excursion (re-search-forward regexp body-end > t)) > (org-at-item-checkbox-p) > (equal (match-string 1) "[ ]")) > (progn (org-toggle-checkbox) (1+ count)) > count))))) > ;; Call of `org-apply-on-list': notice initial value of counter > (format "%d items checked"(org-apply-on-list search-and-check 0)))) > > 3 Where can it be tried ? > ~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The source is at: > > git@github.com:ngz/org-mode-lists.git branch: end-lists > > It is merged very frequently with git head, and I keep a clone of > Org Mode master branch at the same place. So, you can switch from > end-lists to master without too much hassle. It is very stable > anyway, so you do not need to be an adventurous type. > > Feedback, suggestions and comments are welcome. > > Regards, > > -- Nicolas > > > _______________________________________________ > 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 > --0015175ce1bc8a6d9b048c5e0a49 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Nicolas and list friends

This sounds great.=A0 And it seems you'= ve made it easy to try by putting in in git.=A0 Since my git usage consists= almost exclusively of pulling from the org-mode repository, and I've n= ever dealt with testing branches, would one of you be so kind as to feed me= the commands necessary to try this out in the=A0 easiest way possible.=A0 = I keep current on the org 'master' repo.

Should I pull a separate repo, or make a branch on the one I have?=A0 A= ssuming I find no reason to undo the changes, and assuming they are merged = into the core after some weeks, and assuming that I want keep current on th= e main org repository, will I need to do anything if and when these changes= get added to the core if I'm already testing them on the branch?=A0 I&= #39;m sure all of this is blissfully easy (git seems so clever), but I'= d be glad to have someone explain how to do it in the easiest way.

Scot


On Thu, Jul 22, 2010 at 10:0= 8 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
Hello,

Here is a new, and probably final feature-wise, suggestion of list
improvement in Org Mode.

Table of Contents
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
1 What is it about again ?
2 Is that all ?
=A0 =A02.1 Preserving blank lines
=A0 =A02.2 Timer lists
=A0 =A02.3 Automatic rules
=A0 =A02.4 `org-apply-on-list'
3 Where can it be tried ?


1 What is it about again ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~

=A0I redefined lists in Org Mode. Lists start, as before, at a bullet
=A0(whose true regexp is at `org-item-beginning-re'), and end at eithe= r
=A0`org-list-end-regexp', a new headline, or, obviously, end of buffer= .

=A0`org-list-end-regexp' is customizable and defaults to 2 blank lines= ,
=A0but `org-empty-line-terminates-plain-lists' has precedence over it.=
=A0Moreover, any `org-list-end-regexp' found in special blocks does no= t
=A0end list. Here are two examples of valid lists:

=A0Case 1: `org-list-end-regexp' is at default value


=A0- First item

=A0 =A0- Sub item

=A0 =A0 =A0#+BEGIN_EXAMPLE
=A0 =A0 =A0Two blank lines below


=A0 =A0 =A0Two blank lines above
=A0 =A0 =A0#+END_SRC

=A0 =A0- Last sub item


=A0List has ended at the beginning of this line.

=A0Case 2: `org-list-end-regexp' is "^[ \t]*___[ \t]*\n"


=A0- item 1
=A0- item 2
=A0 =A0- sub-item
=A0 =A0- sub-item 2
=A0- item 3
=A0__
=A0List has ended at the beginning of this line.

=A0Now, Org Mode knows when a list has ended and how to indent line
=A0accordingly. In other words, you can `org-return-indent' three time= s
=A0to exit a list and be at the right column to go on with the text.

=A0This new definition is also understood by exporters (LaTeX, DocBook, =A0HTML or ASCII) and `org-list-end-regexp' will appear in source as a=
=A0blank line, whatever its value is (as long as it starts with a caret =A0and ends with a newline character, as specified in doc-string).

=A0Another advantage is that you can have two lists of different types
=A0in a row like in the example below:


=A0- item
=A0- item


=A01. item
=A02. item

=A0In this example, you can move (or cycle, or indent) items in the
=A0second list without worrying about changing the first one.

2 Is that all ?
~~~~~~~~~~~~~~~~

=A0Yes and no. I tried as much as possible to keep compatibility with
=A0previous implementation. But, as I was at it, I made a number of
=A0minor improvements I am now going to describe.

2.1 Preserving blank lines
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

=A0 `org-move-item-up' and `org-move-item-down' will not eat blank=
=A0 lines anymore. You can move an item up and down and stay assured
=A0 list will keep its integrity.

=A0 The same is true for `org-sort-list' that would previously collaps= e
=A0 the list being sorted. Sorting is now safe.

=A0 `org-insert-item', when 'plain-list-item is set to 'auto i= n
=A0 `org-blank-before-new-entry' (the default, I think), will work har= d
=A0 to guess the appropriate number of blank lines to insert before the =A0 item to come. The function is also much more predictable (in
=A0 previous version, trying to insert an item with point on a blank
=A0 line between 2 items would create a new headline).

2.2 Timer lists
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

=A0 There are three improvements in timer lists (C-c C-x -).

=A0 1. When a new item is created, it should be properly indented and
=A0 =A0 =A0not sticked to column 0 anymore,

=A0 2. When an item is inserted in a pre-existing timer list, it will
=A0 =A0 =A0take profit of what has been done to `org-insert-item',

=A0 3. `org-sort-list' can now sort timer lists with the t and T
=A0 =A0 =A0commands.

=A0 /Note/: in order to preserve lists integrity, Org Mode will send an =A0 error if you try to insert a timer list inside a list of another
=A0 type.

2.3 Automatic rules
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

=A0 I've added sets of rules (applied by default) that can improve
=A0 lists experience. You can deactivate them individually by
=A0 customizing `org-list-automatic-rules'.

=A0 Bullet rule: Some may have noticed that you couldn't obtain *
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0as a bullet when cycling a list at = column 0 or Org
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0would have taken them for headings.=

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0I extended the idea. Now, * bullet = will be changed
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0to - if you outdent it to column 0.= This and the
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fact that LaTeX exporter now recogn= izes such lists
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0as valid make *-lists very usable.<= br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0In the same register, cycling items= of a
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0description list will not offer 1. = or 1), as
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ordered and description lists are i= ncompatible.

=A0 Checkbox rule: It replaces `org-provide-checkbox-statistics'
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0which has become obsolete.

=A0 Indent rule: This set prevents user from breaking his list by
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0inadvertence, when indenting or out= denting items
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0and sub-trees. Only moves that keep= list integrity
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0are allowed.

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0The main advantage of it is when yo= u insert a new
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0item and immediately press one or m= ore TAB,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0positions offered will all be meani= ngful. Quick
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0and efficient.

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0As a special case, moving the top i= tem of the list
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0will move the whole list with it.
=A0 Insert rule: As a consequence of the new definition of lists,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0items cannot be inserted inside a s= pecial block in
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0the middle of a list. With this rul= e activated,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0item will be insert right before th= at special
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0block. If not, Org will only throw = an error.

=A0 Renumber rule: It replaces `org-auto-renumber-ordered-lists'
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0which has become obsolete.

=A0 I think those rules make a sane default behavior (except for the
=A0 indent rule, perhaps). And they are easy to disable if one think
=A0 they get too much in the way.

2.4 `org-apply-on-list'
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=A0 It's not much, but I added that small function, inspired from
=A0 `apply-of-rectangle', that might be of some use. It basically
=A0 applies a function passed as argument to each item of the list
=A0 (with a possible return value for functional usage).

=A0 As an illustration, here is a small function that walks through a
=A0 list (and its sublists, if any), checking every item with a blank
=A0 checkbox whose body is matched by REGEXP. It returns the number of
=A0 items checked.


=A0(defun my-check-o-matic (regexp)
=A0 =A0;; Function we are going to apply.
=A0 =A0(let ((search-and-check
=A0 =A0 =A0 =A0 =A0 (lambda (count)
=A0 =A0 =A0 =A0 =A0 =A0 (let* ((body-end (save-excursion (org-end-of-item-= text-before-children)))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Take care of any sublist first =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(count (if (not (org-item-has-child= ren-p))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 count
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (goto-char body-en= d)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-apply-on-list= search-and-check count))))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Tests and checking if the formers are succe= ssful
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (and (save-excursion (re-search-forward re= gexp body-end t))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(org-at-item-checkbox-p) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(equal (match-string 1) &qu= ot;[ ]"))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (progn (org-toggle-checkbox) (1+ count= ))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 count)))))
=A0 =A0 =A0;; Call of `org-apply-on-list': notice initial value of cou= nter
=A0 =A0 =A0(format "%d items checked"(org-apply-on-list search-a= nd-check 0))))

3 Where can it be tried ?
~~~~~~~~~~~~~~~~~~~~~~~~~~

=A0The source is at:

=A0git@github.com:ngz/org-mode-lists.git =A0 branch: end-lists

=A0It is merged very frequently with git head, and I keep a clone of
=A0Org Mode master branch at the same place. So, you can switch from
=A0end-lists to master without too much hassle. It is very stable
=A0anyway, so you do not need to be an adventurous type.

=A0Feedback, suggestions and comments are welcome.

=A0Regards,

-- Nicolas


_______________________________________________
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

--0015175ce1bc8a6d9b048c5e0a49-- --===============0801377556== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============0801377556==--