all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

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.