From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: M-RET and C-RET Date: Sat, 03 Dec 2011 11:24:49 +0100 Message-ID: <87mxbaq7f2.fsf@gmail.com> References: <20111126195304.61776.qmail@rage.so36.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWmnl-0002yB-0O for emacs-orgmode@gnu.org; Sat, 03 Dec 2011 05:26:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWmnj-0004ab-JJ for emacs-orgmode@gnu.org; Sat, 03 Dec 2011 05:26:36 -0500 Received: from mail-bw0-f41.google.com ([209.85.214.41]:55315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWmnj-0004aU-DU for emacs-orgmode@gnu.org; Sat, 03 Dec 2011 05:26:35 -0500 Received: by bkbzt12 with SMTP id zt12so2360819bkb.0 for ; Sat, 03 Dec 2011 02:26:34 -0800 (PST) In-Reply-To: (Michael Brand's message of "Fri, 2 Dec 2011 17:13:22 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Michael Brand Cc: sindikat , Org Mode Hello, Michael Brand writes: > With > > #+begin_src org > ,*** abc > ,*** def > , - ghi > , - jkl > #+end_src > > M-RET on "j" inserts a line above but I expected it below. If I > want a line above I would move the point to "-" before doing M-RET > like I do on a heading where I move to the first "*" to get the insert > above. Point isn't on "j". It's either before or after it. In your case, point is before "j". And using M-RET on an item before its body start will result in creating an item before it. This is done so to avoid splitting counters or check-boxes. You shouldn't compare lists and headlines behaviour, they don't have the same constraints. > Changing to the behavior expected by me would make it possible to add > a new list item below the last one in a list (a very frequent task) Go to the end of the last item, and use M-RET. If it is really frequent, the following function will do what you want: #+begin_src emacs-lisp (defun org-insert-item-at-end (&optional arg) "Insert a new list item at the end of the current list. When optional argument ARG is non-nil, add a check-box to the item." (interactive "P") (let ((itemp (org-in-item-p))) (unless itemp (error "Not in an item")) (goto-char (org-in-item-p)) (let* ((struct (org-list-struct)) (prevs (org-list-prevs-alist struct))) ;; Move to the end of the last item in list, before any white ;; space, and insert item there. (goto-char (org-list-get-item-end (org-list-get-last-item itemp struct prevs) struct)) (skip-chars-backward " \r\t\n") ;; Repair list. (setq struct (org-list-insert-item (point) struct prevs arg)) (org-list-write-struct struct (org-list-parents-alist struct)) ;; Take care of check-boxes count, if needed. (when arg (org-update-checkbox-count-maybe)) ;; Position point at body's start. (looking-at org-list-full-item-re) (goto-char (match-end 0))))) #+end_src > I configured it to nil for headline and item only to be able to insert > a new list item below the current with M-RET where I am forced to be > on or at right of "k" which by default splits which I want only in > very rare cases. If you want to split lines only on very rare occasions, why is it a problem to set `org-M-RET-may-split-line' to nil? > And one should not be invited to avoid M-RET and edit lists with "-" > and TAB as illustrated in the thread "org-list-indent-offset only > works partially": http://thread.gmane.org/gmane.emacs.orgmode/47954 Which part of the thread are you referring to? I see no suggestion about avoiding usage of M-RET. Regards, -- Nicolas Goaziou