Hello. Is there any downside to binding RET to org-return-and-maybe-indent? I want to remove RET indentation in org mode. For example # --------------------------------------------------------------- * Demo of indentation - when I press return at the end of the word THIS - I get indentation # --------------------------------------------------------------- However, if I call org-return-and-maybe-indent at the same point, I do not get indentation. But would changing the binding of RET cause issues elsewhere? I am running Org mode version 9.3.7 (release_9.3.7-694-g7069dc). Jarmo
Jarmo Hurri <jarmo.hurri@iki.fi> writes: > Is there any downside to binding RET to org-return-and-maybe-indent? > > I want to remove RET indentation in org mode. For example > > # --------------------------------------------------------------- > * Demo of indentation > - when I press return at the end of the word THIS > - I get indentation > # --------------------------------------------------------------- RET indentation is something that has been introduced recently on the master branch (which will become Org 9.4 soon). In Org 9.3, with your example, RET does not indent, while C-j does. As ORG-NEWS notes, if you want RET to stop indenting, you can disable electric-indent-mode in org-mode-hook: #+begin_src emacs-lisp (add-hook 'org-mode-hook (lambda () (electric-indent-mode -1))) #+end_src > However, if I call org-return-and-maybe-indent at the same point, I do > not get indentation. > > But would changing the binding of RET cause issues elsewhere? I can't think of any bad side-effect, but my imagination might be lacking. The only downside I can think of is that RET will become redundant with C-j.
Hello Kévin. Kévin Le Gouguec <kevin.legouguec@gmail.com> writes: > RET indentation is something that has been introduced recently on the > master branch (which will become Org 9.4 soon). In Org 9.3, with your > example, RET does not indent, while C-j does. I was wondering why this bothered me! Such a little thing can have a drastic effect on your workflow when it is repeated so many times. > As ORG-NEWS notes, if you want RET to stop indenting, you can disable > electric-indent-mode in org-mode-hook: Thanks, I now located this feature change description in ORG-NEWS. >> But would changing the binding of RET cause issues elsewhere? > > I can't think of any bad side-effect, but my imagination might be > lacking. The only downside I can think of is that RET will become > redundant with C-j. Now I have two options. I will start by disabling electric-indent-mode in org. If that causes weird side effects, then I will rebind RET. Thank you for your most complete answer. All the best, and stay safe. Jarmo
Hello again.
Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:
> As ORG-NEWS notes, if you want RET to stop indenting, you can disable
> electric-indent-mode in org-mode-hook:
>
> #+begin_src emacs-lisp
> (add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
> #+end_src
Unfortunately this has side effects: it changes at least the way
parentheses and indentation interact when opening a Babel source code
block. It might be a good idea to mention this in ORG-NEWS.
Next I will try to change the binding of RET.
All the best, and stay safe.
Jarmo
Jarmo Hurri <jarmo.hurri@iki.fi> writes:
>> #+begin_src emacs-lisp
>> (add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
>> #+end_src
>
> Unfortunately this has side effects: it changes at least the way
> parentheses and indentation interact when opening a Babel source code
> block. It might be a good idea to mention this in ORG-NEWS.
Could you give us a precise recipe? (Starting from emacs -Q and an
empty Org buffer)
I've fiddled a bit with source blocks just now and I'm noticing some
weirdness that I suspect might be due to electric-indent-mode
re-indenting the previous line when hitting RET (or C-j when disabling
electric-indent-mode), but nothing specific to parentheses.
Since I'm a bit pressed for time ATM it would help if you could give a
step-by-step explanation of what goes wrong.
Hi Kévin.
Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:
>>> #+begin_src emacs-lisp
>>> (add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
>>> #+end_src
>>
>> Unfortunately this has side effects: it changes at least the way
>> parentheses and indentation interact when opening a Babel source code
>> block. It might be a good idea to mention this in ORG-NEWS.
>
> Could you give us a precise recipe? (Starting from emacs -Q and an
> empty Org buffer)
>
> I've fiddled a bit with source blocks just now and I'm noticing some
> weirdness that I suspect might be due to electric-indent-mode
> re-indenting the previous line when hitting RET (or C-j when disabling
> electric-indent-mode), but nothing specific to parentheses.
At the minimum it changes the way parentheses indent automatically when
editing source code blocks. Below is a minimal demo, documented using
our favorite system.
All the best, and stay safe.
Jarmo
* Demo of the effect of disabling elint
1. Save this org into file =org-elint-disable.org=
2. Save the following elisp into =minimal-org.el=, replacing the
location of org mode with your path:
#+begin_src elisp
(add-to-list 'load-path (expand-file-name "~/src/org-mode/lisp"))
(add-to-list 'load-path (expand-file-name "~/src/org-mode/contrib/lisp" t))
(add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
#+end_src
3. Toggle the last line
#+begin_src elisp
(add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
#+end_src
in =minimal-org.el= to see the following effect:
1. Open this file with
#+begin_src sh
emacs -Q -l minimal-org.el org-elint-disable.org
#+end_src
2. Type C-c ' for (org-edit-special) in the source code block below,
and follow the instructions on the comment line.
#+begin_src java :exports none :classname Demo
class Demo
{
// 1st press RET at the end of this line, then type TAB and }
#+end_src
Jarmo Hurri <jarmo.hurri@iki.fi> writes:
> * Demo of the effect of disabling elint
> 1. Save this org into file =org-elint-disable.org=
> 2. Save the following elisp into =minimal-org.el=, replacing the
> location of org mode with your path:
>
> #+begin_src elisp
> (add-to-list 'load-path (expand-file-name "~/src/org-mode/lisp"))
> (add-to-list 'load-path (expand-file-name "~/src/org-mode/contrib/lisp" t))
> (add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
> #+end_src
>
> 3. Toggle the last line
>
> #+begin_src elisp
> (add-hook 'org-mode-hook (lambda () (electric-indent-mode -1)))
> #+end_src
>
> in =minimal-org.el= to see the following effect:
> 1. Open this file with
>
> #+begin_src sh
> emacs -Q -l minimal-org.el org-elint-disable.org
> #+end_src
>
> 2. Type C-c ' for (org-edit-special) in the source code block below,
> and follow the instructions on the comment line.
>
> #+begin_src java :exports none :classname Demo
> class Demo
> {
> // 1st press RET at the end of this line, then type TAB and }
> #+end_src
OK, here are my observations:
* Emacs 28, Org 9.3
- RET: indented
- TAB: nothing
- }: de-indents
* Emacs 28, Org master, electric-indent-mode on
- RET: indented
- TAB: nothing
- }: de-indents
* Emacs 28, Org master, electric-indent-mode off
- RET: not indented
- TAB: indents
- }: does not indent
I think this is just because disabling electric-indent-mode is the wrong
thing to do: it should be electric-indent-local-mode. The former
changes the default value of electric-indent-mode for *all buffers*,
whereas the intent is to only disable it in Org buffers; we don't want
to affect Org Src buffers…
If I replace (electric-indent-mode -1) with (electric-indent-local-mode
-1) in org-mode-hook, I get the behaviour we have with "Org 9.3" and
"Org master, electric-indent-mode on".
Can you tell me whether electric-indent-local-mode works better for you?
If it does, I'll followup with a patch to ORG-NEWS.
Greetings Kévin.
Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:
> If I replace (electric-indent-mode -1) with
> (electric-indent-local-mode -1) in org-mode-hook, I get the behaviour
> we have with "Org 9.3" and "Org master, electric-indent-mode on".
>
> Can you tell me whether electric-indent-local-mode works better for
> you? If it does, I'll followup with a patch to ORG-NEWS.
Seems to be working fine. Thank you very much.
All the best, and stay safe.
Jarmo
[-- Attachment #1: Type: text/plain, Size: 351 bytes --] Jarmo Hurri <jarmo.hurri@iki.fi> writes: > Kévin Le Gouguec <kevin.legouguec@gmail.com> writes: > >> Can you tell me whether electric-indent-local-mode works better for >> you? If it does, I'll followup with a patch to ORG-NEWS. > > Seems to be working fine. Thank you very much. Thanks for the confirmation. Here is a patch for ORG-NEWS, then: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Fix-recommendation-in-9.4-release-notes.patch --] [-- Type: text/x-patch, Size: 1139 bytes --] From e5ed2be19d7ada3a0b6dd16fc220c4414b2af4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com> Date: Mon, 27 Jul 2020 15:00:03 +0200 Subject: [PATCH] Fix recommendation in 9.4 release notes Cf. <https://orgmode.org/list/87pn8huuq2.fsf@iki.fi/t/#m4f86f6baf790e88ab905007757487a1f481cc579>. Reported-by: Jarmo Hurri <jarmo.hurri@iki.fi> * etc/ORG-NEWS (=RET= and =C-j= now obey ~electric-indent-mode~): Recommend disabling electric-indent-local-mode rather than electric-indent-mode, as the latter impacts all buffers rather than just the newly-created Org buffer. --- etc/ORG-NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index bc93f8e4f..1ac7486a7 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -253,7 +253,7 @@ To get the previous behaviour back, disable ~electric-indent-mode~ explicitly: #+begin_src emacs-lisp -(add-hook 'org-mode-hook (lambda () (electric-indent-mode -1))) +(add-hook 'org-mode-hook (lambda () (electric-indent-local-mode -1))) #+end_src *** New optional numeric argument for ~org-return~ -- 2.27.0
Kévin Le Gouguec writes:
> Jarmo Hurri <jarmo.hurri@iki.fi> writes:
>
>> Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:
>>
>>> Can you tell me whether electric-indent-local-mode works better for
>>> you? If it does, I'll followup with a patch to ORG-NEWS.
>>
>> Seems to be working fine. Thank you very much.
>
> Thanks for the confirmation.
>
> Here is a patch for ORG-NEWS, then:
Thanks, looks good to me. Applied (0fd9a6ad6).