emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
@ 2020-10-21 14:18 Gustavo Barros
  2021-05-01 16:02 ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Barros @ 2020-10-21 14:18 UTC (permalink / raw)
  To: emacs-orgmode

Hi All,

I just found a misbehaving of `org-insert-heading-respect-content': when 
it's called before the first heading in the buffer, it breaks the 
structure of that fist heading by inserting a new heading on the line 
the previous heading existed.

An ECM to reproduce the issue is:

- Start 'emacs -Q'

- Do an initial setup:
  #+begin_src emacs-lisp
  (add-to-list 'load-path "~/.emacs.d/elpa/org-plus-contrib-20201019")
  #+end_src

- Visit file =test.org= with contents:
  #+begin_src org
  ,#+title: Title


  ,* Foo
  #+end_src

- Place point between the title and the "Foo" heading, and call 
  `org-insert-heading-respect-content' with "C-RET".

- The result is:
  #+begin_src org
  ,#+title: Title


  ,* !* Foo
  #+end_src
  where "!" represents point position.

Which clearly does not "respect content" of the following heading.

Best regards,
Gustavo.


Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.20, cairo version 1.16.0)
 of 2020-08-11
Package: Org mode version 9.4 (9.4-19-gb1de0c-elpaplus @ 
/home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)

current state:
==============
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
 org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
 change-major-mode-hook org-show-all append local] 5]
		 #[0 "\300\301\302\303\304$\207"
		   [add-hook change-major-mode-hook 
		   org-babel-show-result-all append local] 5]
		 org-babel-result-hide-spec org-babel-hide-all-hashes 
		 org-eldoc-load)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 
 "\n\n(fn ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
 org-babel-header-arg-expand)
 org-agenda-loop-over-headlines-in-active-region nil
 org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" 
 . php) ("C" . c) ("C++" . c++)
		      ("asymptote" . asy) ("bash" . sh) ("beamer" 
		      . latex) ("calc" . fundamental) ("cpp" . c++)
		      ("ditaa" . artist) ("dot" . fundamental) ("elisp" 
		      . emacs-lisp) ("ocaml" . tuareg)
		      ("screen" . shell-script) ("shell" . sh) ("sqlite" 
		      . sql))
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees 
 org-cycle-hide-drawers org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate 
 org-babel-speed-command-activate)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-follow :complete 
 org-attach-complete-link)
		       ("id" :follow org-id-open) ("eww" :follow 
		       org-eww-open :store org-eww-store-link)
		       ("rmail" :follow org-rmail-open :store 
		       org-rmail-store-link)
		       ("mhe" :follow org-mhe-open :store 
		       org-mhe-store-link)
		       ("irc" :follow org-irc-visit :store 
		       org-irc-store-link :export org-irc-export)
		       ("info" :follow org-info-open :export 
		       org-info-export :store org-info-store-link)
		       ("gnus" :follow org-gnus-open :store 
		       org-gnus-store-link)
		       ("docview" :follow org-docview-open :export 
		       org-docview-export :store
			org-docview-store-link)
		       ("bibtex" :follow org-bibtex-open :store 
		       org-bibtex-store-link)
		       ("bbdb" :follow org-bbdb-open :export 
		       org-bbdb-export :complete org-bbdb-complete-link
			:store org-bbdb-store-link)
		       ("w3m" :store org-w3m-store-link) ("file+sys") 
		       ("file+emacs")
		       ("shell" :follow org-link--open-shell)
		       ("news" :follow
			#[514 "\301\300\302Q\"\207" ["news" browse-url 
                         ":"] 6 "\n\n(fn URL ARG)"])
		       ("mailto" :follow
			#[514 "\301\300\302Q\"\207" ["mailto" browse-url 
                         ":"] 6 "\n\n(fn URL ARG)"])
		       ("https" :follow
			#[514 "\301\300\302Q\"\207" ["https" browse-url 
                         ":"] 6 "\n\n(fn URL ARG)"])
		       ("http" :follow
			#[514 "\301\300\302Q\"\207" ["http" browse-url 
                         ":"] 6 "\n\n(fn URL ARG)"])
		       ("ftp" :follow
			#[514 "\301\300\302Q\"\207" ["ftp" browse-url 
                         ":"] 6 "\n\n(fn URL ARG)"])
		       ("help" :follow org-link--open-help) ("file" 
		       :complete org-link-complete-file)
		       ("elisp" :follow org-link--open-elisp) ("doi" 
		       :follow org-link--open-doi))
 org-link-elisp-confirm-function 'yes-or-no-p
 )


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

* Re: Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
  2020-10-21 14:18 Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)] Gustavo Barros
@ 2021-05-01 16:02 ` Bastien
  2021-05-02  3:07   ` Gustavo Barros
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2021-05-01 16:02 UTC (permalink / raw)
  To: Gustavo Barros; +Cc: emacs-orgmode

Hi Gustavo,

Gustavo Barros <gusbrs.2016@gmail.com> writes:

> I just found a misbehaving of `org-insert-heading-respect-content': when 
> it's called before the first heading in the buffer, it breaks the 
> structure of that fist heading by inserting a new heading on the line 
> the previous heading existed.

Fixed with commit fb3030188 in the maint branch, thanks a lot.

Please test it and report any problem you may encounter.

Thanks,

-- 
 Bastien


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

* Re: Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
  2021-05-01 16:02 ` Bastien
@ 2021-05-02  3:07   ` Gustavo Barros
  2021-05-02  6:54     ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Barros @ 2021-05-02  3:07 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

On Sat, 01 May 2021 at 13:02, Bastien <bzg@gnu.org> wrote:

> Hi Gustavo,
>
> Gustavo Barros <gusbrs.2016@gmail.com> writes:
>
>> I just found a misbehaving of `org-insert-heading-respect-content': 
>> when 
>> it's called before the first heading in the buffer, it breaks the 
>> structure of that fist heading by inserting a new heading on the line 
>> the previous heading existed.
>
> Fixed with commit fb3030188 in the maint branch, thanks a lot.
>
> Please test it and report any problem you may encounter.

Thank you very much.

I just tested the fix and, indeed, `org-insert-heading-respect-content' 
no longer breaks the structure of the first heading.  However, if I may 
add a nitpick, the value of `org-blank-before-new-entry' does not seem 
to be honored in this case.  For default values, a distance of one blank 
line is ensured to the next heading.  In the report's ECM, after the 
fix, the new heading is inserted immediately before it.  (I'm not sure 
it is really `org-blank-before-new-entry' which is at play here, but the 
behavior is not the same before the first heading than it is after it, 
with respect to blank lines).

Best,
Gustavo.


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

* Re: Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
  2021-05-02  3:07   ` Gustavo Barros
@ 2021-05-02  6:54     ` Bastien
  2021-05-02 17:11       ` Gustavo Barros
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2021-05-02  6:54 UTC (permalink / raw)
  To: Gustavo Barros; +Cc: emacs-orgmode

Hi Gustavo,

Gustavo Barros <gusbrs.2016@gmail.com> writes:

> I just tested the fix and, indeed,
> `org-insert-heading-respect-content' no longer breaks the structure of
> the first heading.  However, if I may add a nitpick, the value of
> `org-blank-before-new-entry' does not seem to be honored in this case.
> For default values, a distance of one blank line is ensured to the
> next heading.  

My understanding is that `org-blank-before-new-entry' will ensure
there is a blank line before the new entry, which is what I see.

Let me know if there is something I miss here.  Thanks!

-- 
 Bastien


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

* Re: Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
  2021-05-02  6:54     ` Bastien
@ 2021-05-02 17:11       ` Gustavo Barros
  2021-05-06 11:53         ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Barros @ 2021-05-02 17:11 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

On Sun, 02 May 2021 at 03:54, Bastien <bzg@gnu.org> wrote:

> Hi Gustavo,
>
> Gustavo Barros <gusbrs.2016@gmail.com> writes:
>
>> I just tested the fix and, indeed,
>> `org-insert-heading-respect-content' no longer breaks the structure 
>> of
>> the first heading.  However, if I may add a nitpick, the value of
>> `org-blank-before-new-entry' does not seem to be honored in this 
>> case.
>> For default values, a distance of one blank line is ensured to the
>> next heading.  
>
> My understanding is that `org-blank-before-new-entry' will ensure
> there is a blank line before the new entry, which is what I see.
>
> Let me know if there is something I miss here.  Thanks!

Indeed, that's why I said I'm not sure `org-blank-before-new-entry' is 
the culprit here.  Still, there is a difference of behavior in that 
regard if point is before or after the fist heading.  An ECM to 
reproduce it is the following.


From the situation ("|" represents point position), call `C-RET':

#+begin_src org
,#+title: Title

|
,* Foo

,* Bar

,* Baz
#+end_src

The result is:

#+begin_src org
,#+title: Title

,* |
,* Foo

,* Bar

,* Baz
#+end_src

Now move point to:

#+begin_src org
,#+title: Title

,*
,* Foo

,* Bar
|
,* Baz
#+end_src

And call `C-RET'.  The result is:

#+begin_src org
,#+title: Title

,*
,* Foo

,* Bar

,* |

,* Baz
#+end_src

Not quite sure what is the cause, and also not absolutely sure what 
would be expected behavior.  Since, if we now place point at:

#+begin_src org
,#+title: Title

,*
,* Foo
|
,* Bar

,*

,* Baz
#+end_src

And call `C-RET', we get:

#+begin_src org
,#+title: Title

,*
,* Foo
,* |

,* Bar

,*

,* Baz
#+end_src

My guess, and this is just a hunch, is that the default value of 
`org-blank-before-new-entry', which by default is `auto' for `heading' 
is somehow backward looking, and hence has somewhat of a hard time in 
making the said "intelligent decision" as to how many blank lines to 
include.  Particularly before the first heading.

Indeed, I can understand the last case in that perspective, since the 
first heading we inserted has no blank line to "Foo", so that when 
inserting a new heading between "Foo" and "Bar" if we look right above 
"no blank line" is the rule to infer.  And, if that first heading is 
removed, inserting a new one there, will behave just as it does between 
"Bar" and "Baz".

This was all tested with `emacs -Q', version 27.2, and Org commit 
3e497bec3.  No variables changed, thus out-of-the-box experience.

Anyway, as mentioned, "nitpick" level stuff, since you asked for 
testing.

Best regards,
Gustavo.


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

* Re: Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
  2021-05-02 17:11       ` Gustavo Barros
@ 2021-05-06 11:53         ` Bastien
  2021-05-06 12:15           ` Gustavo Barros
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2021-05-06 11:53 UTC (permalink / raw)
  To: Gustavo Barros; +Cc: emacs-orgmode

Hi Gustavo,

certainly a nitpick, but I think a good one.  I fixed this in the
maint branch, please let me know if you notice any weirdness.

Thanks again,

-- 
 Bastien


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

* Re: Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)]
  2021-05-06 11:53         ` Bastien
@ 2021-05-06 12:15           ` Gustavo Barros
  0 siblings, 0 replies; 7+ messages in thread
From: Gustavo Barros @ 2021-05-06 12:15 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

On Thu, 06 May 2021 at 08:53, Bastien <bzg@gnu.org> wrote:

> I fixed this in the
> maint branch, please let me know if you notice any weirdness.
>

It's looking good here now.

Thanks again.

Best,
Gustavo.


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

end of thread, other threads:[~2021-05-06 12:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-21 14:18 Bug: org-insert-heading-respect-content before first heading [9.4 (9.4-19-gb1de0c-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201019/)] Gustavo Barros
2021-05-01 16:02 ` Bastien
2021-05-02  3:07   ` Gustavo Barros
2021-05-02  6:54     ` Bastien
2021-05-02 17:11       ` Gustavo Barros
2021-05-06 11:53         ` Bastien
2021-05-06 12:15           ` Gustavo Barros

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