aa71facf6d9eb30380d1a579e4cc4748252f0c39 — Ihor Radchenko a month ago 62356cb
Respect `org-auto-align-tags' in all the editing commands

* lisp/org-mobile.el (org-mobile-edit):
* lisp/org.el (org-insert-heading):
(org-kill-line): Only re-align tags when `org-auto-align-tags' is set
to non-nil.
* etc/ORG-NEWS (~org-auto-align-tags~ is now respected universally):
Announce the breaking change.

Link: https://orgmode.org/list/87msxoc3qp.fsf@localhost
3 files changed, 24 insertions(+), 11 deletions(-)

M lisp/org-mobile.el
M lisp/org.el
M etc/ORG-NEWS => etc/ORG-NEWS +13 -0
@@ 13,6 13,19 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.

* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** ~org-auto-align-tags~ is now respected universally

Previously, only a subset of Org editing commands respected
~org-auto-align-tags~ option.  Now, it is no longer the case.  All the
editing commands, including typing (~org-self-insert-command~) and
deletion respect the option.

~org-auto-align-tags~ is still enabled by default.  For users who
customized ~org-auto-align-tags~ to nil, ~org-edit-headline~,
~org-priority~, ~org-set-tags~, ~org-entry-put~, ~org-kill-line~, and
typing/deleting in headlines will no longer unconditionally auto-align
the tags.

*** ~org-create-file-search-functions~ can use ~org-list-store-props~ to suggest link description

In Org <9.0, ~org-create-file-search-functions~ could set ~description~

M lisp/org-mobile.el => lisp/org-mobile.el +1 -1
@@ 1057,7 1057,7 @@ be returned that indicates what went wrong."
	      (goto-char (match-beginning 4))
	      (insert new)
	      (delete-region (point) (+ (point) (length current)))
	      (when org-auto-align-tags (org-align-tags)))
	       "Heading changed in the mobile device and on the computer")))))))

M lisp/org.el => lisp/org.el +10 -10
@@ 6487,7 6487,7 @@ Assume that point is on the inserted heading."
	     ;; Preserve tags.
	     (let ((split (delete-and-extract-region (point) (match-end 4))))
	       (if (looking-at "[ \t]*$") (replace-match "")
		 (when org-auto-align-tags (org-align-tags)))
	       (when blank? (insert "\n"))
	       (insert "\n" stars " ")

@@ 6607,7 6607,7 @@ Set it to HEADING when provided."
	   (if old (replace-match new t t nil 4)
	     (goto-char (or (match-end 3) (match-end 2) (match-end 1)))
	     (insert " " new))
	   (when org-auto-align-tags (org-align-tags))
	   (when (looking-at "[ \t]*$") (replace-match ""))))))))

(defun org-insert-heading-after-current ()

@@ 11159,7 11159,7 @@ or a character."
		  (insert " [#" news "]"))
	      (goto-char (match-beginning 3))
	      (insert "[#" news "] "))))
	(when org-auto-align-tags (org-align-tags)))
      (if remove
	  (message "Priority removed")
	(message "Priority of current item set to %s" news)))))

@@ 11954,7 11954,7 @@ This function assumes point is on a headline."
	   (unless (org-invisible-p (line-beginning-position))
	     (org-fold-region (point) (line-end-position) nil 'outline))))
       ;; Align tags, if any.
       (when tags (org-align-tags))
       (when (and tags org-auto-align-tags) (org-align-tags))
       (when tags-change? (run-hooks 'org-after-tags-change-hook))))))

(defun org-change-tag-in-region (beg end tag off)

@@ 13194,10 13194,10 @@ decreases scheduled or deadline date by one day."
	       ((not (member value org-todo-keywords-1))
	        (user-error "\"%s\" is not a valid TODO state" value)))
	 (org-todo value)
	 (when org-auto-align-tags (org-align-tags)))
        ((equal property "PRIORITY")
	 (org-priority (if (org-string-nw-p value) (string-to-char value) ?\s))
	 (when org-auto-align-tags (org-align-tags)))
        ((equal property "SCHEDULED")
	 (if (and (looking-at-p org-planning-line-re)

@@ 17057,7 17057,7 @@ overwritten, and the table is not marked as requiring realignment."
    ;; Interactively, point should never be inside invisible regions
      (self-insert-command N)
      (when org-auto-align-tags (org-fix-tags-on-the-fly)))
    (when org-self-insert-cluster-for-undo
      (if (not (eq last-command 'org-self-insert-command))
	  (setq org-self-insert-command-undo-counter 1)

@@ 17087,7 17087,7 @@ because, in this case the deletion might narrow the column."
	(progn (forward-char -1) (org-delete-char 1))
      (funcall-interactively #'backward-delete-char N)
      (when org-auto-align-tags (org-fix-tags-on-the-fly)))))

(defun org-delete-char (N)
  "Like `delete-char', but insert whitespace at field end in tables.

@@ 17103,7 17103,7 @@ because, in this case the deletion might narrow the column."
	  (save-excursion (skip-chars-backward " \t") (bolp))
	  (not (org-at-table-p)))
      (delete-char N)
      (when org-auto-align-tags (org-fix-tags-on-the-fly)))
     ((looking-at ".\\(.*?\\)|")
      (let* ((update? org-table-may-need-update)
	     (noalign (looking-at-p ".*?  |")))

@@ 21146,7 21146,7 @@ see)."
	  (kill-region (point) (line-end-position))
	(kill-region (point) end)))
    ;; Only align tags when we are still on a heading:
    (if (org-at-heading-p) (org-align-tags)))
    (if (and (org-at-heading-p) org-auto-align-tags) (org-align-tags)))
   (t (kill-region (point) (line-end-position)))))

(defun org-yank (&optional arg)