emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignm


From: Ihor Radchenko
Subject: Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
Date: Sat, 13 Aug 2022 14:33:54 +0800

Alain.Cochard@unistra.fr writes:

> Then, to observe the problem, I can for example compare
>
> (1) visiting the file pb.org containing:
>
>    #+STARTUP: noindent
>    * headline 1                               :htag:
>    *************** inelinetask             :itag:
>    *************** END
>    * headline 2                       :htag:
>
> and doing C-u C-c C-q,  to 
>
> (2) the same, but with 'indent' instead of 'noindent'.
>
> For me, all 3 tags end up perfectly aligned in the case (1), while
> ':itag:' is shifted to the right in case (2).

Thanks for reporting!
Can you try the attached patch?

>From 66260f723b64e20598766f14982f13c98fe40ee8 Mon Sep 17 00:00:00 2001
Message-Id: 
<66260f723b64e20598766f14982f13c98fe40ee8.1660372414.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 13 Aug 2022 14:28:55 +0800
Subject: [PATCH] org-align-tags: Fix tag alignment in inlinetasks

* lisp/org.el (org-align-tags): Re-use 'line-prefix text property when
`org-indent-mode' is enabled.  The old version partially copy-pasted
the org-indent code and missed the new changes in inlinetask
alignment.  The new approach should be robust against future
org-indent changes.

Fixes 25334.19025.107017.390781@gargle.gargle.HOWL">https://orgmode.org/list/25334.19025.107017.390781@gargle.gargle.HOWL
---
 lisp/org.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4eef56f45..2f528aaa4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11519,8 +11519,12 @@ (defun org-align-tags (&optional all)
   (let ((get-indent-column
         (lambda ()
           (let ((offset (if (bound-and-true-p org-indent-mode)
-                            (* (1- org-indent-indentation-per-level)
-                               (1- (org-current-level)))
+                             (save-excursion
+                               (org-back-to-heading-or-point-min)
+                               (length
+                                (get-text-property
+                                 (line-end-position)
+                                 'line-prefix)))
                           0)))
             (+ org-tags-column
                (if (> org-tags-column 0) (- offset) offset))))))
-- 
2.35.1


-- 
Ihor Radchenko,
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]