Browse Source

org.el: Two minor fixes

* lisp/org.el (org-set-tags-command): Fix point position after
setting tag at the beginning of a blank heading.
(org-kill-line): Prevent from throwing an error when killing
the headline while point is right after the * chars.
Bastien 5 years ago
parent
commit
450452de4b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      lisp/org.el

+ 5 - 2
lisp/org.el

@@ -11660,7 +11660,9 @@ in Lisp code use `org-set-tags' instead."
 				#'org-tags-completion-function
 				nil nil (org-make-tag-string current-tags)
 				'org-tags-history)))))))
-	  (org-set-tags tags)))))))
+	  (org-set-tags tags)))))
+    ;; `save-excursion' may not replace the point at the right position:
+    (when (looking-back "^\*+") (forward-char))))
 
 (defun org-align-tags (&optional all)
   "Align tags in current entry.
@@ -19792,7 +19794,8 @@ depending on context."
       (if (<= end (point))		;on tags part
 	  (kill-region (point) (line-end-position))
 	(kill-region (point) end)))
-    (org-align-tags))
+    ;; Only align tags when we are still on a heading:
+    (if (org-at-heading-p) (org-align-tags)))
    (t (kill-region (point) (line-end-position)))))
 
 (defun org-yank (&optional arg)