`org-open-line' ignores tables at the very beginning of the document
* lisp/org.el (org-open-line): Ignore tables at the very beginning of the document. * testing/lisp/test-org.el (test-org/open-line): New test.
This commit is contained in:
parent
a1f51c8655
commit
149b8046ac
|
@ -518,7 +518,10 @@ to force opening it in either Emacs or with system application.
|
|||
*** New defalias ~org-babel-execute:j~
|
||||
Allows J source blocks be indicated by letter j. Previously the
|
||||
indication letter was solely J.
|
||||
|
||||
*** ~org-open-line~ ignores tables at the very beginning of the buffer
|
||||
When ~org-special-ctrl-o~ is non-nil, it is impractical to create
|
||||
a blank line above a table at the beginning of the document. Now, as
|
||||
a special case, ~org-open-line~ behaves normally in this situation.
|
||||
* Version 8.3
|
||||
|
||||
** Incompatible changes
|
||||
|
|
14
lisp/org.el
14
lisp/org.el
|
@ -21291,15 +21291,13 @@ With argument, join this line to following line."
|
|||
|
||||
(defun org-open-line (n)
|
||||
"Insert a new row in tables, call `open-line' elsewhere.
|
||||
If `org-special-ctrl-o' is nil, just call `open-line' everywhere."
|
||||
If `org-special-ctrl-o' is nil, just call `open-line' everywhere.
|
||||
As a special case, when a document starts with a table, allow to
|
||||
call `open-line' on the very first character."
|
||||
(interactive "*p")
|
||||
(cond
|
||||
((not org-special-ctrl-o)
|
||||
(open-line n))
|
||||
((org-at-table-p)
|
||||
(org-table-insert-row))
|
||||
(t
|
||||
(open-line n))))
|
||||
(if (and org-special-ctrl-o (/= (point) 1) (org-at-table-p))
|
||||
(org-table-insert-row)
|
||||
(open-line n)))
|
||||
|
||||
(defun org-return (&optional indent)
|
||||
"Goto next table row or insert a newline.
|
||||
|
|
|
@ -2487,6 +2487,35 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
|
|||
(org-end-of-line)
|
||||
(eobp)))))
|
||||
|
||||
(ert-deftest test-org/open-line ()
|
||||
"Test `org-open-line' specifications."
|
||||
;; Call `open-line' outside of tables.
|
||||
(should
|
||||
(equal "\nText"
|
||||
(org-test-with-temp-text "Text"
|
||||
(org-open-line 1)
|
||||
(buffer-string))))
|
||||
;; At a table, create a row above.
|
||||
(should
|
||||
(equal "\n| |\n| a |"
|
||||
(org-test-with-temp-text "\n<point>| a |"
|
||||
(org-open-line 1)
|
||||
(buffer-string))))
|
||||
;; At the very first character of the buffer, also call `open-line'.
|
||||
(should
|
||||
(equal "\n| a |"
|
||||
(org-test-with-temp-text "| a |"
|
||||
(org-open-line 1)
|
||||
(buffer-string))))
|
||||
;; Narrowing does not count.
|
||||
(should
|
||||
(equal "Text\n| |\n| a |"
|
||||
(org-test-with-temp-text "Text\n<point>| a |"
|
||||
(narrow-to-region (point) (point-max))
|
||||
(org-open-line 1)
|
||||
(widen)
|
||||
(buffer-string)))))
|
||||
|
||||
(ert-deftest test-org/forward-sentence ()
|
||||
"Test `org-forward-sentence' specifications."
|
||||
;; At the end of a table cell, move to the end of the next one.
|
||||
|
|
Loading…
Reference in New Issue