From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Pittman Subject: Automatically indent text when return is hit in an org buffer. Date: Mon, 10 Dec 2007 15:31:43 +1100 Message-ID: <87abojxj9s.fsf@enki.rimspace.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J1bX0-0002BT-MC for emacs-orgmode@gnu.org; Mon, 10 Dec 2007 00:50:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J1bWx-00028L-5h for emacs-orgmode@gnu.org; Mon, 10 Dec 2007 00:50:17 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J1bWw-000281-S1 for emacs-orgmode@gnu.org; Mon, 10 Dec 2007 00:50:14 -0500 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J1bWw-00035Q-Hp for emacs-orgmode@gnu.org; Mon, 10 Dec 2007 00:50:14 -0500 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1J1bWk-0003VD-41 for emacs-orgmode@gnu.org; Mon, 10 Dec 2007 05:50:02 +0000 Received: from 203-217-31-70.perm.iinet.net.au ([203.217.31.70]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Dec 2007 05:50:02 +0000 Received: from daniel by 203-217-31-70.perm.iinet.net.au with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Dec 2007 05:50:02 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 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 ()