소스 검색

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.
Nicolas Goaziou 12 년 전
부모
커밋
f48a8b7bf8
2개의 변경된 파일34개의 추가작업 그리고 32개의 파일을 삭제
  1. 33 31
      lisp/org.el
  2. 1 1
      testing/lisp/test-org.el

+ 33 - 31
lisp/org.el

@@ -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))
-        (type (org-element-type
-               (save-excursion (beginning-of-line) (org-element-at-point)))))
-    (cond
-     ((or (not special) arg)
-      (call-interactively
-       (if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line)))
-     ((memq type '(headline inlinetask))
-      (let ((pos (point)))
-        (beginning-of-line 1)
-        (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$"))
-            (if (eq special t)
-                (if (or (< pos (match-beginning 1)) (= pos (match-end 0)))
-                    (goto-char (match-beginning 1))
-                  (goto-char (match-end 0)))
-              (if (or (< pos (match-end 0))
-                      (not (eq this-command last-command)))
-                  (goto-char (match-end 0))
-                (goto-char (match-beginning 1))))
-          (call-interactively
-           (if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line)))))
-     ((memq type
-            '(center-block comment-block drawer dynamic-block example-block
-                           export-block item plain-list property-drawer
-                           quote-block special-block src-block verse-block))
-      ;; Never move past the ellipsis.
-      (or (eolp) (move-end-of-line 1))
-      (when (org-invisible-p2) (backward-char)))
-     (t
-      (call-interactively
-       (if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line))))
+		   org-special-ctrl-a/e)))
+    (if (or (not special) arg)
+	(call-interactively
+	 (if (fboundp 'move-end-of-line) 'move-end-of-line 'end-of-line))
+      (let* ((element (save-excursion (beginning-of-line)
+				      (org-element-at-point)))
+	     (type (org-element-type element)))
+	(cond
+	 ((memq type '(headline inlinetask))
+	  (let ((pos (point)))
+	    (beginning-of-line 1)
+	    (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$"))
+		(if (eq special t)
+		    (if (or (< pos (match-beginning 1)) (= pos (match-end 0)))
+			(goto-char (match-beginning 1))
+		      (goto-char (match-end 0)))
+		  (if (or (< pos (match-end 0))
+			  (not (eq this-command last-command)))
+		      (goto-char (match-end 0))
+		    (goto-char (match-beginning 1))))
+	      (call-interactively
+	       (if (fboundp 'move-end-of-line) 'move-end-of-line
+		 'end-of-line)))))
+	 ((memq type
+		'(center-block comment-block drawer dynamic-block example-block
+			       export-block item plain-list property-drawer
+			       quote-block special-block src-block verse-block))
+	  ;; If element is hidden, `move-end-of-line' would put point
+	  ;; after it.  Use `end-of-line' to stay on current line.
+	  (call-interactively '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)

+ 1 - 1
testing/lisp/test-org.el

@@ -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."