emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix org-capture-place-entry narrow bounds
@ 2020-05-30  0:25 Kevin Liu
  2020-05-30  0:26 ` Kevin Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Liu @ 2020-05-30  0:25 UTC (permalink / raw)
  To: emacs-orgmode

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

This is a patch to fix my previous report of a regression in capture
behavior between 9.3 and 9.3.6:

> Basically, the last position in the narrowed org-capture is actually
> the first position on the next line, so when you go to (end-of-buffer)
> and start typing you start clobbering the next headline.

The fix already landed in cb2774d1a is inadequate for me as the subtree
structure can still be broken during the capture process.  I think this
is the more correct approach, though I haven't done much testing outside
of my own workflow and `make test`.  It seems to be the same behavior as
9.3.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 1362 bytes --]

From e6f4faacd2db9ea3f5dc6d6582e0e58ee11c8bef Mon Sep 17 00:00:00 2001
From: nivekuil <mail@nivekuil.com>
Date: Fri, 29 May 2020 16:48:31 -0700
Subject: [PATCH] Fix org-capture-narrow

---
 lisp/org-capture.el | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9136d331b..4d2c3e8d4 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -728,16 +728,6 @@ captured item after finalizing."
 
   (run-hooks 'org-capture-prepare-finalize-hook)
 
-  ;; Fix missing final newline, as it may have been deleted by accident
-  (when (eq (org-capture-get :type 'local) 'entry)
-    (save-excursion
-      (goto-char (point-max))
-      (and (not (looking-at-p "^"))
-	   (org-with-wide-buffer
-	    (and (not (looking-at-p org-heading-regexp))
-		 (not (eobp))))
-	   (insert "\n"))))
-
   ;; Did we start the clock in this capture buffer?
   (when (and org-capture-clock-was-started
 	     org-clock-marker
@@ -1166,7 +1156,7 @@ may have been stored before."
 	(org-capture-empty-lines-after)
 	(unless (org-at-heading-p) (outline-next-heading))
 	(org-capture-mark-kill-region origin (point))
-	(org-capture-narrow beg (point))
+	(org-capture-narrow beg (if (eobp) (point) (1- (point))))
 	(org-capture--position-cursor beg (point))))))
 
 (defun org-capture-place-item ()
-- 
2.26.2


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

* Re: [PATCH] Fix org-capture-place-entry narrow bounds
  2020-05-30  0:25 [PATCH] Fix org-capture-place-entry narrow bounds Kevin Liu
@ 2020-05-30  0:26 ` Kevin Liu
  2020-06-13  8:48   ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Liu @ 2020-05-30  0:26 UTC (permalink / raw)
  To: emacs-orgmode

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

Sorry, corrected patch format:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-capture-Fix-org-capture-place-entry-narrow-bounds.patch --]
[-- Type: text/x-patch, Size: 1738 bytes --]

From 8e7b28054492424170f14f11297b416ef7575540 Mon Sep 17 00:00:00 2001
From: nivekuil <mail@nivekuil.com>
Date: Fri, 29 May 2020 16:48:31 -0700
Subject: [PATCH] capture: Fix org-capture-place-entry narrow bounds

* lisp/org-capture.el
(org-capture-place-entry):
Prevent breaking the following headline inside the capture buffer.
This should match the behavior from 9.3.
(org-capture-finalize):
Reverts cb2774d1a, which solves a similar problem but only in the
finalize stage, so the subtree structure would still be broken in the
middle of editing the capture.
---
 lisp/org-capture.el | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9136d331b..4d2c3e8d4 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -728,16 +728,6 @@ captured item after finalizing."
 
   (run-hooks 'org-capture-prepare-finalize-hook)
 
-  ;; Fix missing final newline, as it may have been deleted by accident
-  (when (eq (org-capture-get :type 'local) 'entry)
-    (save-excursion
-      (goto-char (point-max))
-      (and (not (looking-at-p "^"))
-	   (org-with-wide-buffer
-	    (and (not (looking-at-p org-heading-regexp))
-		 (not (eobp))))
-	   (insert "\n"))))
-
   ;; Did we start the clock in this capture buffer?
   (when (and org-capture-clock-was-started
 	     org-clock-marker
@@ -1166,7 +1156,7 @@ may have been stored before."
 	(org-capture-empty-lines-after)
 	(unless (org-at-heading-p) (outline-next-heading))
 	(org-capture-mark-kill-region origin (point))
-	(org-capture-narrow beg (point))
+	(org-capture-narrow beg (if (eobp) (point) (1- (point))))
 	(org-capture--position-cursor beg (point))))))
 
 (defun org-capture-place-item ()
-- 
2.26.2


[-- Attachment #3: Type: text/plain, Size: 2106 bytes --]



On 29 May 2020 17:25, Kevin Liu <kevin@nivekuil.com> wrote:

> This is a patch to fix my previous report of a regression in capture
> behavior between 9.3 and 9.3.6:
>
>> Basically, the last position in the narrowed org-capture is actually
>> the first position on the next line, so when you go to (end-of-buffer)
>> and start typing you start clobbering the next headline.
>
> The fix already landed in cb2774d1a is inadequate for me as the subtree
> structure can still be broken during the capture process.  I think this
> is the more correct approach, though I haven't done much testing outside
> of my own workflow and `make test`.  It seems to be the same behavior as
> 9.3.
>
> From e6f4faacd2db9ea3f5dc6d6582e0e58ee11c8bef Mon Sep 17 00:00:00 2001
> From: nivekuil <mail@nivekuil.com>
> Date: Fri, 29 May 2020 16:48:31 -0700
> Subject: [PATCH] Fix org-capture-narrow
>
> ---
>  lisp/org-capture.el | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index 9136d331b..4d2c3e8d4 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -728,16 +728,6 @@ captured item after finalizing."
>
>    (run-hooks 'org-capture-prepare-finalize-hook)
>
> -  ;; Fix missing final newline, as it may have been deleted by accident
> -  (when (eq (org-capture-get :type 'local) 'entry)
> -    (save-excursion
> -      (goto-char (point-max))
> -      (and (not (looking-at-p "^"))
> -	   (org-with-wide-buffer
> -	    (and (not (looking-at-p org-heading-regexp))
> -		 (not (eobp))))
> -	   (insert "\n"))))
> -
>    ;; Did we start the clock in this capture buffer?
>    (when (and org-capture-clock-was-started
>  	     org-clock-marker
> @@ -1166,7 +1156,7 @@ may have been stored before."
>  	(org-capture-empty-lines-after)
>  	(unless (org-at-heading-p) (outline-next-heading))
>  	(org-capture-mark-kill-region origin (point))
> -	(org-capture-narrow beg (point))
> +	(org-capture-narrow beg (if (eobp) (point) (1- (point))))
>  	(org-capture--position-cursor beg (point))))))
>
>  (defun org-capture-place-item ()


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

* Re: [PATCH] Fix org-capture-place-entry narrow bounds
  2020-05-30  0:26 ` Kevin Liu
@ 2020-06-13  8:48   ` Nicolas Goaziou
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Goaziou @ 2020-06-13  8:48 UTC (permalink / raw)
  To: Kevin Liu; +Cc: emacs-orgmode

Hello,

Kevin Liu <kevin@nivekuil.com> writes:

> From 8e7b28054492424170f14f11297b416ef7575540 Mon Sep 17 00:00:00 2001
> From: nivekuil <mail@nivekuil.com>
> Date: Fri, 29 May 2020 16:48:31 -0700
> Subject: [PATCH] capture: Fix org-capture-place-entry narrow bounds
>
> * lisp/org-capture.el
> (org-capture-place-entry):
> Prevent breaking the following headline inside the capture buffer.
> This should match the behavior from 9.3.
> (org-capture-finalize):
> Reverts cb2774d1a, which solves a similar problem but only in the
> finalize stage, so the subtree structure would still be broken in the
> middle of editing the capture.

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou


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

end of thread, other threads:[~2020-06-13  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30  0:25 [PATCH] Fix org-capture-place-entry narrow bounds Kevin Liu
2020-05-30  0:26 ` Kevin Liu
2020-06-13  8:48   ` 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).