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

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  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
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Gautier Ponsinet @ 2024-04-17 10:40 UTC (permalink / raw)
  To: Ihor Radchenko, emacs-orgmode; +Cc: Max Nikulin

Hello Ihor,

Ihor Radchenko <yantar92@posteo.net> [2024-04-17 10:21 +0000]:
> 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.

I am voting for applying the change you propose and setting the default
value of ~org-auto-align-tags~ to t.

(and thank you for all your work!)

All the best,
Gautier.


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

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  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
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: William Denton @ 2024-04-17 14:53 UTC (permalink / raw)
  Cc: emacs-orgmode

On Wednesday, April 17th, 2024 at 06:21, Ihor Radchenko <yantar92@posteo.net> wrote:

> 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

I use proportional fonts for regular text (with the mixed-pitch package).  In this situation, as far as I know the only way to make tags look at consistent is to set org-tags-column to 0 so they directly follow the text (I make the font size smaller, so there's a large heading then small tag) or to jam them way over as far right as they'll go.  Anything else and they look ragged.

So I suspect people using variable pitches will already have this turned on, and making it the default won't bother them.  

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada



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

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  2024-04-17 14:53 ` William Denton
@ 2024-04-17 16:36   ` Ihor Radchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-04-17 16:36 UTC (permalink / raw)
  To: William Denton; +Cc: emacs-orgmode

William Denton <william@williamdenton.org> writes:

> On Wednesday, April 17th, 2024 at 06:21, Ihor Radchenko <yantar92@posteo.net> wrote:
>
>> 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
>
> I use proportional fonts for regular text (with the mixed-pitch package).  In this situation, as far as I know the only way to make tags look at consistent is to set org-tags-column to 0 so they directly follow the text (I make the font size smaller, so there's a large heading then small tag) or to jam them way over as far right as they'll go.  Anything else and they look ragged.

Yes. But this is out of scope of the discussed tag alignment -
`org-auto-align-tags' controls the actual plain text in Org buffers.
`org-tags-column' has no meaning when non-proportional fonts are used.

For non-proportional fonts, the display depends on the specifics of the
fonts used to display various parts of the headline. If we want to
display Org tags right-aligned, for example, it is a job for
fontification and does not need to involve editing the underlying plain text.

> So I suspect people using variable pitches will already have this turned on, and making it the default won't bother them.  

Sure. I'd like to hear from people who do care about the proposed changes.

-- 
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	[flat|nested] 10+ messages in thread

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  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-18  0:02 ` Samuel Wales
  2024-04-18  5:17   ` Ihor Radchenko
  2024-04-18 10:53 ` Max Nikulin
  2024-05-13 12:13 ` Ihor Radchenko
  4 siblings, 1 reply; 10+ messages in thread
From: Samuel Wales @ 2024-04-18  0:02 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org, Max Nikulin

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

for some reason 9.6.22 says org-auto-align-tags is set to t by default.
[btw, i use proportional fonts, so org-tags-column is 0.]



-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com

[-- Attachment #2: Type: text/html, Size: 356 bytes --]

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

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  2024-04-18  0:02 ` Samuel Wales
@ 2024-04-18  5:17   ` Ihor Radchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-04-18  5:17 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode@gnu.org, Max Nikulin

Samuel Wales <samologist@gmail.com> writes:

> for some reason 9.6.22 says org-auto-align-tags is set to t by default.

Hmm... That's a good reason. And I need to get some sleep.

The default is really t.

The change is still breaking though, but only for people who customized
~org-auto-align-tags~.

-- 
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	[flat|nested] 10+ messages in thread

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  2024-04-17 10:21 [POLL] Should we enable or disable automatic tag alignment by default everywhere Ihor Radchenko
                   ` (2 preceding siblings ...)
  2024-04-18  0:02 ` Samuel Wales
@ 2024-04-18 10:53 ` Max Nikulin
  2024-04-23 11:47   ` Ihor Radchenko
  2024-05-13 12:13 ` Ihor Radchenko
  4 siblings, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2024-04-18 10:53 UTC (permalink / raw)
  To: emacs-orgmode

On 17/04/2024 17:21, Ihor Radchenko wrote:
> Or maybe should we keep the status quo with ~org-auto-align-tags~
> sometimes respected and sometimes not?

I am rather neutral in respect to this change.

I like that tags are aligned (so I am not going to set 
`org-auto-align-tags' to nil), but generally I do not bother. I have 
some old headings where tags were typed directly and so they are not 
aligned.

It was painful when I accidentally hit an extra key and got all tags 
realigned. I had to spend some time to avoid committing unintended 
changes. I am unsure if the proposed patch will alleviate similar issues 
since it allows to disable realignment only. In my case some tags were 
shifted by a space or two. Perhaps some editing commands (refile & Co) 
do not call `org-align-tags', perhaps it was direct kill and yank 
bypassing Org edit structure commands, so there was no chance to get 
properly aligned tags after editing.

In that thread tag alignment was just an example when minor user mistake 
can lead to global changes.
Max Nikulin. Preventing inadvertent global modifications. Tue, 12 Sep 
2023 23:47:30 +0700.
https://list.orgmode.org/udq4n4$1me$1@ciao.gmane.io

Some general considerations.

There should be a way to align tags for a specific heading even when 
`org-auto-align-tags' is nil.

> -	   (org-align-tags)
> +	   (when org-auto-align-tags (org-align-tags))

Instead of repetitive changes I would consider either checking 
`org-auto-align-tags' inside `org-align-tags' or introducing a macro.



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

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  2024-04-18 10:53 ` Max Nikulin
@ 2024-04-23 11:47   ` Ihor Radchenko
  2024-04-23 14:59     ` Max Nikulin
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2024-04-23 11:47 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> There should be a way to align tags for a specific heading even when 
> `org-auto-align-tags' is nil.
>
>> -	   (org-align-tags)
>> +	   (when org-auto-align-tags (org-align-tags))

I can convert org-align-tags into a command.

> Instead of repetitive changes I would consider either checking 
> `org-auto-align-tags' inside `org-align-tags' or introducing a macro.

It will not do much good:

1. If we check inside `org-align-tags', it will be a breaking API
   change and the command name will no longer be intuitive.

2. If we introduce a macro/function, it will be something like
   (org-align-tags-maybe) - not much different from
   (when org-auto-align-tags (org-align-tags))

-- 
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	[flat|nested] 10+ messages in thread

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  2024-04-23 11:47   ` Ihor Radchenko
@ 2024-04-23 14:59     ` Max Nikulin
  0 siblings, 0 replies; 10+ messages in thread
From: Max Nikulin @ 2024-04-23 14:59 UTC (permalink / raw)
  To: emacs-orgmode

On 23/04/2024 18:47, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>> There should be a way to align tags for a specific heading even when
>> `org-auto-align-tags' is nil.
> 
> I can convert org-align-tags into a command.

I would prefer to have C-u C-c C-q (`org-set-tags-command') applied just 
to the current heading (or to active region). Unfortunately it would be 
a breaking change. I have no idea how to make (org-align-tags) call 
easier than (org-align-tags 'all) without breaking changes. Otherwise it 
would be inconsistent and M-: (org-align-tags) can be used in the last 
resort.



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

* Re: [POLL] Should we enable or disable automatic tag alignment by default everywhere
  2024-04-17 10:21 [POLL] Should we enable or disable automatic tag alignment by default everywhere Ihor Radchenko
                   ` (3 preceding siblings ...)
  2024-04-18 10:53 ` Max Nikulin
@ 2024-05-13 12:13 ` Ihor Radchenko
  4 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-05-13 12:13 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Max Nikulin

Ihor Radchenko <yantar92@posteo.net> writes:

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

Given positive responses, I have applied the patch onto main.
Applied, patch.
Closed, poll.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=aa71facf6

> 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.
> ...

That was a mistake. org-auto-align-tags is _enabled_ by default. So, the
change will only be breaking for users who explicitly disabled
org-auto-align-tags. (see the updated news entry in the commit)

-- 
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	[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).