[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH] org.el: Fix newline at eob in org-insert-heading
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [PATCH] org.el: Fix newline at eob in org-insert-heading |
Date: |
Sat, 16 Feb 2019 09:38:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hello,
Leo Vivier <address@hidden> writes:
> * lisp/org.el (org-insert-heading): Check if narrowed before inserting
> newline at eob
>
> When narrowed into an org-buffer (e.g. when capturing), adding a new
> heading with C-<return> or M-<return> on the last line of a
> buffer (i.e. that not without a newline at the end) would result in
> the insertion of a newline at the bottom of the narrowed capture
> buffer.
>
> - C-<return>: `org-insert-heading-respect-content'
> - M-<return>: `org-meta-return'
>
> Both functions use `org-insert-heading' in their definitions.
>
> The problem is due to `eobp' returning t when point is on the last
> character of the narrowed buffer (as explained in its docstring).
> Since those `eobp' predicates in `org-insert-heading' are probably
> there to ensure a newline at the end of the *file*, checking whether
> the buffer is *narrowed* (with `buffer-narrowed-p') prior to inserting
> the newline fixes the problem.
I don't think this would be a sufficient fix, because the buffer can be
narrowed and, yet, showing the end of the file.
Anyway, I don't think this final newline is needed. I removed it. This
should fix your issue. Please let me know if you encounter other
glitches in that area.
Regards,
--
Nicolas Goaziou