0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 21:07:54 +00:00

org-list: Modify M-RET on a description tag

* lisp/org-list.el (org-list-insert-item): On a description tag,
  insert item before current one.  However, past the colons, insert it
  after.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add
  tests.

Reported-by: Leo Ufimtsev <lufimtse@redhat.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/96330>
This commit is contained in:
Nicolas Goaziou 2015-03-23 23:35:57 +01:00
parent 830cf3e193
commit 5a550938ce
2 changed files with 49 additions and 7 deletions

View file

@ -1273,12 +1273,16 @@ This function modifies STRUCT."
(beforep
(progn
(looking-at org-list-full-item-re)
;; Do not count tag in a non-descriptive list.
(<= pos (if (and (match-beginning 4)
(save-match-data
(string-match "[.)]" (match-string 1))))
(match-beginning 4)
(match-end 0)))))
(<= pos
(cond
((not (match-beginning 4)) (match-end 0))
;; Ignore tag in a non-descriptive list.
((save-match-data (string-match "[.)]" (match-string 1)))
(match-beginning 4))
(t (save-excursion
(goto-char (match-end 4))
(skip-chars-forward " \t")
(point)))))))
(split-line-p (org-get-alist-option org-M-RET-may-split-line 'item))
(blank-nb (org-list-separating-blank-lines-number
pos struct prevs))

View file

@ -711,7 +711,45 @@
(goto-char (point-max))
(org-insert-item)
(forward-line -1)
(looking-at "$")))))
(looking-at "$"))))
;; When called before or on the bullet, insert new item before
;; current one.
(should
(equal "- \n- item"
(org-test-with-temp-text "- item"
(org-insert-item)
(buffer-string))))
(should
(equal "- \n- item"
(org-test-with-temp-text "- <point>item"
(org-insert-item)
(buffer-string))))
;; When called on tag in a descriptive list, insert new item before
;; current one too.
(should
(equal "- :: \n- tag :: item"
(org-test-with-temp-text "- tag <point>:: item"
(org-insert-item)
(buffer-string))))
(should
(equal "- :: \n- tag :: item"
(org-test-with-temp-text "- ta<point>g :: item"
(org-insert-item)
(buffer-string))))
;; Further, it splits the line or add a blank new item after it,
;; according to `org-M-RET-may-split-line'.
(should
(equal "- it\n- em"
(org-test-with-temp-text "- it<point>em"
(let ((org-M-RET-may-split-line '((default . t))))
(org-insert-item))
(buffer-string))))
(should
(equal "- item\n- "
(org-test-with-temp-text "- it<point>em"
(let ((org-M-RET-may-split-line '((default . nil))))
(org-insert-item))
(buffer-string)))))
(ert-deftest test-org-list/repair ()
"Test `org-list-repair' specifications."