emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Fix org-meta-return for checkbox lists
@ 2018-06-14 15:30 Kaushal Modi
  2018-06-14 18:41 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2018-06-14 15:30 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1812 bytes --]

Hello,

Currently if you do M-RET in a checkbox list item, the next item does not
become a checkbox automatically. This patch fixes that.

I have been using this fix locally for few months. But never got to
submitting it as I need to yet write a test for it.

Does that patch look good (apart from missing tests). Should I format it
w.r.t to next? or master?

Thanks.


=====

From 8572f66a514289e2193f162f8c3c24818af00912 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Wed, 21 Mar 2018 11:41:51 -0400
Subject: [PATCH] Make `org-meta-return' do the right thing for checkbox
lists
 too

---
 lisp/org-list.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/org-list.el b/lisp/org-list.el
index 0d20c9df7..6839105df 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -2247,10 +2247,14 @@ item is invisible."
     (let* ((struct (save-excursion (goto-char itemp)
                        (org-list-struct)))
            (prevs (org-list-prevs-alist struct))
+           (list-type (org-list-get-list-type itemp struct prevs))
            ;; If we're in a description list, ask for the new term.
-           (desc (when (eq (org-list-get-list-type itemp struct prevs)
-                   'descriptive)
-               " :: ")))
+           (desc (when (eq list-type 'descriptive)
+               " :: "))
+           ;; Check if the current list item has a checkbox.
+           (checkbox (or checkbox
+                 (and (eq list-type 'unordered)
+                  (org-list-get-checkbox itemp struct)))))
       (setq struct (org-list-insert-item pos struct prevs checkbox desc))
       (org-list-write-struct struct (org-list-parents-alist struct))
       (when checkbox (org-update-checkbox-count-maybe))
-- 
2.17.0.rc0


-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 2484 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Fix org-meta-return for checkbox lists
  2018-06-14 15:30 Fix org-meta-return for checkbox lists Kaushal Modi
@ 2018-06-14 18:41 ` Nicolas Goaziou
  2018-06-15 13:53   ` Bernt Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2018-06-14 18:41 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Currently if you do M-RET in a checkbox list item, the next item does not
> become a checkbox automatically. This patch fixes that.
>
> I have been using this fix locally for few months. But never got to
> submitting it as I need to yet write a test for it.
>
> Does that patch look good (apart from missing tests). Should I format it
> w.r.t to next? or master?

IMO, there is nothing to fix. Inserting a checkbox in every item is not
mandatory.

Furthermore, currently, M-RET inserts a regular item and M-S-RET inserts
it with a checkbox. With your patch, both M-RET and M-S-RET do the same
thing, which is sub-optimal.

My vote is to keep the current behaviour.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix org-meta-return for checkbox lists
  2018-06-14 18:41 ` Nicolas Goaziou
@ 2018-06-15 13:53   ` Bernt Hansen
  2018-06-15 14:01     ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2018-06-15 13:53 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list, Kaushal Modi

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Kaushal Modi <kaushal.modi@gmail.com> writes:
>
>> Currently if you do M-RET in a checkbox list item, the next item does not
>> become a checkbox automatically. This patch fixes that.
>>
>> I have been using this fix locally for few months. But never got to
>> submitting it as I need to yet write a test for it.
>>
>> Does that patch look good (apart from missing tests). Should I format it
>> w.r.t to next? or master?
>
> IMO, there is nothing to fix. Inserting a checkbox in every item is not
> mandatory.
>
> Furthermore, currently, M-RET inserts a regular item and M-S-RET inserts
> it with a checkbox. With your patch, both M-RET and M-S-RET do the same
> thing, which is sub-optimal.
>
> My vote is to keep the current behaviour.

I agree.  I use lists with mixed checkboxes and no checkboxes and do not
want to enforce checkboxes on every list item.

Thanks,
Bernt

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix org-meta-return for checkbox lists
  2018-06-15 13:53   ` Bernt Hansen
@ 2018-06-15 14:01     ` Kaushal Modi
  2018-06-15 14:10       ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2018-06-15 14:01 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-org list, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

Hello Nicolas, Brent,

On Fri, Jun 15, 2018 at 9:53 AM Bernt Hansen <bernt@norang.ca> wrote:

> I agree.  I use lists with mixed checkboxes and no checkboxes and do not
> want to enforce checkboxes on every list item.
>

OK, I can understand if the behavior is kept as it is.

Is it that common to have mix of checkboxes and unordered lists items?

I would think that this behavior of org-meta-return is more consistent:

- If you are on a "* foo" line, M-RET creates "* " on the next line.
- If you are on a "1. foo" line, M-RET creates "2. " on the next line.
- If you are on a "- foo" line, M-RET creates "- " on the next line.
- *But* if you are on a "- [ ] foo" line, M-RET still creates "- " instead
of "- [ ] " on the next line?

Shouldn't M-RET and M-S-RET behavior be switched for checkbox lists?
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1485 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix org-meta-return for checkbox lists
  2018-06-15 14:01     ` Kaushal Modi
@ 2018-06-15 14:10       ` Nicolas Goaziou
  2018-06-15 14:19         ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2018-06-15 14:10 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Bernt Hansen, emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Is it that common to have mix of checkboxes and unordered lists items?

The problem is that your initial suggestion make it impossible, common
or not.

> I would think that this behavior of org-meta-return is more consistent:
>
> - If you are on a "* foo" line, M-RET creates "* " on the next line.
> - If you are on a "1. foo" line, M-RET creates "2. " on the next line.
> - If you are on a "- foo" line, M-RET creates "- " on the next line.
> - *But* if you are on a "- [ ] foo" line, M-RET still creates "- " instead
> of "- [ ] " on the next line?
>
> Shouldn't M-RET and M-S-RET behavior be switched for checkbox lists?

As it is, it is symmetric with M-RET and M-S-RET on headlines. E.g., in
the following document

  * TODO Stuff|

where "|" is point, M-RET results in

  * TODO Stuff
  * 

i.e., no TODO added. I find it straightforward.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix org-meta-return for checkbox lists
  2018-06-15 14:10       ` Nicolas Goaziou
@ 2018-06-15 14:19         ` Kaushal Modi
  0 siblings, 0 replies; 6+ messages in thread
From: Kaushal Modi @ 2018-06-15 14:19 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bernt Hansen, emacs-org list

[-- Attachment #1: Type: text/plain, Size: 616 bytes --]

On Fri, Jun 15, 2018 at 10:10 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

>
> The problem is that your initial suggestion make it impossible, common
> or not.
>

I agree. That was a mistake. I overlooked the case where one would want to
have mix of checkbox and unordered items.


> As it is, it is symmetric with M-RET and M-S-RET on headlines. E.g., in
> the following document
>
>   * TODO Stuff|
>
> where "|" is point, M-RET results in
>
>   * TODO Stuff
>   *
>
> i.e., no TODO added. I find it straightforward.
>

OK. So no one way is right :) So it makes sense to keep it as it is.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1196 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-15 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-14 15:30 Fix org-meta-return for checkbox lists Kaushal Modi
2018-06-14 18:41 ` Nicolas Goaziou
2018-06-15 13:53   ` Bernt Hansen
2018-06-15 14:01     ` Kaushal Modi
2018-06-15 14:10       ` Nicolas Goaziou
2018-06-15 14:19         ` Kaushal Modi

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).