8

I want org-mode to default to alt-enter when under bullets, so that for bullets I can just press enter to make a new bullet.

So for instance:

  • Banana
  • Apple
  • Kiwi [MOUSE CURSOR HERE]

When I press enter, I want the following behavior (which happens when I press M-enter):

  • Banana
  • Apple
  • Kiwi
  • [MOUSE CURSOR HERE]

Instead of:

  • Banana
  • Apple
  • Kiwi

[MOUSE CURSOR HERE]

That is the default for most other applications, but why not for org-mode?

This would greatly improve my workflow. But I don't know how! Thanks in advance.

  • 1
    Welcome to Emacs.SE! It would help if you could explain what you have tried to do so far (and what references you've looked up that have left you stuck). To start, have a look at the following description of Emacs key bindings, which will get you started with the concepts. – Dan Jul 12 '16 at 22:29
  • 1
    I think the former one is the default behavior in org-mode. Can you start your emacs with only org-mode loaded, and try it again? – Leu_Grady Jul 12 '16 at 22:48
  • How would you terminate a list? – SabreWolfy Aug 12 '16 at 11:48
  • 1
    Not the solution, but in my experience, getting using to M-RET is much more beneficial. M-RET would do the right thing when point is in (i) a list (ii) a heading (iii) an org table cell (iv)... By the time you start liking M-RET, you discover C-u M-RET, and you like it even more! :) – Kaushal Modi Oct 11 '16 at 15:20
3

You might give this version a try. It adds items and headings with regular return, and with double return on an empty entry terminates the list. It also modifies return in a table to add rows or terminate a table on an empty row. Its lightly tested ;)

(defun scimax/org-return ()
  "Add new list or headline "
  (interactive)
  (cond
   ((org-in-item-p)
    (if (org-element-property :contents-begin (org-element-context))
    (org-insert-heading)
      (beginning-of-line)
      (kill-line)
      (org-return)))
   ((org-at-heading-p)
    (if (not (string= "" (org-element-property :title (org-element-context))))
    (org-insert-heading)
      (beginning-of-line)
      (kill-line)
      (org-return)))
   ((org-at-table-p)
    (if (-any?
     (lambda (x) (not (string= "" x)))
     (nth
      (- (org-table-current-dline) 1)
      (org-table-to-lisp)))
    (org-return)
      ;; empty row
      (beginning-of-line)
      (kill-line)
      (org-return)))
   (t
    (org-return))))

(define-key org-mode-map (kbd "RET")
  'scimax/org-return)
3

The package org-autolist that does this has been available from MELPA for almost two years.

See https://github.com/calvinwyoung/org-autolist

  • org-autolist seems to work only with list items. not headings – iLemming Apr 14 '17 at 1:46
0

You can do it like this:

 (defun my/org-list-new-item ()
   (interactive)
   (if (org-in-item-p) (org-insert-heading) (org-return)))
 (define-key org-mode-map (kbd "RET") 'my/org-list-new-item)

But I really do not recommend to use it like this.

  • And it doesn't have msword like behaviour (double enter to clear empty list item and go to 'normal' text). Of course it could be done just add more elisp. – Maxim Kim Jul 13 '16 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.