emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding RET to org-return-and-maybe-indent


From: Kévin Le Gouguec
Subject: Re: Binding RET to org-return-and-maybe-indent
Date: Fri, 24 Jul 2020 18:59:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]