From: Bastien <bzg@altern.org>
To: Daniel Pittman <daniel@rimspace.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Automatically indent text when return is hit in an org buffer.
Date: Tue, 11 Dec 2007 11:43:42 +0100 [thread overview]
Message-ID: <87ve75v7dt.fsf@bzg.ath.cx> (raw)
In-Reply-To: <87abojxj9s.fsf@enki.rimspace.net> (Daniel Pittman's message of "Mon, 10 Dec 2007 15:31:43 +1100")
[-- 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
next prev parent reply other threads:[~2007-12-11 10:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-10 4:31 Automatically indent text when return is hit in an org buffer Daniel Pittman
2007-12-11 10:43 ` Bastien [this message]
2007-12-11 11:17 ` Daniel Pittman
2007-12-17 8:30 ` Carsten Dominik
2007-12-17 8:25 ` Carsten Dominik
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ve75v7dt.fsf@bzg.ath.cx \
--to=bzg@altern.org \
--cc=daniel@rimspace.net \
--cc=emacs-orgmode@gnu.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.