emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
@ 2022-01-10  9:26 Samim Pezeshki
  2022-01-10 10:27 ` Christopher M. Miles
  2022-01-21 10:28 ` Nicolas Goaziou
  0 siblings, 2 replies; 8+ messages in thread
From: Samim Pezeshki @ 2022-01-10  9:26 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 128 bytes --]

Hi,

This patch adds a header to the clock report table in the agenda, if
org-agenda-clock-report-header is set.

Thanks,
Samim

[-- Attachment #1.2: Type: text/html, Size: 865 bytes --]

[-- Attachment #2: 0001-lisp-org-agenda.el-Add-header-to-agenda-clock-report.patch --]
[-- Type: text/x-patch, Size: 2777 bytes --]

From 36bc298c1820003cd2a9370bc36c21efe667e7b4 Mon Sep 17 00:00:00 2001
From: Samim Pezeshki <psamim@gmail.com>
Date: Mon, 10 Jan 2022 12:32:51 +0330
Subject: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table

* lisp/org-agenda.el (org-agenda-list): Add header to agenda
clock report table.

TINYCHANGE
---
 doc/org-manual.org | 4 ++--
 etc/ORG-NEWS       | 1 +
 lisp/org-agenda.el | 9 +++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index b4c20f252..2c54fde87 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -9742,8 +9742,8 @@ the other commands, point needs to be in the desired line.
   variable ~org-agenda-start-with-clockreport-mode~.  By using
   a prefix argument when toggling this mode (i.e., {{{kbd(C-u R)}}}),
   the clock table does not show contributions from entries that are
-  hidden by agenda filtering[fn:99].  See also the variable
-  ~org-clock-report-include-clocking-task~.
+  hidden by agenda filtering[fn:99].  See also the variables
+  ~org-clock-report-include-clocking-task~ and ~org-agenda-clock-report-header~.
 
 - {{{kbd(v c)}}} ::
 
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 335db4139..5a94e737e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -140,6 +140,7 @@ introduced which will accept three new formats:
 Chmod-style permissions are based on the new variable
 ~org-babel-tangle-default-file-mode~.
 
+*** A new custom setting =org-agenda-clock-report-header= to add a header to org agenda clock report
 * Version 9.5
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 7bcaf7117..be0808e45 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1217,6 +1217,11 @@ For example, 9:30am would become 09:30 rather than  9:30."
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-agenda-clock-report-header nil
+  "Header for org agenda clock report mode"
+  :group 'org-agenda
+  :type 'string)
+
 (defun org-agenda-time-of-day-to-ampm (time)
   "Convert TIME of a string like \"13:45\" to an AM/PM style time string."
   (let* ((hour-number (string-to-number (substring time 0 -3)))
@@ -4473,6 +4478,10 @@ items if they have an hour specification like [h]h:mm."
 	  (setq p (plist-put p :tend clocktable-end))
 	  (setq p (plist-put p :scope 'agenda))
 	  (setq tbl (apply #'org-clock-get-clocktable p))
+    (when org-agenda-clock-report-header
+      (put-text-property 0 (length org-agenda-clock-report-header) 'face 'org-agenda-structure
+                         org-agenda-clock-report-header)
+      (insert org-agenda-clock-report-header))
 	  (insert tbl)))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
-- 
2.34.1


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

* Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-10  9:26 [PATCH] lisp/org-agenda.el: Add header to agenda clock report table Samim Pezeshki
@ 2022-01-10 10:27 ` Christopher M. Miles
  2022-01-21  9:13   ` Samim Pezeshki
  2022-01-21 10:28 ` Nicolas Goaziou
  1 sibling, 1 reply; 8+ messages in thread
From: Christopher M. Miles @ 2022-01-10 10:27 UTC (permalink / raw)
  To: Samim Pezeshki; +Cc: emacs-orgmode

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


Good idea to add header for clock report table.

Samim Pezeshki <p.samim@gmail.com> writes:

> Hi,
>
> This patch adds a header to the clock report table in the agenda, if 
> org-agenda-clock-report-header is set.
>
> Thanks,
> Samim
>
> [4. text/x-patch; 0001-lisp-org-agenda.el-Add-header-to-agenda-clock-report.patch]...


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-10 10:27 ` Christopher M. Miles
@ 2022-01-21  9:13   ` Samim Pezeshki
  0 siblings, 0 replies; 8+ messages in thread
From: Samim Pezeshki @ 2022-01-21  9:13 UTC (permalink / raw)
  To: numbchild; +Cc: emacs-orgmode

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

Should I do something for this patch to be approved?

On Mon, Jan 10, 2022 at 1:58 PM Christopher M. Miles <numbchild@gmail.com>
wrote:

>
> Good idea to add header for clock report table.
>
> Samim Pezeshki <p.samim@gmail.com> writes:
>
> > Hi,
> >
> > This patch adds a header to the clock report table in the agenda, if
> > org-agenda-clock-report-header is set.
> >
> > Thanks,
> > Samim
> >
> > [4. text/x-patch;
> 0001-lisp-org-agenda.el-Add-header-to-agenda-clock-report.patch]...
>
>
> --
> [ stardiviner ]
>        I try to make every word tell the meaning that I want to express.
>
>        Blog: https://stardiviner.github.io/
>        IRC(freenode): stardiviner, Matrix: stardiviner
>        GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>

[-- Attachment #2: Type: text/html, Size: 1387 bytes --]

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

* Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-10  9:26 [PATCH] lisp/org-agenda.el: Add header to agenda clock report table Samim Pezeshki
  2022-01-10 10:27 ` Christopher M. Miles
@ 2022-01-21 10:28 ` Nicolas Goaziou
  2022-01-22 16:24   ` Samim Pezeshki
  1 sibling, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2022-01-21 10:28 UTC (permalink / raw)
  To: Samim Pezeshki; +Cc: emacs-orgmode

Hello,

Samim Pezeshki <p.samim@gmail.com> writes:

> +(defcustom org-agenda-clock-report-header nil
> +  "Header for org agenda clock report mode"
> +  :group 'org-agenda
> +  :type 'string)

Please add :package-version and :safe keywords to the definition.

Also, type does not match the default value. You probably mean

(choice
 (string :tag "Header")
 (const :tag "No header" nil))

> +
>  (defun org-agenda-time-of-day-to-ampm (time)
>    "Convert TIME of a string like \"13:45\" to an AM/PM style time string."
>    (let* ((hour-number (string-to-number (substring time 0 -3)))
> @@ -4473,6 +4478,10 @@ items if they have an hour specification like [h]h:mm."
>  	  (setq p (plist-put p :tend clocktable-end))
>  	  (setq p (plist-put p :scope 'agenda))
>  	  (setq tbl (apply #'org-clock-get-clocktable p))
> +    (when org-agenda-clock-report-header
> +      (put-text-property 0 (length org-agenda-clock-report-header) 'face 'org-agenda-structure
> +                         org-agenda-clock-report-header)
> +      (insert org-agenda-clock-report-header))

Maybe:

  (insert (propertize org-agenda-clock-report-header 'face 'org-agenda-structure))

Could you send an updated patch?

Regards,
-- 
Nicolas Goaziou


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

* Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-21 10:28 ` Nicolas Goaziou
@ 2022-01-22 16:24   ` Samim Pezeshki
  2022-01-26 20:08     ` Nicolas Goaziou
  2022-01-28  9:01     ` [ISSUE] " Christopher M. Miles
  0 siblings, 2 replies; 8+ messages in thread
From: Samim Pezeshki @ 2022-01-22 16:24 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1492 bytes --]

Thanks Nicolas for reviewing the changes!

I applied the changes.
Attached is the updated patch.



On Fri, Jan 21, 2022 at 1:58 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Samim Pezeshki <p.samim@gmail.com> writes:
>
> > +(defcustom org-agenda-clock-report-header nil
> > +  "Header for org agenda clock report mode"
> > +  :group 'org-agenda
> > +  :type 'string)
>
> Please add :package-version and :safe keywords to the definition.
>
> Also, type does not match the default value. You probably mean
>
> (choice
>  (string :tag "Header")
>  (const :tag "No header" nil))
>
> > +
> >  (defun org-agenda-time-of-day-to-ampm (time)
> >    "Convert TIME of a string like \"13:45\" to an AM/PM style time
> string."
> >    (let* ((hour-number (string-to-number (substring time 0 -3)))
> > @@ -4473,6 +4478,10 @@ items if they have an hour specification like
> [h]h:mm."
> >         (setq p (plist-put p :tend clocktable-end))
> >         (setq p (plist-put p :scope 'agenda))
> >         (setq tbl (apply #'org-clock-get-clocktable p))
> > +    (when org-agenda-clock-report-header
> > +      (put-text-property 0 (length org-agenda-clock-report-header)
> 'face 'org-agenda-structure
> > +                         org-agenda-clock-report-header)
> > +      (insert org-agenda-clock-report-header))
>
> Maybe:
>
>   (insert (propertize org-agenda-clock-report-header 'face
> 'org-agenda-structure))
>
> Could you send an updated patch?
>
> Regards,
> --
> Nicolas Goaziou
>

[-- Attachment #1.2: Type: text/html, Size: 2749 bytes --]

[-- Attachment #2: 0001-lisp-org-agenda.el-Add-header-to-agenda-clock-report.patch --]
[-- Type: text/x-patch, Size: 2786 bytes --]

From 6691abdcef95181ea9517e2c2c60ca52443c14a6 Mon Sep 17 00:00:00 2001
From: Samim Pezeshki <psamim@gmail.com>
Date: Mon, 10 Jan 2022 12:32:51 +0330
Subject: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table

* lisp/org-agenda.el (org-agenda-list): Add header to agenda
clock report table.

TINYCHANGE
---
 doc/org-manual.org |  4 ++--
 etc/ORG-NEWS       |  1 +
 lisp/org-agenda.el | 11 +++++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index b4c20f252..2c54fde87 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -9742,8 +9742,8 @@ the other commands, point needs to be in the desired line.
   variable ~org-agenda-start-with-clockreport-mode~.  By using
   a prefix argument when toggling this mode (i.e., {{{kbd(C-u R)}}}),
   the clock table does not show contributions from entries that are
-  hidden by agenda filtering[fn:99].  See also the variable
-  ~org-clock-report-include-clocking-task~.
+  hidden by agenda filtering[fn:99].  See also the variables
+  ~org-clock-report-include-clocking-task~ and ~org-agenda-clock-report-header~.
 
 - {{{kbd(v c)}}} ::
 
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 335db4139..5a94e737e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -140,6 +140,7 @@ introduced which will accept three new formats:
 Chmod-style permissions are based on the new variable
 ~org-babel-tangle-default-file-mode~.
 
+*** A new custom setting =org-agenda-clock-report-header= to add a header to org agenda clock report
 * Version 9.5
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 7bcaf7117..6357d9cec 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1217,6 +1217,15 @@ For example, 9:30am would become 09:30 rather than  9:30."
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-agenda-clock-report-header nil
+  "Header for org agenda clock report mode"
+  :group 'org-agenda
+  :type '(choice
+    (string :tag "Header")
+    (const :tag "No header" nil))
+  :safe #'stringp
+  :package-version '(Org . "9.6"))
+
 (defun org-agenda-time-of-day-to-ampm (time)
   "Convert TIME of a string like \"13:45\" to an AM/PM style time string."
   (let* ((hour-number (string-to-number (substring time 0 -3)))
@@ -4473,6 +4482,8 @@ items if they have an hour specification like [h]h:mm."
 	  (setq p (plist-put p :tend clocktable-end))
 	  (setq p (plist-put p :scope 'agenda))
 	  (setq tbl (apply #'org-clock-get-clocktable p))
+    (when org-agenda-clock-report-header
+      (insert (propertize org-agenda-clock-report-header 'face 'org-agenda-structure)))
 	  (insert tbl)))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
-- 
2.34.1


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

* Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-22 16:24   ` Samim Pezeshki
@ 2022-01-26 20:08     ` Nicolas Goaziou
  2022-01-28  9:01     ` [ISSUE] " Christopher M. Miles
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2022-01-26 20:08 UTC (permalink / raw)
  To: Samim Pezeshki; +Cc: emacs-orgmode

Hello,

Samim Pezeshki <p.samim@gmail.com> writes:

> Thanks Nicolas for reviewing the changes!
>
> I applied the changes.
> Attached is the updated patch.

Applied. Thank you.

Regards,
-- 
Nicolas Goaziou


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

* [ISSUE] Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-22 16:24   ` Samim Pezeshki
  2022-01-26 20:08     ` Nicolas Goaziou
@ 2022-01-28  9:01     ` Christopher M. Miles
  2022-05-09 12:38       ` [PATCH] " Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Christopher M. Miles @ 2022-01-28  9:01 UTC (permalink / raw)
  To: Samim Pezeshki; +Cc: emacs-orgmode, Nicolas Goaziou

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


I tested this commit, it should auto append a newline character after
~org-agenda-clock-report-header~. Otherwise the header line will in same line with table first line.

Samim Pezeshki <p.samim@gmail.com> writes:

> Thanks Nicolas for reviewing the changes!
>
> I applied the changes.
> Attached is the updated patch.
>
> On Fri, Jan 21, 2022 at 1:58 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
>  Hello,
>
>  Samim Pezeshki <p.samim@gmail.com> writes:
>
>  > +(defcustom org-agenda-clock-report-header nil
>  > +  "Header for org agenda clock report mode"
>  > +  :group 'org-agenda
>  > +  :type 'string)
>
>  Please add :package-version and :safe keywords to the definition.
>
>  Also, type does not match the default value. You probably mean
>
>  (choice
>   (string :tag "Header")
>   (const :tag "No header" nil))
>
>  > +
>  >  (defun org-agenda-time-of-day-to-ampm (time)
>  >    "Convert TIME of a string like \"13:45\" to an AM/PM style time string."
>  >    (let* ((hour-number (string-to-number (substring time 0 -3)))
>  > @@ -4473,6 +4478,10 @@ items if they have an hour specification like [h]h:mm."
>  >         (setq p (plist-put p :tend clocktable-end))
>  >         (setq p (plist-put p :scope 'agenda))
>  >         (setq tbl (apply #'org-clock-get-clocktable p))
>  > +    (when org-agenda-clock-report-header
>  > +      (put-text-property 0 (length org-agenda-clock-report-header) 'face 'org-agenda-structure
>  > +                         org-agenda-clock-report-header)
>  > +      (insert org-agenda-clock-report-header))
>
>  Maybe:
>
>    (insert (propertize org-agenda-clock-report-header 'face 'org-agenda-structure))
>
>  Could you send an updated patch?
>
>  Regards,
>  -- 
>  Nicolas Goaziou
>
> [4. text/x-patch; 0001-lisp-org-agenda.el-Add-header-to-agenda-clock-report.patch]...


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [PATCH] Re: [ISSUE] Re: [PATCH] lisp/org-agenda.el: Add header to agenda clock report table
  2022-01-28  9:01     ` [ISSUE] " Christopher M. Miles
@ 2022-05-09 12:38       ` Ihor Radchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-05-09 12:38 UTC (permalink / raw)
  To: numbchild; +Cc: Samim Pezeshki, emacs-orgmode, Nicolas Goaziou

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

"Christopher M. Miles" <numbchild@gmail.com> writes:

> I tested this commit, it should auto append a newline character after
> ~org-agenda-clock-report-header~. Otherwise the header line will in same line with table first line.

Reasonable concern.
The attached patch should fix it.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda-Make-sure-that-clock-report-header-has-tr.patch --]
[-- Type: text/x-patch, Size: 1396 bytes --]

From c918d5097af4ca82e381cc7a45efccebadf22e91 Mon Sep 17 00:00:00 2001
Message-Id: <c918d5097af4ca82e381cc7a45efccebadf22e91.1652099867.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Mon, 9 May 2022 20:35:18 +0800
Subject: [PATCH] org-agenda: Make sure that clock report header has trailing
 newline

* lisp/org-agenda.el (org-agenda-list): Add trailing newline to
`org-agenda-clock-report-header' if there is none.
---
 lisp/org-agenda.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9d38b889d..3a795ef74 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4486,8 +4486,10 @@ (defun org-agenda-list (&optional arg start-day span with-hour)
 	  (setq p (plist-put p :tend clocktable-end))
 	  (setq p (plist-put p :scope 'agenda))
 	  (setq tbl (apply #'org-clock-get-clocktable p))
-    (when org-agenda-clock-report-header
-      (insert (propertize org-agenda-clock-report-header 'face 'org-agenda-structure)))
+          (when org-agenda-clock-report-header
+            (insert (propertize org-agenda-clock-report-header 'face 'org-agenda-structure))
+            (unless (string-suffix-p "\n" org-agenda-clock-report-header)
+              (insert "\n")))
 	  (insert tbl)))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
-- 
2.35.1


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

end of thread, other threads:[~2022-05-09 12:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10  9:26 [PATCH] lisp/org-agenda.el: Add header to agenda clock report table Samim Pezeshki
2022-01-10 10:27 ` Christopher M. Miles
2022-01-21  9:13   ` Samim Pezeshki
2022-01-21 10:28 ` Nicolas Goaziou
2022-01-22 16:24   ` Samim Pezeshki
2022-01-26 20:08     ` Nicolas Goaziou
2022-01-28  9:01     ` [ISSUE] " Christopher M. Miles
2022-05-09 12:38       ` [PATCH] " Ihor Radchenko

Code repositories for project(s) associated with this 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).