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: Jarmo Hurri
Subject: Re: Binding RET to org-return-and-maybe-indent
Date: Fri, 24 Jul 2020 07:26:17 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

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
  




reply via email to

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