emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Michael Brand <michael.ch.brand@gmail.com>
Cc: sindikat <sindikat@mail36.net>, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: M-RET and C-RET
Date: Sat, 03 Dec 2011 11:24:49 +0100	[thread overview]
Message-ID: <87mxbaq7f2.fsf@gmail.com> (raw)
In-Reply-To: <CALn3zogYj2+U5FtkDeXQxoHByoyL76eb8AoSG_a_dLuqUAtXbA@mail.gmail.com> (Michael Brand's message of "Fri, 2 Dec 2011 17:13:22 +0100")

Hello,

Michael Brand <michael.ch.brand@gmail.com> 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

  reply	other threads:[~2011-12-03 10:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-26 19:53 M-RET and C-RET sindikat
2011-12-02 16:13 ` Michael Brand
2011-12-03 10:24   ` Nicolas Goaziou [this message]
2011-12-03 16:58     ` Michael Brand
2011-12-04 10:33       ` Nicolas Goaziou
2011-12-04 21:38         ` Michael Brand
2011-12-05 17:23   ` Greg Troxel
  -- strict thread matches above, loose matches on Subject: below --
2011-11-25 16:49 sindikat
2011-11-26  6:08 ` Tom Prince

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mxbaq7f2.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael.ch.brand@gmail.com \
    --cc=sindikat@mail36.net \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).