Explorar el Código

Fix regression in tags alignment

* lisp/org.el (org--align-tags-here): Correctly preserve column.
* testing/lisp/test-org.el (test-org/tag-align): Add test.

The regression was introduced in
593058e4a6270f52fdede2b871a0ee6504944f13.

Reported-by: Bernt Hansen <bernt@norang.ca>
<http://lists.gnu.org/r/emacs-orgmode/2018-06/msg00245.html>
Nicolas Goaziou hace 6 años
padre
commit
62dd2cc829
Se han modificado 2 ficheros con 11 adiciones y 5 borrados
  1. 3 4
      lisp/org.el
  2. 8 1
      testing/lisp/test-org.el

+ 3 - 4
lisp/org.el

@@ -14266,7 +14266,8 @@ tags."
 	   (current
 	    (save-excursion (goto-char tags-start) (current-column)))
 	   (origin (point-marker))
-	   (column (current-column)))
+	   (column (current-column))
+	   (in-blank? (and (> origin blank-start) (<= origin tags-start))))
       (when (/= new current)
 	(delete-region blank-start tags-start)
 	(goto-char blank-start)
@@ -14274,9 +14275,7 @@ tags."
 	;; Try to move back to original position.  If point was in the
 	;; blanks before the tags, ORIGIN marker is of no use because
 	;; it now points to BLANK-START.  Use COLUMN instead.
-	(let ((in-blank? (and (> origin blank-start) (<= origin tags-start))))
-	  (if in-blank? (org-move-to-column column)
-	    (goto-char origin)))))))
+	(if in-blank? (org-move-to-column column) (goto-char origin))))))
 
 (defun org-set-tags-command (&optional arg)
   "Set the tags for the current visible entry.

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

@@ -6040,7 +6040,14 @@ Paragraph<point>"
 	    (let ((org-tags-column 0))
 	      (org-fix-tags-on-the-fly)
 	      (insert "x")
-	      (buffer-string))))))
+	      (buffer-string)))))
+  ;; Aligning tags preserve position.
+  (should
+   (= 6 (org-test-with-temp-text "* 345 <point> :tag:"
+	  (let ((org-tags-column 78)
+		(indent-tabs-mode nil))
+	    (org-fix-tags-on-the-fly))
+	  (current-column)))))
 
 (ert-deftest test-org/get-tags ()
   "Test `org-get-tags' specifications."