* Automatically indent text when return is hit in an org buffer.
@ 2007-12-10 4:31 Daniel Pittman
2007-12-11 10:43 ` Bastien
2007-12-17 8:25 ` Carsten Dominik
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Pittman @ 2007-12-10 4:31 UTC (permalink / raw)
To: emacs-orgmode
G'day. I am a fan of `newline-and-indent', and turn it on for most of
the modes I routinely use, since it is almost always what I want done.
org-mode rebinds the "return" key to `org-return', which acts
intelligently in the face of tables -- and calls `newline' hard-coded in
other cases.
I would like to preserve that intelligence, but also to use
`newline-and-indent', so generated this patch to implement my desired
behaviour.
By default this changes nothing: org behaves exactly the same way as it
did previously.
If this isn't the right approach I am happy to rework the patch to
better match the rest of the software.
Finally, while I believe that this is a trivial change and will not need
assignment papers anyway I can note two things:
* there are copyright assignments from me to the FSF on record already
for Emacs and constituents, so I don't know if I need a new
assignment.
* I am happy to disclaim this if necessary.
Regards,
Daniel
--
Daniel Pittman <daniel@cybersource.com.au> Phone: 03 9621 2377
Level 4, 10 Queen St, Melbourne Web: http://www.cyber.com.au
Cybersource: Australia's Leading Linux and Open Source Solutions Company
diff --git a/org/org.el b/org/org.el
--- a/org/org.el
+++ b/org/org.el
@@ -555,6 +555,13 @@ and a boolean flag as cdr."
:type '(list
(cons (const heading) (boolean))
(cons (const plain-list-item) (boolean))))
+
+(defcustom org-return-and-indent nil
+ "Should `org-return' automatically indent the next line?
+Non-nil means, automatically indent the inserted line by calling
+`newline-and-indent' rather than `newline' when return is hit."
+ :group 'org-edit-structure
+ :type 'boolean)
(defcustom org-insert-heading-hook nil
"Hook being run after inserting a new heading."
@@ -26288,12 +26295,13 @@ Calls `org-table-next-row' or `newline',
Calls `org-table-next-row' or `newline', depending on context.
See the individual commands for more information."
(interactive)
- (cond
- ((bobp) (newline))
- ((org-at-table-p)
- (org-table-justify-field-maybe)
- (call-interactively 'org-table-next-row))
- (t (newline))))
+ (let ((newline (if org-return-and-indent #'newline-and-indent #'newline)))
+ (cond
+ ((bobp) (funcall newline))
+ ((org-at-table-p)
+ (org-table-justify-field-maybe)
+ (call-interactively 'org-table-next-row))
+ (t (funcall newline)))))
(defun org-ctrl-c-minus ()
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Automatically indent text when return is hit in an org buffer.
2007-12-10 4:31 Automatically indent text when return is hit in an org buffer Daniel Pittman
@ 2007-12-11 10:43 ` Bastien
2007-12-11 11:17 ` Daniel Pittman
2007-12-17 8:25 ` Carsten Dominik
1 sibling, 1 reply; 5+ messages in thread
From: Bastien @ 2007-12-11 10:43 UTC (permalink / raw)
To: Daniel Pittman; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 771 bytes --]
Hi Daniel,
Daniel Pittman <daniel@rimspace.net> writes:
> G'day. I am a fan of `newline-and-indent', and turn it on for most of
> the modes I routinely use, since it is almost always what I want done.
>
> org-mode rebinds the "return" key to `org-return', which acts
> intelligently in the face of tables -- and calls `newline' hard-coded in
> other cases.
>
> I would like to preserve that intelligence, but also to use
> `newline-and-indent', so generated this patch to implement my desired
> behaviour.
I think having a new option is not the best solution. I would prefer to
preserve the distinction between the two commands (RET and C-j).
The patch below does this: define org-return-indent and bind it to C-j.
Whether you want to bind it to RET is up to you.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org.el.patch --]
[-- Type: text/x-diff, Size: 1671 bytes --]
diff -u /home/guerry/elisp/testing/org/ /home/guerry/elisp/testing/temp4/org.el
--- /home/guerry/elisp/testing/org/org.el 2007-12-10 19:35:09.000000000 +0100
+++ /home/guerry/elisp/testing/temp4/org.el 2007-12-11 01:33:04.000000000 +0100
@@ -25815,6 +25815,7 @@
(org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
(org-defkey org-mode-map "\C-c#" 'org-update-checkbox-count)
(org-defkey org-mode-map "\C-m" 'org-return)
+(org-defkey org-mode-map "\C-j" 'org-return-indent)
(org-defkey org-mode-map "\C-c?" 'org-table-field-info)
(org-defkey org-mode-map "\C-c " 'org-table-blank-field)
(org-defkey org-mode-map "\C-c+" 'org-table-sum)
@@ -26283,18 +26284,24 @@
(let ((org-note-abort t))
(funcall org-finish-function))))
-(defun org-return ()
+(defun org-return (&optional indent)
"Goto next table row or insert a newline.
Calls `org-table-next-row' or `newline', depending on context.
See the individual commands for more information."
(interactive)
(cond
- ((bobp) (newline))
+ ((bobp) (if indent (newline-and-indent) (newline)))
((org-at-table-p)
(org-table-justify-field-maybe)
(call-interactively 'org-table-next-row))
- (t (newline))))
+ (t (if indent (newline-and-indent) (newline)))))
+(defun org-return-indent ()
+ (interactive)
+ "Goto next table row or insert a newline and indent.
+Calls `org-table-next-row' or `newline-and-indent', depending on
+context. See the individual commands for more information."
+ (org-return t))
(defun org-ctrl-c-minus ()
"Insert separator line in table or modify bullet type in list.
Diff finished. Tue Dec 11 01:33:29 2007
[-- Attachment #3: Type: text/plain, Size: 278 bytes --]
> If this isn't the right approach I am happy to rework the patch to
> better match the rest of the software.
Thanks for pointing out this issue and for the patch! I don't know what
Carsten will do with this, but having two solutions is certainly good :)
Best,
--
Bastien
[-- Attachment #4: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Automatically indent text when return is hit in an org buffer.
2007-12-11 10:43 ` Bastien
@ 2007-12-11 11:17 ` Daniel Pittman
2007-12-17 8:30 ` Carsten Dominik
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Pittman @ 2007-12-11 11:17 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
Bastien <bzg@altern.org> writes:
> Daniel Pittman <daniel@rimspace.net> writes:
>
>> G'day. I am a fan of `newline-and-indent', and turn it on for most
>> of the modes I routinely use, since it is almost always what I want
>> done.
[...]
> I think having a new option is not the best solution. I would prefer
> to preserve the distinction between the two commands (RET and C-j).
>
> The patch below does this: define org-return-indent and bind it to
> C-j. Whether you want to bind it to RET is up to you.
Well, the approach seems perfectly reasonable to me, and I can achieve
the same result; I fully support your approach.
[...]
>> If this isn't the right approach I am happy to rework the patch to
>> better match the rest of the software.
>
> Thanks for pointing out this issue and for the patch! I don't know
> what Carsten will do with this, but having two solutions is certainly
> good :)
Mmm. I suspect that your approach is the better one; it is more in
keeping with the rest of Emacs, I think, and certainly achieves my goal.
Thanks,
Daniel
--
Daniel Pittman <daniel@cybersource.com.au> Phone: 03 9428 6922
1/130-132 Stawell St, Richmond Web: http://www.cyber.com.au
Cybersource: Australia's Leading Linux and Open Source Solutions Company
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Automatically indent text when return is hit in an org buffer.
2007-12-11 11:17 ` Daniel Pittman
@ 2007-12-17 8:30 ` Carsten Dominik
0 siblings, 0 replies; 5+ messages in thread
From: Carsten Dominik @ 2007-12-17 8:30 UTC (permalink / raw)
To: Daniel Pittman; +Cc: emacs-orgmode
I will take Bastien's patch, thanks to both of you.
- Carsten
On Dec 11, 2007 12:17 PM, Daniel Pittman <daniel@rimspace.net> wrote:
> Bastien <bzg@altern.org> writes:
> > Daniel Pittman <daniel@rimspace.net> writes:
> >
> >> G'day. I am a fan of `newline-and-indent', and turn it on for most
> >> of the modes I routinely use, since it is almost always what I want
> >> done.
>
> [...]
>
> > I think having a new option is not the best solution. I would prefer
> > to preserve the distinction between the two commands (RET and C-j).
> >
> > The patch below does this: define org-return-indent and bind it to
> > C-j. Whether you want to bind it to RET is up to you.
>
> Well, the approach seems perfectly reasonable to me, and I can achieve
> the same result; I fully support your approach.
>
> [...]
>
> >> If this isn't the right approach I am happy to rework the patch to
> >> better match the rest of the software.
> >
> > Thanks for pointing out this issue and for the patch! I don't know
> > what Carsten will do with this, but having two solutions is certainly
> > good :)
>
> Mmm. I suspect that your approach is the better one; it is more in
> keeping with the rest of Emacs, I think, and certainly achieves my goal.
>
> Thanks,
> Daniel
> --
> Daniel Pittman <daniel@cybersource.com.au> Phone: 03 9428 6922
> 1/130-132 Stawell St, Richmond Web: http://www.cyber.com.au
> Cybersource: Australia's Leading Linux and Open Source Solutions Company
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Automatically indent text when return is hit in an org buffer.
2007-12-10 4:31 Automatically indent text when return is hit in an org buffer Daniel Pittman
2007-12-11 10:43 ` Bastien
@ 2007-12-17 8:25 ` Carsten Dominik
1 sibling, 0 replies; 5+ messages in thread
From: Carsten Dominik @ 2007-12-17 8:25 UTC (permalink / raw)
To: Daniel Pittman; +Cc: emacs-orgmode
On Dec 10, 2007 5:31 AM, Daniel Pittman <daniel@rimspace.net> wrote:
> G'day. I am a fan of `newline-and-indent', and turn it on for most of
> the modes I routinely use, since it is almost always what I want done.
>
> org-mode rebinds the "return" key to `org-return', which acts
> intelligently in the face of tables -- and calls `newline' hard-coded in
> other cases.
>
> I would like to preserve that intelligence, but also to use
> `newline-and-indent', so generated this patch to implement my desired
> behaviour.
>
> By default this changes nothing: org behaves exactly the same way as it
> did previously.
>
>
> If this isn't the right approach I am happy to rework the patch to
> better match the rest of the software.
>
>
> Finally, while I believe that this is a trivial change and will not need
> assignment papers anyway I can note two things:
>
> * there are copyright assignments from me to the FSF on record already
> for Emacs and constituents, so I don't know if I need a new
> assignment.
If you have a past-and-future-changes assignment for Emacs, that
would be enough. Please mail me a PDF copy of the assignment for
my records. Thanks!
- Carsten
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-12-17 8:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-10 4:31 Automatically indent text when return is hit in an org buffer Daniel Pittman
2007-12-11 10:43 ` Bastien
2007-12-11 11:17 ` Daniel Pittman
2007-12-17 8:30 ` Carsten Dominik
2007-12-17 8:25 ` Carsten Dominik
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.