emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Alain.Cochard@unistra.fr
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
Date: Sat, 13 Aug 2022 14:33:54 +0800	[thread overview]
Message-ID: <87tu6g7iul.fsf@localhost> (raw)
In-Reply-To: <25334.19025.107017.390781@gargle.gargle.HOWL>

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

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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-align-tags-Fix-tag-alignment-in-inlinetasks.patch --]
[-- Type: text/x-patch, Size: 1511 bytes --]

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


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



-- 
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	other threads:[~2022-08-13  6:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 12:40 Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment Alain.Cochard
2022-08-13  6:33 ` Ihor Radchenko [this message]
2022-08-19 12:14   ` Alain.Cochard
2022-08-20  7:20     ` Ihor Radchenko
2022-08-21 15:13       ` Alain.Cochard
2022-08-22 12:08         ` Ihor Radchenko
2022-08-22 15:17           ` applying patches Max Nikulin
2022-08-23  2:43             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu6g7iul.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=Alain.Cochard@unistra.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).