[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reconciling org-mode idiosyncrasies with Emacs core
From: |
Kévin Le Gouguec |
Subject: |
Re: Reconciling org-mode idiosyncrasies with Emacs core |
Date: |
Mon, 04 May 2020 12:45:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Nicolas,
I took a stab at making RET obey electric-indent-mode in org-mode. I've
got something working; I'd like to ask for a review before moving on to
Changelog and ORG-NEWS entries (and tackling C-j… and maybe writing a
few unit tests?).
Here's the patch, with some additional comments below:
org-return.patch
Description: Text Data
Nicolas Goaziou <address@hidden> writes:
> Kévin Le Gouguec <address@hidden> writes:
>
>> Do you think a patch that
>>
>> - tweaked org-return (bound to RET) to default its INDENT argument to
>> the current value of electric-indent-mode,
After taking an in-depth look at 'org-return' and 'newline', I decided
to "let the knife do the work" and simply keep calling 'newline', though
with additional arguments:
- INTERACTIVE is what makes 'newline' run 'post-self-insert-hook' (thus
triggering indentation through electric-indent-mode),
- ARG wasn't strictly necessary, but it seemed harmless to add it, and
it allows inserting multiple newlines, thus removing one more "Org
idiosyncrasy".
I felt that introducing org--newline made the code clearer, but I can
understand if it seems too trivial to keep. I took the liberty of using
this function in the "list item" case too, otherwise there's no way to
indent the trailing text.
> The change will not appear overnight in Org, i.e., not in Org stable's
> branch (Org 9.3.X), and it will be announced in ORG-NEWS.
I'll work on ORG-NEWS (plus Changelog entries, plus unit tests) as soon
as I'm confident that my approach is satisfactory.
(Out of curiosity, could it be argued that this is solving a "bug" in
org-mode and, as such, could be committed to Emacs core first, then
backported to the org-mode repository? I don't feel strongly either
way, I wouldn't want to make things more complicated for Org
maintainers.)
Now for C-j, in order to minimize breakage (for anyone calling
org-return-indent from Lisp code) and simplify disabling the new
behaviour (by simply turning off electric-indent-mode in Org), should we
bind C-j to a new function? E.g.:
(defun org-return-and-maybe-indent ()
(interactive)
(org-return (not electric-indent-mode)))
Thank you for your time.
- Re: Reconciling org-mode idiosyncrasies with Emacs core,
Kévin Le Gouguec <=
- Re: Reconciling org-mode idiosyncrasies with Emacs core, Nicolas Goaziou, 2020/05/04
- Re: Reconciling org-mode idiosyncrasies with Emacs core, Kévin Le Gouguec, 2020/05/04
- [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode (was: Reconciling org-mode idiosyncrasies with Emacs core), Kévin Le Gouguec, 2020/05/06
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Nicolas Goaziou, 2020/05/07
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Kévin Le Gouguec, 2020/05/07
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Nicolas Goaziou, 2020/05/07
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Kévin Le Gouguec, 2020/05/07
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Kévin Le Gouguec, 2020/05/07
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Nicolas Goaziou, 2020/05/07
- Re: [PATCH] Make RET and C-j obey `electric-indent-mode' in org-mode, Bastien, 2020/05/24