emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
@ 2022-08-12 12:40 Alain.Cochard
  2022-08-13  6:33 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Alain.Cochard @ 2022-08-12 12:40 UTC (permalink / raw)
  To: Org Mode List; +Cc: alain.cochard


Hello.

I use

emacs -Q -l ~/.emacs.git

with ~/.emacs.git containing only:

   (add-to-list 'load-path "~/Org/Coch-git/org-mode/lisp")
   (require 'org-inlinetask)

which gives:

   Org mode version 9.5.4 (release_9.5.4-727-gb42883 @
   /home/cochard/Org/Coch-git/org-mode/lisp/) GNU Emacs 27.2 (build 1,
   x86_64-redhat-linux-gnu, GTK+ Version 3.24.30, cairo version
   1.17.4) of 2021-08-07

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

NB: I observe a consistent (bad) behavior by customizing
org-startup-indented.

Regards.

-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France     | [ slot available for rent ]



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

* Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
  2022-08-12 12:40 Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment Alain.Cochard
@ 2022-08-13  6:33 ` Ihor Radchenko
  2022-08-19 12:14   ` Alain.Cochard
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-08-13  6:33 UTC (permalink / raw)
  To: Alain.Cochard; +Cc: Org Mode List

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

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

* Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
  2022-08-13  6:33 ` Ihor Radchenko
@ 2022-08-19 12:14   ` Alain.Cochard
  2022-08-20  7:20     ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Alain.Cochard @ 2022-08-19 12:14 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Alain.Cochard, Org Mode List

Ihor Radchenko writes on Sat 13 Aug 2022 14:33:

 > Can you try the attached patch?

The problem is solved if I use emacs 28.1 (thanks a lot), but not for
emacs 27.2...

Emacs 27.2 is the native emacs for the Fedora 34 GNU/Linux
distribution I use.  I was able to install emacs 28.1 from source, but
I couldn't have my MUA (vm) work properly with it, so it would be
great if you could find a fix valid for emacs 27.2 too!

PS: I have had only a very limited and ancient experience with
patches, so it was not immediate for me to try your patch.  While
working on it, I noticed that the section of the manual

   * Feedback::                     Bug reports, ideas, patches, etc.

does not even contain the word 'patch'.  So I was thinking it might be
a good idea to say a few words in that section about what patches are
and how to apply them.


-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France     | [ slot available for rent ]



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

* Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
  2022-08-19 12:14   ` Alain.Cochard
@ 2022-08-20  7:20     ` Ihor Radchenko
  2022-08-21 15:13       ` Alain.Cochard
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-08-20  7:20 UTC (permalink / raw)
  To: alain.cochard; +Cc: Org Mode List

Alain.Cochard@unistra.fr writes:

>  > Can you try the attached patch?
>
> The problem is solved if I use emacs 28.1 (thanks a lot), but not for
> emacs 27.2...

Applied onto main via ccca8549a.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ccca8549a2fe3158ad41603eedc8ba427a240df5

I have tested the patch on emacs-27.2, and it works just fine.
Can you please check again using the newest development version of Org?

> PS: I have had only a very limited and ancient experience with
> patches, so it was not immediate for me to try your patch.  While
> working on it, I noticed that the section of the manual
>
>    * Feedback::                     Bug reports, ideas, patches, etc.
>
> does not even contain the word 'patch'.  So I was thinking it might be
> a good idea to say a few words in that section about what patches are
> and how to apply them.

Applying patches is out of scope of the manual.
Next time, you can just ask to provide an alternative way of testing. I
can then just upload the patched version to an alternative repository.

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


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

* Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
  2022-08-20  7:20     ` Ihor Radchenko
@ 2022-08-21 15:13       ` Alain.Cochard
  2022-08-22 12:08         ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Alain.Cochard @ 2022-08-21 15:13 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: alain.cochard, Org Mode List

Ihor Radchenko writes on Sat 20 Aug 2022 15:20:

 > I have tested the patch on emacs-27.2, and it works just fine.  Can
 > you please check again using the newest development version of Org?

Indeed, now it works for me too.  Thanks.

 > > I noticed that the section of the manual
 > >
 > >    * Feedback::                     Bug reports, ideas, patches, etc.
 > >
 > > does not even contain the word 'patch'.  So I was thinking it might be
 > > a good idea to say a few words in that section about what patches are
 > > and how to apply them.
 > 
 > Applying patches is out of scope of the manual.

Fair enough, but in that case shouldn't the word "patches" be removed
from "Bug reports, ideas, patches, etc."?   

 > Next time, you can just ask to provide an alternative way of testing. I
 > can then just upload the patched version to an alternative repository.

Well, I was trying to save you some time so that you can spend it on
more constructive actions.  I succeeded, and learned things in the
process -- patching (at least basic concepts and actions) is
relatively simple, so I think it could easily be _within_ the scope of
the manual.

Regards

-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France     | [ slot available for rent ]



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

* Re: Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment
  2022-08-21 15:13       ` Alain.Cochard
@ 2022-08-22 12:08         ` Ihor Radchenko
  2022-08-22 15:17           ` applying patches Max Nikulin
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-08-22 12:08 UTC (permalink / raw)
  To: Alain.Cochard; +Cc: Org Mode List

Alain.Cochard@unistra.fr writes:

>  > Applying patches is out of scope of the manual.
>
> Fair enough, but in that case shouldn't the word "patches" be removed
> from "Bug reports, ideas, patches, etc."?   

The word "patches" refers to sending patches, not applying or testing.
It only makes sense for people who know how to create patches.

In addition, we have https://orgmode.org/worg/org-contribute.html
detailing how to propose patches to Org.

On the other hand, testing the proposed patches is also a kind of
Feedback and can be thought as fitting to the manual section.

>  > Next time, you can just ask to provide an alternative way of testing. I
>  > can then just upload the patched version to an alternative repository.
>
> Well, I was trying to save you some time so that you can spend it on
> more constructive actions.  I succeeded, and learned things in the
> process -- patching (at least basic concepts and actions) is
> relatively simple, so I think it could easily be _within_ the scope of
> the manual.

It might. It is probably even useful. Would you mind writing several
paragraphs for the manual about applying patches?

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


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

* applying patches
  2022-08-22 12:08         ` Ihor Radchenko
@ 2022-08-22 15:17           ` Max Nikulin
  2022-08-23  2:43             ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Max Nikulin @ 2022-08-22 15:17 UTC (permalink / raw)
  To: emacs-orgmode

On 22/08/2022 19:08, Ihor Radchenko wrote:
> Alain.Cochard@unistra.fr writes:
> 
>> Well, I was trying to save you some time so that you can spend it on
>> more constructive actions.  I succeeded, and learned things in the
>> process -- patching (at least basic concepts and actions) is
>> relatively simple, so I think it could easily be _within_ the scope of
>> the manual.
> 
> It might. It is probably even useful. Would you mind writing several
> paragraphs for the manual about applying patches?

It may be enough to add links to already written documents.

For those who are familiar with git:

https://git-scm.com/book/en/v2/Distributed-Git-Maintaining-a-Project

Perhaps I have seen better introduction how to use the "patch" command than
https://www.gnu.org/software/diffutils/manual/html_node/Merging-with-patch.html



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

* Re: applying patches
  2022-08-22 15:17           ` applying patches Max Nikulin
@ 2022-08-23  2:43             ` Ihor Radchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-08-23  2:43 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>> It might. It is probably even useful. Would you mind writing several
>> paragraphs for the manual about applying patches?
>
> It may be enough to add links to already written documents.

I'd say that the purpose of describing patch or git apply in the manual
is a quick reference for ordinary users who report a bug and want to
test the proposed fix.

More detailed instructions may be added to
https://orgmode.org/worg/org-contribute.html

> For those who are familiar with git:
>
> https://git-scm.com/book/en/v2/Distributed-Git-Maintaining-a-Project
>
> Perhaps I have seen better introduction how to use the "patch" command than
> https://www.gnu.org/software/diffutils/manual/html_node/Merging-with-patch.html

I'd better see these links in org-contribute.
Possibly, we can add a new item to "Ways that do not involve programming":
- Help to test the proposed patches: You can help checking the quality
  of existing patches submitted to the mailing list. Just apply the
  patch (see [[how to apply patches]]) and try using it with your Org
  setup. Then report any issues or rough edges.

<<how to apply patches>> can then detail different ways to do it and
provide the above links as further reading.

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


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

end of thread, other threads:[~2022-08-23  2:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 12:40 Suspected bug: '#+STARTUP: indent' messes up inlinetasks' tag alignment Alain.Cochard
2022-08-13  6:33 ` Ihor Radchenko
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

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