Fix end of line function called on an hidden block

* lisp/org.el (org-end-of-line): On a hidden block make sure to
  delegate motion to `end-of-line' instead of `move-end-of-line' in
  order to stay on the current line.
* testing/lisp/test-org.el: Update test.
This commit is contained in:
Nicolas Goaziou 2012-11-05 00:57:56 +01:00
parent d22e732d7a
commit f48a8b7bf8
2 changed files with 34 additions and 32 deletions

View File

@ -21331,37 +21331,39 @@ tags on the first attempt, and only move to after the tags when
the cursor is already beyond the end of the headline." the cursor is already beyond the end of the headline."
(interactive "P") (interactive "P")
(let ((special (if (consp org-special-ctrl-a/e) (cdr org-special-ctrl-a/e) (let ((special (if (consp org-special-ctrl-a/e) (cdr org-special-ctrl-a/e)
org-special-ctrl-a/e)) org-special-ctrl-a/e)))
(type (org-element-type (if (or (not special) arg)
(save-excursion (beginning-of-line) (org-element-at-point))))) (call-interactively
(cond (if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line))
((or (not special) arg) (let* ((element (save-excursion (beginning-of-line)
(call-interactively (org-element-at-point)))
(if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line))) (type (org-element-type element)))
((memq type '(headline inlinetask)) (cond
(let ((pos (point))) ((memq type '(headline inlinetask))
(beginning-of-line 1) (let ((pos (point)))
(if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$")) (beginning-of-line 1)
(if (eq special t) (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$"))
(if (or (< pos (match-beginning 1)) (= pos (match-end 0))) (if (eq special t)
(goto-char (match-beginning 1)) (if (or (< pos (match-beginning 1)) (= pos (match-end 0)))
(goto-char (match-end 0))) (goto-char (match-beginning 1))
(if (or (< pos (match-end 0)) (goto-char (match-end 0)))
(not (eq this-command last-command))) (if (or (< pos (match-end 0))
(goto-char (match-end 0)) (not (eq this-command last-command)))
(goto-char (match-beginning 1)))) (goto-char (match-end 0))
(call-interactively (goto-char (match-beginning 1))))
(if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line))))) (call-interactively
((memq type (if (fboundp 'move-end-of-line) 'move-end-of-line
'(center-block comment-block drawer dynamic-block example-block 'end-of-line)))))
export-block item plain-list property-drawer ((memq type
quote-block special-block src-block verse-block)) '(center-block comment-block drawer dynamic-block example-block
;; Never move past the ellipsis. export-block item plain-list property-drawer
(or (eolp) (move-end-of-line 1)) quote-block special-block src-block verse-block))
(when (org-invisible-p2) (backward-char))) ;; If element is hidden, `move-end-of-line' would put point
(t ;; after it. Use `end-of-line' to stay on current line.
(call-interactively (call-interactively 'end-of-line))
(if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line)))) (t
(call-interactively
(if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line))))))
(org-no-warnings (and (featurep 'xemacs) (setq zmacs-region-stays t))))) (org-no-warnings (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
(define-key org-mode-map "\C-a" 'org-beginning-of-line) (define-key org-mode-map "\C-a" 'org-beginning-of-line)

View File

@ -453,7 +453,7 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER" (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
(progn (org-hide-block-toggle) (progn (org-hide-block-toggle)
(org-end-of-line) (org-end-of-line)
(eolp))))) (eobp)))))
(ert-deftest test-org/forward-element () (ert-deftest test-org/forward-element ()
"Test `org-forward-element' specifications." "Test `org-forward-element' specifications."