Hello,

Leo Vivier <[email protected]> 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

Reply via email to