Respect `org-auto-align-tags' in all the editing commands

* lisp/org-mobile.el (org-mobile-edit):
* lisp/org.el (org-insert-heading):
(org-edit-headline):
(org-priority):
(org-set-tags):
(org-entry-put):
(org-self-insert-command):
(org-delete-backward-char):
(org-delete-char):
(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
This commit is contained in:
Ihor Radchenko 2024-04-17 13:04:52 +03:00
parent 62356cb44b
commit aa71facf6d
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 24 additions and 11 deletions

View File

@ -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~

View File

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

View File

@ -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 "")
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
(end-of-line)
(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))
(org-align-tags)
(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 "] "))))
(org-align-tags))
(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)
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
((equal property "PRIORITY")
(org-priority (if (org-string-nw-p value) (string-to-char value) ?\s))
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
((equal property "SCHEDULED")
(forward-line)
(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
(org-fold-core-suppress-folding-fix
(self-insert-command N)
(org-fix-tags-on-the-fly))
(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."
(org-at-table-p))
(progn (forward-char -1) (org-delete-char 1))
(funcall-interactively #'backward-delete-char N)
(org-fix-tags-on-the-fly))))
(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)
(org-fix-tags-on-the-fly))
(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)