From: gautier@gautierponsinet.xyz
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Bastien <bzg@gnu.org>, emacs-orgmode@gnu.org
Subject: Re: New face: org-agenda-calendar-timerange
Date: Thu, 19 Jan 2023 22:58:39 +0100 [thread overview]
Message-ID: <12a8d2e8b36fb5c6f61a2b084e22a7b8@gautierponsinet.xyz> (raw)
In-Reply-To: <87lely4wne.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 1659 bytes --]
Please find attached a patch containing two commits.
The first one applies the face `org-agenda-calendar-event' to entries
with a time range within a single day.
The second one defines the new face `org-agenda-calendar-daterange'
and applies it to entries with a time range on several days. (The
second commit assumes the first one is already applied.)
Since I am still learning elisp and this is my first contribution, it
would be very nice if someone could double check the patch, and any
feedback would be very welcome.
I will look into the other points we have discussed so far later on.
By the way, while trying to understand the code I have discovered the
commit "cb19f5c94e3dc94da78169ec675d5bd07af34427" by Bastien which I
don't really understand. The commit message says, talking about
entries with a timerange:
"* lisp/org-agenda.el (org-agenda-get-blocks): When both dates are of
the same value, assume this is a time to display for each date in the
range."
It seems to me that this should be done by creating repeating tasks
rather than an entry with a timerange, because suppose I want to put
in my agenda an event spanning on several days including the precise
hours at which it starts and ends but which starts and ends on the
same hour, for example an entry with the following timerange:
<2023-01-19 jeu. 12:00>--<2023-01-26 jeu. 12:00> .
In this case, it makes no sense to print the time "12:00" everyday in
the range. I would expect the agenda to show the event on each days it
is, the time at which the event starts on the first day, and the time
at which the event ends on the last day. Does that make sense?
All the best,
Gautier.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: agenda-timerange-faces.patch --]
[-- Type: text/x-diff; name=agenda-timerange-faces.patch, Size: 4896 bytes --]
From e3feebdf3596645d28d66c1baf6296bcaedf1f42 Mon Sep 17 00:00:00 2001
From: Gautier Ponsinet <gautier@gautierponsinet.xyz>
Date: Thu, 19 Jan 2023 21:34:37 +0100
Subject: [PATCH 1/2] org-agenda: Apply the face `org-agenda-calendar-event'
* list/org-agenda.el (org-agenda-get-blocks): Apply the face
`org-agenda-calendar-event' to entries with a time range within a
single day.
---
lisp/org-agenda.el | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d983a0916..4f29f3eb6 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7059,8 +7059,7 @@ scheduled items with an hour specification like [h]h:mm."
(defun org-agenda-get-blocks ()
"Return the date-range information for agenda display."
(with-no-warnings (defvar date))
- (let* ((props (list 'face nil
- 'org-not-done-regexp org-not-done-regexp
+ (let* ((props (list 'org-not-done-regexp org-not-done-regexp
'org-todo-regexp org-todo-regexp
'org-complex-heading-regexp org-complex-heading-regexp
'mouse-face 'highlight
@@ -7069,9 +7068,9 @@ scheduled items with an hour specification like [h]h:mm."
(abbreviate-file-name buffer-file-name))))
(regexp org-tr-regexp)
(d0 (calendar-absolute-from-gregorian date))
- marker hdmarker ee txt d1 d2 s1 s2 category
- level todo-state tags pos head donep inherited-tags
- effort effort-minutes)
+ face marker hdmarker ee txt d1 d2 s1 s2 category level
+ todo-state tags pos head donep inherited-tags effort
+ effort-minutes)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -7109,6 +7108,9 @@ scheduled items with an hour specification like [h]h:mm."
(setq donep (member todo-state org-done-keywords))
(when (and donep org-agenda-skip-timestamp-if-done)
(throw :skip t))
+ (setq face (if (= d1 d2)
+ 'org-agenda-calendar-event
+ nil))
(setq marker (org-agenda-new-marker (point))
category (org-get-category))
(setq effort (save-match-data (or (get-text-property (point) 'effort)
@@ -7160,6 +7162,7 @@ scheduled items with an hour specification like [h]h:mm."
(concat "<" end-time ">")))))
remove-re))))
(org-add-props txt props
+ 'face face
'org-marker marker 'org-hd-marker hdmarker
'type "block" 'date date
'level level
--
2.39.1
From 5dc50a84ab6adc1765eaf5bf3cf3c670df69f355 Mon Sep 17 00:00:00 2001
From: Gautier Ponsinet <gautier@gautierponsinet.xyz>
Date: Thu, 19 Jan 2023 22:18:12 +0100
Subject: [PATCH 2/2] Define the face `org-agenda-calendar-daterange'
* etc/ORG-NEWS: Announce the introduction of the new face
`org-agenda-calendar-daterange'.
* lisp/org-faces.el: Define the face `org-agenda-calendar-daterange'.
* lisp/org-agenda.el (org-agenda-get-blocks): Apply the face
`org-agenda-calendar-daterange' to entries with a date range.
---
etc/ORG-NEWS | 5 +++++
lisp/org-agenda.el | 2 +-
lisp/org-faces.el | 4 ++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c5d9bdf6e..613b32408 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -55,6 +55,11 @@ document header:
,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
#+END_src
+*** New face: ~org-agenda-calendar-daterange~
+The face ~org-agenda-calendar-daterange~ is used to show entries with
+a date range in the agenda. It inherits from the default face in
+order to remain backward-compatible.
+
* Version 9.6
** Important announcements and breaking changes
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 4f29f3eb6..15736e5b8 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7110,7 +7110,7 @@ scheduled items with an hour specification like [h]h:mm."
(throw :skip t))
(setq face (if (= d1 d2)
'org-agenda-calendar-event
- nil))
+ 'org-agenda-calendar-daterange))
(setq marker (org-agenda-new-marker (point))
category (org-get-category))
(setq effort (save-match-data (or (get-text-property (point) 'effort)
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index 594c9a6e7..b3f8e419c 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -660,6 +660,10 @@ month and 365.24 days for a year)."
"Face used for agenda entries that come from the Emacs diary."
:group 'org-faces)
+(defface org-agenda-calendar-daterange '((t :inherit default))
+ "Face used to show entries with a date range in the agenda."
+ :group 'org-faces)
+
(defface org-agenda-calendar-event '((t :inherit default))
"Face used to show events and appointments in the agenda."
:group 'org-faces)
--
2.39.1
next prev parent reply other threads:[~2023-01-19 21:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 16:56 New face: org-agenda-calendar-timerange Gautier Ponsinet
2023-01-17 11:20 ` Ihor Radchenko
2023-01-17 22:25 ` gautier
2023-01-18 10:08 ` Ihor Radchenko
2023-01-18 15:41 ` gautier
2023-01-18 16:01 ` gautier
2023-01-19 11:00 ` Ihor Radchenko
2023-01-19 21:58 ` gautier [this message]
2023-01-20 3:32 ` Ruijie Yu via General discussions about Org-mode.
2023-01-20 4:24 ` Ruijie Yu via General discussions about Org-mode.
2023-01-20 11:24 ` Ihor Radchenko
2023-01-20 11:36 ` Bastien Guerry
2023-01-21 8:27 ` Ihor Radchenko
2023-01-21 8:29 ` Ihor Radchenko
2023-01-21 22:44 ` Gautier Ponsinet
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=12a8d2e8b36fb5c6f61a2b084e22a7b8@gautierponsinet.xyz \
--to=gautier@gautierponsinet.xyz \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/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).