emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jarmo Hurri <jarmo.hurri@iki.fi>
To: emacs-orgmode@gnu.org
Subject: Re: Binding RET to org-return-and-maybe-indent
Date: Fri, 24 Jul 2020 07:26:17 +0300	[thread overview]
Message-ID: <87pn8l5yja.fsf@iki.fi> (raw)
In-Reply-To: <878sfaxoly.fsf@gmail.com>


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	other threads:[~2020-07-24  4:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 12:12 Jarmo Hurri
2020-07-22 14:50 ` Kévin Le Gouguec
2020-07-23  5:55   ` Jarmo Hurri
2020-07-23  9:52   ` Jarmo Hurri
2020-07-23 15:00     ` Kévin Le Gouguec
2020-07-24  4:26       ` Jarmo Hurri [this message]
2020-07-24 16:59         ` Kévin Le Gouguec
2020-07-27 10:18           ` Jarmo Hurri
2020-07-27 13:12             ` [PATCH] Fix recommendation in ORG-NEWS (was: Binding RET to org-return-and-maybe-indent) Kévin Le Gouguec
2020-07-29  1:51               ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pn8l5yja.fsf@iki.fi \
    --to=jarmo.hurri@iki.fi \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Binding RET to org-return-and-maybe-indent' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this 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).