emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Use the same TODO keyword as the current heading
@ 2017-10-16 19:38 Allen Li
  2017-10-17  7:47 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Allen Li @ 2017-10-16 19:38 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

This makes org-insert-todo-heading-respect-content use the previous
heading of the same level instead of the previous heading regardless
of level.

Given:

   * TODO some task
   ** WAITING other task

The original code yields:

   * TODO some task
   ** WAITING other task
   * WAITING

This commit yields:

   * TODO some task
   ** WAITING other task
   * TODO

* lisp/org.el (org-insert-todo-heading): Use keyword of previous same
  level heading
---
 lisp/org.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d6cd77bf9..100fe9a58 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7947,8 +7947,7 @@ unchecked check box."
     (org-insert-heading (or (and (equal arg '(16)) '(16))
      force-heading))
     (save-excursion
-      (org-back-to-heading)
-      (outline-previous-heading)
+      (org-forward-heading-same-level -1)
       (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
     (let* ((new-mark-x
      (if (or (equal arg '(4))
-- 
2.15.0.rc0.271.g36b669edcc-goog

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

* Re: [PATCH] Use the same TODO keyword as the current heading
  2017-10-16 19:38 [PATCH] Use the same TODO keyword as the current heading Allen Li
@ 2017-10-17  7:47 ` Nicolas Goaziou
  2017-10-17 18:40   ` Allen Li
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-10-17  7:47 UTC (permalink / raw)
  To: Allen Li; +Cc: emacs-orgmode

Hello,

Allen Li <vianchielfaura@gmail.com> writes:

> This makes org-insert-todo-heading-respect-content use the previous
> heading of the same level instead of the previous heading regardless
> of level.
>
> Given:
>
>    * TODO some task
>    ** WAITING other task
>
> The original code yields:
>
>    * TODO some task
>    ** WAITING other task
>    * WAITING
>
> This commit yields:
>
>    * TODO some task
>    ** WAITING other task
>    * TODO
>
> * lisp/org.el (org-insert-todo-heading): Use keyword of previous same
>   level heading

Thank you. 

Would you mind adding a test in "test-org.el", to
`insert-todo-heading-respect-content' test?

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Use the same TODO keyword as the current heading
  2017-10-17  7:47 ` Nicolas Goaziou
@ 2017-10-17 18:40   ` Allen Li
  2017-10-18 20:49     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Allen Li @ 2017-10-17 18:40 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On Tue, Oct 17, 2017 at 12:47 AM, Nicolas Goaziou
<mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Allen Li <vianchielfaura@gmail.com> writes:
>
>> This makes org-insert-todo-heading-respect-content use the previous
>> heading of the same level instead of the previous heading regardless
>> of level.
>>
>> Given:
>>
>>    * TODO some task
>>    ** WAITING other task
>>
>> The original code yields:
>>
>>    * TODO some task
>>    ** WAITING other task
>>    * WAITING
>>
>> This commit yields:
>>
>>    * TODO some task
>>    ** WAITING other task
>>    * TODO
>>
>> * lisp/org.el (org-insert-todo-heading): Use keyword of previous same
>>   level heading
>
> Thank you.
>
> Would you mind adding a test in "test-org.el", to
> `insert-todo-heading-respect-content' test?
>
> Regards,
>
> --
> Nicolas Goaziou

Here's the new patch with tests

---
 lisp/org.el              | 3 +--
 testing/lisp/test-org.el | 7 +++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d6cd77bf9..100fe9a58 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7947,8 +7947,7 @@ unchecked check box."
     (org-insert-heading (or (and (equal arg '(16)) '(16))
      force-heading))
     (save-excursion
-      (org-back-to-heading)
-      (outline-previous-heading)
+      (org-forward-heading-same-level -1)
       (let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
     (let* ((new-mark-x
      (if (or (equal arg '(4))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 3bc8c7b23..1b9178426 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1415,6 +1415,13 @@
     "* TODO \n"
     (org-test-with-temp-text "* H\n- an item\n- another one"
       (search-forward "an ")
+      (org-insert-todo-heading-respect-content)
+      (buffer-substring-no-properties (line-beginning-position) (point-max)))))
+  ;; Use the same TODO keyword as current heading.
+  (should
+   (equal
+    "* TODO\n"
+    (org-test-with-temp-text "* TODO\n** WAITING\n"
       (org-insert-todo-heading-respect-content)
       (buffer-substring-no-properties (line-beginning-position)
(point-max))))))

-- 
2.15.0.rc0.271.g36b669edcc-goog

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

* Re: [PATCH] Use the same TODO keyword as the current heading
  2017-10-17 18:40   ` Allen Li
@ 2017-10-18 20:49     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-10-18 20:49 UTC (permalink / raw)
  To: Allen Li; +Cc: emacs-orgmode

Hello,

Allen Li <vianchielfaura@gmail.com> writes:

> Here's the new patch with tests

I added a commit message and applied it. Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

end of thread, other threads:[~2017-10-18 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-16 19:38 [PATCH] Use the same TODO keyword as the current heading Allen Li
2017-10-17  7:47 ` Nicolas Goaziou
2017-10-17 18:40   ` Allen Li
2017-10-18 20:49     ` Nicolas Goaziou

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