emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Change of behavior of org-meta-return in 9.6/DoomEmacs?
@ 2022-05-16 22:14 Guillaume MULLER
  2022-05-17 16:57 ` Kaushal Modi
  2022-05-18 18:31 ` Nick Dokos
  0 siblings, 2 replies; 4+ messages in thread
From: Guillaume MULLER @ 2022-05-16 22:14 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1491 bytes --]

Hi,

I've been using org-mode for a few years now. Thanks for the tool, I love it! What I love most is that it really feels like built FOR the user, as every default behavior is the right one!

I recently switched from Vanilla Emacs (org 9.5.3) to DoomEmacs (org 9.6), because I'm tired of managing my 2000+ config.org with half-backed results.

I noticed that hitting Meta-Return in org in Doom does not behave as in Vanilla Emacs. If I have (with <> being the cursor):

* outline 1
** outline 2
   + no<>te1
   + note2

In Vanilla Emacs, hitting M-Ret (i.e. calling org-meta-return) resulted in:

* outline 1
** outline 2
   + no
   + <>te1
   + note2

In Doom Emacs, it results in:
* outline 1
** outline 2
   + note1
   + note2
** <>

As I use "keycast" package, I can see that, in both cases:
- M-Ret is org-meta-return
- C-Ret is +org/insert-item-below
but in the case of DoomEmacs, both result in the same behavior.

I tried many combinations of C/M/Ret, but I cannot reproduce the behavior of Vanilla/9.5.3 in Doom/9.6 . The only way I found to reach the same result as Vanilla Emacs in Doom Emacs (i.e. creating a new entry based on the remaining of the line) is to cut & paste line splits and creating new items/outlines manually, which is very painful.

How can I check if it is a change in org 9.6 or in DoomEmacs?

How can I get back org-meta-return acting in Doom/9.6 as in Vanilla/9.5.3?

Thanks in advance for your help


Guillaume

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

* Re: Change of behavior of org-meta-return in 9.6/DoomEmacs?
  2022-05-16 22:14 Change of behavior of org-meta-return in 9.6/DoomEmacs? Guillaume MULLER
@ 2022-05-17 16:57 ` Kaushal Modi
  2022-05-20 20:50   ` Guillaume MULLER
  2022-05-18 18:31 ` Nick Dokos
  1 sibling, 1 reply; 4+ messages in thread
From: Kaushal Modi @ 2022-05-17 16:57 UTC (permalink / raw)
  To: Guillaume MULLER; +Cc: emacs-org list

On Tue, May 17, 2022 at 12:24 PM Guillaume MULLER
<guillaume.muller@alolise.org> wrote:
>
> I noticed that hitting Meta-Return in org in Doom does not behave as in Vanilla Emacs. If I have (with <> being the cursor):
>
> * outline 1
> ** outline 2
>    + no<>te1
>    + note2
>
> In Vanilla Emacs, hitting M-Ret (i.e. calling org-meta-return) resulted in:
>
> * outline 1
> ** outline 2
>    + no
>    + <>te1
>    + note2

I am seeing your Vanilla Emacs behavior on Emacs 28.1 with Org built
from main branch (Org mode version 9.5.3 (release_9.5.3-504-gcdbb1c)).

> As I use "keycast" package, I can see that, in both cases:
> - M-Ret is org-meta-return
> - C-Ret is +org/insert-item-below

The keycast package's modeline display might not show if that
org-meta-return has been advised to modify the behavior.

If you do C-h f org-meta-return, do you see something like "This
function has .. advice: .." towards the end of that *Help* buffer?

> How can I check if it is a change in org 9.6 or in DoomEmacs?

Try reverting your DoomEmacs version to an older version to see if
that fixes it.
Then try reverting to the Org stable version from GNU ELPA (version
9.5.3) and see if that fixes the issue.

Also, may be opening an issue on the DoomEmacs repo might help.

Good luck!


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

* Re: Change of behavior of org-meta-return in 9.6/DoomEmacs?
  2022-05-16 22:14 Change of behavior of org-meta-return in 9.6/DoomEmacs? Guillaume MULLER
  2022-05-17 16:57 ` Kaushal Modi
@ 2022-05-18 18:31 ` Nick Dokos
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Dokos @ 2022-05-18 18:31 UTC (permalink / raw)
  To: emacs-orgmode

Guillaume MULLER <guillaume.muller@alolise.org> writes:

> Hi,
>
> I noticed that hitting Meta-Return in org in Doom does not behave as
> in Vanilla Emacs. If I have (with <> being the cursor):
>
> * outline 1
> ** outline 2
>   + no<>te1
>   + note2
>
> In Vanilla Emacs, hitting M-Ret (i.e. calling org-meta-return) resulted in:
>
> * outline 1
> ** outline 2
>   + no
>   + <>te1
>   + note2
>
> In Doom Emacs, it results in:
> * outline 1
> ** outline 2
>   + note1
>   + note2
> ** <>
>

Compare the values of the variable `org-M-RET-may-split-line' in the
two cases: are they the same?

-- 
Nick




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

* Re: Change of behavior of org-meta-return in 9.6/DoomEmacs?
  2022-05-17 16:57 ` Kaushal Modi
@ 2022-05-20 20:50   ` Guillaume MULLER
  0 siblings, 0 replies; 4+ messages in thread
From: Guillaume MULLER @ 2022-05-20 20:50 UTC (permalink / raw)
  Cc: emacs-org list


[-- Attachment #1.1.1: Type: text/plain, Size: 1039 bytes --]

Hi again,

Thanks for your response.

> If you do C-h f org-meta-return, do you see something like "This
> function has .. advice: .." towards the end of that *Help* buffer?

After investigation, the bug is in org-insert-heading in org 9.6 (Latest Doom - upgraded today - uses exactly version: (9.6-??-971eb68)

The documentation says:
"If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
org-M-RET-may-split-line on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

Whatever the value(s) I put in org-M-RET-may-split-line , org-insert-heading *always* creates a new line with a empty heading/item and leaves anything that was on the initial heading/item in-place.

If someone can confirm this finding, I would be happy to create the corresponding bug report.

Have a nice day

-- 
Guillaume MULLER - PhD
DataScientist
Saint-Étienne

[-- Attachment #1.1.2: org-insert-heading.doom --]
[-- Type: text/plain, Size: 6362 bytes --]

org-insert-heading is an interactive and byte-compiled function
defined in org.el.

Signature
(org-insert-heading &optional ARG INVISIBLE-OK TOP)

Documentation
Insert a new heading or an item with the same depth at point.

If point is at the beginning of a heading, insert a new heading
or a new headline above the current one.  When at the beginning
of a regular line of text, turn it into a heading.

If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
org-M-RET-may-split-line on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

With a C-u prefix, set org-insert-heading-respect-content to
a non-nil value for the duration of the command.  This forces the
insertion of a heading after the current subtree, independently
on the location of point.

With a C-u C-u prefix, insert the heading at the end of the tree
above the current heading.  For example, if point is within a
2nd-level heading, then it will insert a 2nd-level heading at
the end of the 1st-level parent subtree.

When INVISIBLE-OK is set, stop at invisible headlines when going
back.  This is important for non-interactive uses of the
command.

When optional argument TOP is non-nil, insert a level 1 heading,
unconditionally.

Key Bindings
This command is not in any keymaps.

References
References in org.el:
(defun org-insert-heading-after-current ...)   1 reference
(defun org-insert-heading-respect-content ...) 1 reference
(defun org-insert-todo-heading ...)            1 reference
(defun org-insert-subheading ...)              1 reference
(defun org-meta-return ...)                    2 references

Find all references Functions used by org-insert-heading

Debugging
Enable edebug Enable tracing
Disassemble Forget

Source Code
;; Defined in ~/.emacs.doom.d/.local/straight/repos/org/lisp/org.el
(defun org-insert-heading (&optional arg invisible-ok top)
  "Insert a new heading or an item with the same depth at point.

If point is at the beginning of a heading, insert a new heading
or a new headline above the current one.  When at the beginning
of a regular line of text, turn it into a heading.

If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
`org-M-RET-may-split-line' on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

With a `\\[universal-argument]' prefix, set \
`org-insert-heading-respect-content' to
a non-nil value for the duration of the command.  This forces the
insertion of a heading after the current subtree, independently
on the location of point.

With a `\\[universal-argument] \\[universal-argument]' prefix, \
insert the heading at the end of the tree
above the current heading.  For example, if point is within a
2nd-level heading, then it will insert a 2nd-level heading at
the end of the 1st-level parent subtree.

When INVISIBLE-OK is set, stop at invisible headlines when going
back.  This is important for non-interactive uses of the
command.

When optional argument TOP is non-nil, insert a level 1 heading,
unconditionally."
  (interactive "P")
  (let* ((blank? (org--blank-before-heading-p (equal arg '(16))))
	 (level (org-current-level))
	 (stars (make-string (if (and level (not top)) level 1) ?*)))
    (cond
     ((or org-insert-heading-respect-content
	  (member arg '((4) (16)))
	  (and (not invisible-ok)
	       (invisible-p (max (1- (point)) (point-min)))))
      ;; Position point at the location of insertion.  Make sure we
      ;; end up on a visible headline if INVISIBLE-OK is nil.
      (org-with-limited-levels
       (if (not level) (outline-next-heading) ;before first headline
	 (org-back-to-heading invisible-ok)
	 (when (equal arg '(16)) (org-up-heading-safe))
	 (org-end-of-subtree)))
      (unless (bolp) (insert "\n"))
      (when (and blank? (save-excursion
                          (backward-char)
                          (org-before-first-heading-p)))
        (insert "\n")
        (backward-char))
      (when (and (not level) (not (eobp)) (not (bobp)))
        (when (org-at-heading-p) (insert "\n"))
        (backward-char))
      (unless (and blank? (org-previous-line-empty-p))
	(org-N-empty-lines-before-current (if blank? 1 0)))
      (insert stars " ")
      ;; When INVISIBLE-OK is non-nil, ensure newly created headline
      ;; is visible.
      (unless invisible-ok
	(pcase (get-char-property-and-overlay (point) 'invisible)
	  (`(outline . ,o)
	   (move-overlay o (overlay-start o) (line-end-position 0)))
	  (_ nil))))
     ;; At a headline...
     ((org-at-heading-p)
      (cond ((bolp)
	     (when blank? (save-excursion (insert "\n")))
	     (save-excursion (insert stars " \n"))
	     (unless (and blank? (org-previous-line-empty-p))
	       (org-N-empty-lines-before-current (if blank? 1 0)))
	     (end-of-line))
	    ((and (org-get-alist-option org-M-RET-may-split-line 'headline)
		  (org-match-line org-complex-heading-regexp)
		  (org-pos-in-match-range (point) 4))
	     ;; Grab the text that should moved to the new headline.
	     ;; Preserve tags.
	     (let ((split (delete-and-extract-region (point) (match-end 4))))
	       (if (looking-at "[ \t]*$") (replace-match "")
		 (org-align-tags))
	       (end-of-line)
	       (when blank? (insert "\n"))
	       (insert "\n" stars " ")
	       (when (org-string-nw-p split) (insert split))))
	    (t
	     (end-of-line)
	     (when blank? (insert "\n"))
	     (insert "\n" stars " "))))
     ;; On regular text, turn line into a headline or split, if
     ;; appropriate.
     ((bolp)
      (insert stars " ")
      (unless (and blank? (org-previous-line-empty-p))
        (org-N-empty-lines-before-current (if blank? 1 0))))
     (t
      (unless (org-get-alist-option org-M-RET-may-split-line 'headline)
        (end-of-line))
      (insert "\n" stars " ")
      (unless (and blank? (org-previous-line-empty-p))
        (org-N-empty-lines-before-current (if blank? 1 0))))))
  (run-hooks 'org-insert-heading-hook))

Symbol Properties
event-symbol-element-mask
  (org-insert-heading 0)
event-symbol-elements
  (org-insert-heading)
modifier-cache
  ((0 . org-insert-heading))

[-- Attachment #1.1.3: org-insert-heading.vanilla --]
[-- Type: text/plain, Size: 254 bytes --]

org-insert-heading-respect-content is an interactive compiled Lisp
function in ‘org.el’.

It is bound to <C-return>.

(org-insert-heading-respect-content &optional INVISIBLE-OK)

Insert heading with ‘org-insert-heading-respect-content’ set to t.

[-- Attachment #1.1.4: org-meta-ret.doom --]
[-- Type: text/plain, Size: 1394 bytes --]

org-meta-return is an interactive and byte-compiled function defined
in org.el.

Signature
(org-meta-return &optional ARG)

Documentation
Insert a new heading or wrap a region in a table.

Calls org-insert-heading, org-insert-item or
org-table-wrap-region, depending on context.  When called with
an argument, unconditionally call org-insert-heading.

Key Bindings
org-mode-map C-c C-x RET
org-mode-map C-c C-x m
org-mode-map M-RET

References
org-meta-return is unused in org.el.

Find all references Functions used by org-meta-return

Debugging
Enable edebug Enable tracing
Disassemble Forget

Source Code
;; Defined in ~/.emacs.doom.d/.local/straight/repos/org/lisp/org.el
(defun org-meta-return (&optional arg)
  "Insert a new heading or wrap a region in a table.
Calls `org-insert-heading', `org-insert-item' or
`org-table-wrap-region', depending on context.  When called with
an argument, unconditionally call `org-insert-heading'."
  (interactive "P")
  (org-check-before-invisible-edit 'insert)
  (or (run-hook-with-args-until-success 'org-metareturn-hook)
      (call-interactively (cond (arg #'org-insert-heading)
				((org-at-table-p) #'org-table-wrap-region)
				((org-in-item-p) #'org-insert-item)
				(t #'org-insert-heading)))))

Symbol Properties
event-symbol-element-mask
  (org-meta-return 0)
event-symbol-elements
  (org-meta-return)
modifier-cache
  ((0 . org-meta-return))

[-- Attachment #1.1.5: org-meta-ret.vanilla --]
[-- Type: text/plain, Size: 391 bytes --]

org-meta-return is an interactive compiled Lisp function in ‘org.el’.

It is bound to M-RET, C-c C-x RET, C-c C-x m.

(org-meta-return &optional ARG)

Insert a new heading or wrap a region in a table.
Calls ‘org-insert-heading’, ‘org-insert-item’ or
‘org-table-wrap-region’, depending on context.  When called with
an argument, unconditionally call ‘org-insert-heading’.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

end of thread, other threads:[~2022-05-21  6:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 22:14 Change of behavior of org-meta-return in 9.6/DoomEmacs? Guillaume MULLER
2022-05-17 16:57 ` Kaushal Modi
2022-05-20 20:50   ` Guillaume MULLER
2022-05-18 18:31 ` Nick Dokos

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