emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [POLL] Should we enable or disable automatic tag alignment by default everywhere
@ 2024-04-17 10:21 Ihor Radchenko
  2024-04-17 10:40 ` Gautier Ponsinet
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-04-17 10:21 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Max Nikulin

[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]

Dear all,

We have ~org-auto-align-tags~ option that controls whether editing
commands re-align the tags.  However, this option is only respected by
some editing commands, like changing the headline level.  Many other
editing commands re-align tags unconditionally.  For example, when

* typing right here or deleting inside a heading with       :tag1:tag2:

the :tag1:tag2: automatically remains aligned, regardless of the value
of ~org-auto-align-tags~.

In the attached patch, I am changing all the commands in Org mode,
including "self-insert" and "delete-backwards" to respect this option.

However, because ~org-auto-align-tags~ is disabled by default, this will
cause breaking change - there are many more commands in Org mode that
re-align tags unconditionally compared to the commands that do take it
into account.

I'd like to ask you, Org mode users, whether we should flip the default
value of ~org-auto-align-tags~ to t or leave it as nil - flipping the
default value will preserve the behavior described above, but change the
default behavior of ~org-promote~, ~org-demote~, ~org-todo~,
~org-delete-indentation~, and ~org-return~.  Keeping the value nil, will
change the default behavior when typing/deleting inside headline, in
~org-mobile-edit~, ~org-insert-heading~, ~org-edit-headline~,
~org-priority~, ~org-entry-put~, ~org-kill-line~.

Or maybe should we keep the status quo with ~org-auto-align-tags~
sometimes respected and sometimes not?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Respect-org-auto-align-tags-in-all-the-editing-comma.patch --]
[-- Type: text/x-patch, Size: 6153 bytes --]

From 6f16612796076077c95176be0929677ffe8e0d3d Mon Sep 17 00:00:00 2001
Message-ID: <6f16612796076077c95176be0929677ffe8e0d3d.1713348551.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 17 Apr 2024 13:04:52 +0300
Subject: [PATCH] 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 not respected universally):
Announce the breaking change.

Link: https://orgmode.org/list/87msxoc3qp.fsf@localhost
---
 etc/ORG-NEWS       | 10 ++++++++++
 lisp/org-mobile.el |  2 +-
 lisp/org.el        | 20 ++++++++++----------
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e61bd6988..e6dc35f87 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,16 @@ 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 not 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 disabled by default.  Now, none of the
+Org editing commands re-align tags to ~org-tags-column~ by default.
+
 *** Underline syntax now takes priority over subscript when both are applicable
 
 Previously, Org mode interpreted =(_text_)= as subscript.
diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
index 83e0316fd..b34623686 100644
--- a/lisp/org-mobile.el
+++ b/lisp/org-mobile.el
@@ -1057,7 +1057,7 @@ (defun org-mobile-edit (what old new)
 	      (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")))))))
diff --git a/lisp/org.el b/lisp/org.el
index a53f36d33..c4475cd62 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6565,7 +6565,7 @@ (defun org-insert-heading (&optional arg invisible-ok level)
 	     ;; 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 " ")
@@ -6677,7 +6677,7 @@ (defun org-edit-headline (&optional heading)
 	   (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 ()
@@ -11215,7 +11215,7 @@ (defun org-priority (&optional action show)
 		  (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)))))
@@ -12021,7 +12021,7 @@ (defun org-set-tags (tags)
 	   (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)
@@ -13261,10 +13261,10 @@ (defun org-entry-put (epom property value)
 	       ((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)
@@ -17088,7 +17088,7 @@ (defun org-self-insert-command (N)
     ;; 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)
@@ -17118,7 +17118,7 @@ (defun org-delete-backward-char (N)
 	     (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.
@@ -17134,7 +17134,7 @@ (defun org-delete-char (N)
 	  (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 ".*?  |")))
@@ -21175,7 +21175,7 @@ (defun org-kill-line (&optional _arg)
 	  (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)
-- 
2.44.0


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-05-13 12:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-17 10:21 [POLL] Should we enable or disable automatic tag alignment by default everywhere Ihor Radchenko
2024-04-17 10:40 ` Gautier Ponsinet
2024-04-17 14:53 ` William Denton
2024-04-17 16:36   ` Ihor Radchenko
2024-04-18  0:02 ` Samuel Wales
2024-04-18  5:17   ` Ihor Radchenko
2024-04-18 10:53 ` Max Nikulin
2024-04-23 11:47   ` Ihor Radchenko
2024-04-23 14:59     ` Max Nikulin
2024-05-13 12:13 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).