Re:[PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-12-18 Thread Ihor Radchenko
Ihor Radchenko  writes:

> If you have no objections to the patch, I will apply it next week with
> suggestion from Max.

Applied to bugfix as 85aaa1990



Re:[PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-12-10 Thread Ihor Radchenko
tumashu   writes:

> Another way is creating a new function for the below code, so user can advice 
> it to full control time string format.

It is technically possible. However, to be frank, org-agenda code is
too much mess to introduce yet another function or customisation. I am
reluctant to do anything more than bug fixing until we refactor
org-agenda.el to something more maintainable.

If you have no objections to the patch, I will apply it next week with
suggestion from Max.

Best,
Ihor



Re: [PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-10-06 Thread Nicolas Goaziou
Hello,

Ihor Radchenko  writes:

> Nicolas Goaziou  writes:
>
>> Also, the fix belongs to `org-get-time-of-day', which is also
>> responsible for formatting the output.
>
> I doubt so. `org-get-time-of-day' is used to format ending time in time
> ranges.  If we force fixed width in `org-get-time-of-day', we may have
> something like " 8:00- 9:00" instead of " 8:00-9:00".  On the other
> hand, the current behaviour for non-nil org-agenda-timegrid-use-ampm, we
> already have "8am- 9am" even without the patch.
>
> WDYT?

Fair enough. I think I should not even try to understand
"org-agenda.el".

Regards,
-- 
Nicolas Goaziou



Re:[PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-10-04 Thread tumashu
















At 2021-10-04 15:48:49, "Ihor Radchenko"  wrote:
>tumashu  writes:
>
>> Hello:
>>
>>
>> When I update to org 9.5,  I find that  the align of time like "7:00" has 
>> been changed.
>>
>> I think the new style is not beautiful as old style.
>>  
>> 1. New style look like not align to  the first char, for the width of 9 
>> looks like > 1
>> 2. the old style is align ":"
>
>The attached patch should fix the issue. Please, test it though. I do
>not use time grid regularly.

If change s1, I think s2 should be deal with too, by the way, what about change 
the below function?

```
(defun org-agenda-time-of-day-to-ampm-maybe (time)
  "Conditionally convert TIME to AM/PM format.
This is based on `org-agenda-timegrid-use-ampm'."
  (if org-agenda-timegrid-use-ampm
  (org-agenda-time-of-day-to-ampm time)
time))
^^^
```

Another way is creating a new function for the below code, so user can advice 
it to full control time string format.

```
(cond (s2 (concat
  (org-agenda-time-of-day-to-ampm-maybe s1)
  "-" (org-agenda-time-of-day-to-ampm-maybe s2)
  (when org-agenda-timegrid-use-ampm " ")))
 (s1 (concat
  (org-agenda-time-of-day-to-ampm-maybe s1)
  (if org-agenda-timegrid-use-ampm
  (concat time-grid-trailing-characters " ")
time-grid-trailing-characters)))
 (t ""))

```


>
>Best,
>Ihor
>


Re: [PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-10-04 Thread Ihor Radchenko
Nicolas Goaziou  writes:

>> I think, "%5s" is enough, flag "0" does not anything useful for
>> strings.
>
> Also, the fix belongs to `org-get-time-of-day', which is also
> responsible for formatting the output.

I doubt so. `org-get-time-of-day' is used to format ending time in time
ranges.  If we force fixed width in `org-get-time-of-day', we may have
something like " 8:00- 9:00" instead of " 8:00-9:00".  On the other
hand, the current behaviour for non-nil org-agenda-timegrid-use-ampm, we
already have "8am- 9am" even without the patch.

WDYT?

Best,
Ihor



Re: [PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-10-04 Thread Nicolas Goaziou
Hello,

Max Nikulin  writes:

> On 04/10/2021 14:48, Ihor Radchenko wrote:
>> tumashu writes:
>>>
>>> When I update to org 9.5,  I find that  the align of time like "7:00" has 
>>> been changed.
>>>
>>> I think the new style is not beautiful as old style.
>>>   1. New style look like not align to  the first char, for the
>>> width of 9 looks like > 1
>>> 2. the old style is align ":"
>> The attached patch should fix the issue. Please, test it though.
>> I do
>> not use time grid regularly.
>
>> -  (when s1 (setq s1 (org-get-time-of-day s1 'overtime)))
>> +  (when s1 (setq s1 (format "%05s" (org-get-time-of-day s1 'overtime
>
> I think, "%5s" is enough, flag "0" does not anything useful for
> strings.

Also, the fix belongs to `org-get-time-of-day', which is also
responsible for formatting the output.

Regards,
-- 
Nicolas Goaziou



Re: [PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-10-04 Thread Max Nikulin

On 04/10/2021 14:48, Ihor Radchenko wrote:

tumashu writes:


When I update to org 9.5,  I find that  the align of time like "7:00" has been 
changed.

I think the new style is not beautiful as old style.
  
1. New style look like not align to  the first char, for the width of 9 looks like > 1

2. the old style is align ":"


The attached patch should fix the issue. Please, test it though. I do
not use time grid regularly.



- (when s1 (setq s1 (org-get-time-of-day s1 'overtime)))
+ (when s1 (setq s1 (format "%05s" (org-get-time-of-day s1 'overtime


I think, "%5s" is enough, flag "0" does not anything useful for strings.





[PATCH] The align of time is not beautiful as 9.4 when I update to org 9.5.

2021-10-04 Thread Ihor Radchenko
tumashu  writes:

> Hello:
>
>
> When I update to org 9.5,  I find that  the align of time like "7:00" has 
> been changed.
>
> I think the new style is not beautiful as old style.
>  
> 1. New style look like not align to  the first char, for the width of 9 looks 
> like > 1
> 2. the old style is align ":"

The attached patch should fix the issue. Please, test it though. I do
not use time grid regularly.

Best,
Ihor

>From df5c35bd84e1d343c52c605c2c77393fb11ad590 Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Mon, 4 Oct 2021 15:45:16 +0800
Subject: [PATCH] org-agenda: Make sure that time grid is aligned when hour <10

* lisp/org-agenda.el (org-agenda-format-item): Make sure that hour
part of begin time in time grid always occupy 5 chars

Fixes https://list.orgmode.org/orgmode/3afe1bba.2f48.17c350d0a41.coremail.tuma...@163.com/
---
 lisp/org-agenda.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 354f40867..e20d0225f 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6765,7 +6765,7 @@ (defvar level) (defvar tag) (defvar time))
 	(setq duration (- (org-duration-to-minutes s2)
 			  (org-duration-to-minutes s1
   ;; Format S1 and S2 for display.
-	  (when s1 (setq s1 (org-get-time-of-day s1 'overtime)))
+	  (when s1 (setq s1 (format "%05s" (org-get-time-of-day s1 'overtime
 	  (when s2 (setq s2 (org-get-time-of-day s2 'overtime
 	(when (string-match org-tag-group-re txt)
 	  ;; Tags are in the string
-- 
2.32.0