From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Automatically indent text when return is hit in an org buffer. Date: Tue, 11 Dec 2007 11:43:42 +0100 Message-ID: <87ve75v7dt.fsf@bzg.ath.cx> References: <87abojxj9s.fsf@enki.rimspace.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J22ad-00036a-2X for emacs-orgmode@gnu.org; Tue, 11 Dec 2007 05:43:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J22aa-00033E-3e for emacs-orgmode@gnu.org; Tue, 11 Dec 2007 05:43:50 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J22aZ-00032t-Tc for emacs-orgmode@gnu.org; Tue, 11 Dec 2007 05:43:48 -0500 Received: from ug-out-1314.google.com ([66.249.92.173]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J22aZ-0003Tg-NL for emacs-orgmode@gnu.org; Tue, 11 Dec 2007 05:43:48 -0500 Received: by ug-out-1314.google.com with SMTP id a2so227471ugf.48 for ; Tue, 11 Dec 2007 02:43:46 -0800 (PST) In-Reply-To: <87abojxj9s.fsf@enki.rimspace.net> (Daniel Pittman's message of "Mon, 10 Dec 2007 15:31:43 +1100") 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: Daniel Pittman Cc: emacs-orgmode@gnu.org --=-=-= Hi Daniel, Daniel Pittman 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=org.el.patch 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 --=-=-= > 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 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--