emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Patch] Hide the file column in a clock report.
@ 2017-08-31 18:44 Michaël Cadilhac
  2017-09-02  2:20 ` Adam Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Michaël Cadilhac @ 2017-08-31 18:44 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi there;

Not sure it's for everyone, but I really don't need the file column in
my clock report, even though I use multiple files.  Here's a patch
that allows this, if there's any interest.

M.

[-- Attachment #2: 0001-Add-the-option-of-hiding-the-file-column-in-a-clock-.patch --]
[-- Type: text/x-patch, Size: 3770 bytes --]

From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
Date: Thu, 31 Aug 2017 19:37:55 +0100
Subject: [PATCH] Add the option of hiding the file column in a clock report

* contrib/orgmanual.org: Document the change.
* doc/org.texi (The clock table): Ditto.
* lisp/org-clock.el (org-clocktable-defaults): Add default value for
  :hidefiles.
(org-dblock-write:clocktable): Do not make "multiline" true if
hidefiles is.
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/clocktable):
  Add :hidefiles to completions.

TINYCHANGE
---
 contrib/orgmanual.org | 4 ++++
 doc/org.texi          | 1 +
 lisp/org-clock.el     | 5 ++++-
 lisp/org-pcomplete.el | 5 +++--
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/contrib/orgmanual.org b/contrib/orgmanual.org
index 6cc88a86e..e184fb51d 100644
--- a/contrib/orgmanual.org
+++ b/contrib/orgmanual.org
@@ -6253,6 +6253,10 @@ but you can specify your own function using the ~:formatter~ parameter.
 
   Indent each headline field according to its level.
 
+- :hidefiles ::
+
+  Hide the file column when multiple files are used to produced the table.
+
 - :tcolumns ::   
 
   Number of columns to be used for times.  If this is smaller than
diff --git a/doc/org.texi b/doc/org.texi
index a74f967f5..2c2f8d0cc 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6689,6 +6689,7 @@ but you can specify your own function using the @code{:formatter} parameter.
              @r{the org table.  If you write it like @samp{50!}, then the}
              @r{headline will also be shortened in export.}
 :indent      @r{Indent each headline field according to its level.}
+:hidefiles   @r{Should the file column be hidden when multiple files are parsed?}
 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
 :level       @r{Should a level number column be included?}
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6b967c673..05c46e18c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -298,6 +298,7 @@ string as argument."
    :link nil
    :narrow '40!
    :indent t
+   :hidefiles nil
    :formula nil
    :timestamp nil
    :level nil
@@ -2391,6 +2392,7 @@ the currently selected interval size."
 	   (ws (plist-get params :wstart))
 	   (ms (plist-get params :mstart))
 	   (step (plist-get params :step))
+	   (hide-files (plist-get params :hidefiles))
 	   (formatter (or (plist-get params :formatter)
 			  org-clock-clocktable-formatter
 			  'org-clocktable-write-default))
@@ -2445,7 +2447,8 @@ the currently selected interval size."
 	     ;; Even though `file-with-archives' can consist of
 	     ;; multiple files, we consider this is one extended file
 	     ;; instead.
-	     (and (consp files) (not (eq scope 'file-with-archives)))))
+	     (and (not hide-files)
+		  (consp files) (not (eq scope 'file-with-archives)))))
 
 	(funcall formatter
 		 origin
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 61ec5fad4..a92b44cb2 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -374,8 +374,9 @@ Complete a language in the first field, the header arguments and switches."
 			   ":tstart" ":tend" ":block" ":step"
 			   ":stepskip0" ":fileskip0"
 			   ":emphasize" ":link" ":narrow" ":indent"
-			   ":tcolumns" ":level" ":compact" ":timestamp"
-			   ":formula" ":formatter" ":wstart" ":mstart"))))
+			   ":hidefiles" ":tcolumns" ":level" ":compact"
+			   ":timestamp" ":formula" ":formatter"
+			   ":wstart" ":mstart"))))
 
 (defun org-pcomplete-case-double (list)
   "Return list with both upcase and downcase version of all strings in LIST."
-- 
2.14.1


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

* Re: [Patch] Hide the file column in a clock report.
  2017-08-31 18:44 [Patch] Hide the file column in a clock report Michaël Cadilhac
@ 2017-09-02  2:20 ` Adam Porter
  2017-09-02  9:14   ` Michaël Cadilhac
  0 siblings, 1 reply; 7+ messages in thread
From: Adam Porter @ 2017-09-02  2:20 UTC (permalink / raw)
  To: emacs-orgmode

Michaël Cadilhac <michael@cadilhac.name> writes:

> Hi there;
>
> Not sure it's for everyone, but I really don't need the file column in
> my clock report, even though I use multiple files.  Here's a patch
> that allows this, if there's any interest.

This looks very nice!  One suggestion:

+:hidefiles   @r{Should the file column be hidden when multiple files are parsed?}

It would be clearer if it said something like, "Hide file column when
multiple files are parsed."  The other options mentioned there are
written like that, not as questions.  :)

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

* Re: [Patch] Hide the file column in a clock report.
  2017-09-02  2:20 ` Adam Porter
@ 2017-09-02  9:14   ` Michaël Cadilhac
  2017-09-03  1:11     ` Adam Porter
  2017-09-03  8:15     ` Nicolas Goaziou
  0 siblings, 2 replies; 7+ messages in thread
From: Michaël Cadilhac @ 2017-09-02  9:14 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-orgmode

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

On 2 September 2017 at 03:20, Adam Porter <adam@alphapapa.net> wrote:
> One suggestion:
>
> +:hidefiles   @r{Should the file column be hidden when multiple files are parsed?}
>
> It would be clearer if it said something like, "Hide file column when
> multiple files are parsed."  The other options mentioned there are
> written like that, not as questions.  :)

While I definitely agree that question form is weird, I copied it from
the ":level" option (arguably without thinking twice) which reads:

:level       @r{Should a level number column be included?}

In any case, let's not repeat that oddity :-)  I've changed the patch
according to your suggestion.

Cheers;
M.

[-- Attachment #2: 0001-Add-the-option-of-hiding-the-file-column-in-a-clock-.patch --]
[-- Type: text/x-patch, Size: 3754 bytes --]

From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
Date: Thu, 31 Aug 2017 19:37:55 +0100
Subject: [PATCH] Add the option of hiding the file column in a clock report

* contrib/orgmanual.org: Document the change.
* doc/org.texi (The clock table): Ditto.
* lisp/org-clock.el (org-clocktable-defaults): Add default value for
  :hidefiles.
(org-dblock-write:clocktable): Do not make "multiline" true if
hidefiles is.
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/clocktable):
  Add :hidefiles to completions.

TINYCHANGE
---
 contrib/orgmanual.org | 4 ++++
 doc/org.texi          | 1 +
 lisp/org-clock.el     | 5 ++++-
 lisp/org-pcomplete.el | 5 +++--
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/contrib/orgmanual.org b/contrib/orgmanual.org
index 6cc88a86e..e184fb51d 100644
--- a/contrib/orgmanual.org
+++ b/contrib/orgmanual.org
@@ -6253,6 +6253,10 @@ but you can specify your own function using the ~:formatter~ parameter.
 
   Indent each headline field according to its level.
 
+- :hidefiles ::
+
+  Hide the file column when multiple files are used to produced the table.
+
 - :tcolumns ::   
 
   Number of columns to be used for times.  If this is smaller than
diff --git a/doc/org.texi b/doc/org.texi
index a74f967f5..2c2f8d0cc 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6689,6 +6689,7 @@ but you can specify your own function using the @code{:formatter} parameter.
              @r{the org table.  If you write it like @samp{50!}, then the}
              @r{headline will also be shortened in export.}
 :indent      @r{Indent each headline field according to its level.}
+:hidefiles   @r{Hide file column when multiple files are parsed.}
 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
 :level       @r{Should a level number column be included?}
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6b967c673..05c46e18c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -298,6 +298,7 @@ string as argument."
    :link nil
    :narrow '40!
    :indent t
+   :hidefiles nil
    :formula nil
    :timestamp nil
    :level nil
@@ -2391,6 +2392,7 @@ the currently selected interval size."
 	   (ws (plist-get params :wstart))
 	   (ms (plist-get params :mstart))
 	   (step (plist-get params :step))
+	   (hide-files (plist-get params :hidefiles))
 	   (formatter (or (plist-get params :formatter)
 			  org-clock-clocktable-formatter
 			  'org-clocktable-write-default))
@@ -2445,7 +2447,8 @@ the currently selected interval size."
 	     ;; Even though `file-with-archives' can consist of
 	     ;; multiple files, we consider this is one extended file
 	     ;; instead.
-	     (and (consp files) (not (eq scope 'file-with-archives)))))
+	     (and (not hide-files)
+		  (consp files) (not (eq scope 'file-with-archives)))))
 
 	(funcall formatter
 		 origin
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 61ec5fad4..a92b44cb2 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -374,8 +374,9 @@ Complete a language in the first field, the header arguments and switches."
 			   ":tstart" ":tend" ":block" ":step"
 			   ":stepskip0" ":fileskip0"
 			   ":emphasize" ":link" ":narrow" ":indent"
-			   ":tcolumns" ":level" ":compact" ":timestamp"
-			   ":formula" ":formatter" ":wstart" ":mstart"))))
+			   ":hidefiles" ":tcolumns" ":level" ":compact"
+			   ":timestamp" ":formula" ":formatter"
+			   ":wstart" ":mstart"))))
 
 (defun org-pcomplete-case-double (list)
   "Return list with both upcase and downcase version of all strings in LIST."
-- 
2.14.1


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

* Re: [Patch] Hide the file column in a clock report.
  2017-09-02  9:14   ` Michaël Cadilhac
@ 2017-09-03  1:11     ` Adam Porter
  2017-09-03  8:15     ` Nicolas Goaziou
  1 sibling, 0 replies; 7+ messages in thread
From: Adam Porter @ 2017-09-03  1:11 UTC (permalink / raw)
  To: emacs-orgmode

Michaël Cadilhac <michael@cadilhac.name> writes:

> While I definitely agree that question form is weird, I copied it from
> the ":level" option (arguably without thinking twice) which reads:
>
> :level       @r{Should a level number column be included?}
>
> In any case, let's not repeat that oddity :-)  I've changed the patch
> according to your suggestion.

Oops, I didn't see that.  Good call.  :)

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

* Re: [Patch] Hide the file column in a clock report.
  2017-09-02  9:14   ` Michaël Cadilhac
  2017-09-03  1:11     ` Adam Porter
@ 2017-09-03  8:15     ` Nicolas Goaziou
  2019-08-28 23:25       ` Michaël Cadilhac
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2017-09-03  8:15 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Adam Porter, emacs-orgmode

Hello,

Michaël Cadilhac <michael@cadilhac.name> writes:

> From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
> Date: Thu, 31 Aug 2017 19:37:55 +0100
> Subject: [PATCH] Add the option of hiding the file column in a clock
> report

Thank you.

We are in feature-freeze phase, but it can go in master once Org 9.1 is
released.

Could you provide tests in "test-org-clock.el"? This can be named
"test-org-clock/clocktable/hidefiles". There are examples in the file.

Regards,

-- 
Nicolas Goaziou

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

* Re: [Patch] Hide the file column in a clock report.
  2017-09-03  8:15     ` Nicolas Goaziou
@ 2019-08-28 23:25       ` Michaël Cadilhac
  2019-09-05 16:58         ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Michaël Cadilhac @ 2019-08-28 23:25 UTC (permalink / raw)
  Cc: emacs-orgmode


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

Here attached.  Let me know if that's all good!

Cheers,
M.

On Sun, 3 Sep 2017 at 03:15, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Hello,
>
> Michaël Cadilhac <michael@cadilhac.name> writes:
>
> > From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
> > Date: Thu, 31 Aug 2017 19:37:55 +0100
> > Subject: [PATCH] Add the option of hiding the file column in a clock
> > report
>
> Thank you.
>
> We are in feature-freeze phase, but it can go in master once Org 9.1 is
> released.
>
> Could you provide tests in "test-org-clock.el"? This can be named
> "test-org-clock/clocktable/hidefiles". There are examples in the file.
>
> Regards,
>
> --
> Nicolas Goaziou
>

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

[-- Attachment #2: 0001-org-clock.el-Add-an-option-to-not-show-the-file-colu.patch --]
[-- Type: text/x-patch, Size: 2175 bytes --]

From 77006082d020f26147e9412e10d07a9a2ac50cb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
Date: Sun, 10 Mar 2019 19:05:10 +0000
Subject: [PATCH 1/3] org-clock.el: Add an option to not show the file column
 in clock report

* lisp/org-clock.el (org-clocktable-defaults): Add `hidefiles'.
(org-dblock-write:clocktable): Implement not showing files when
`hidefiles' is true.
* lisp/org-pcomplete.el: Add `hidefiles'.
---
 lisp/org-clock.el     | 5 ++++-
 lisp/org-pcomplete.el | 5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index bf9053ec2..8af59e705 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -304,6 +304,7 @@ string as argument."
    :link nil
    :narrow '40!
    :indent t
+   :hidefiles nil
    :formula nil
    :timestamp nil
    :level nil
@@ -2391,6 +2392,7 @@ the currently selected interval size."
 	   (ws (plist-get params :wstart))
 	   (ms (plist-get params :mstart))
 	   (step (plist-get params :step))
+	   (hide-files (plist-get params :hidefiles))
 	   (formatter (or (plist-get params :formatter)
 			  org-clock-clocktable-formatter
 			  'org-clocktable-write-default))
@@ -2445,7 +2447,8 @@ the currently selected interval size."
 	     ;; Even though `file-with-archives' can consist of
 	     ;; multiple files, we consider this is one extended file
 	     ;; instead.
-	     (and (consp files) (not (eq scope 'file-with-archives)))))
+	     (and (not hide-files)
+		  (consp files) (not (eq scope 'file-with-archives)))))
 
 	(funcall formatter
 		 origin
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 70a8173d8..9e68c7dc1 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -430,8 +430,9 @@ switches."
 			   ":tstart" ":tend" ":block" ":step"
 			   ":stepskip0" ":fileskip0"
 			   ":emphasize" ":link" ":narrow" ":indent"
-			   ":tcolumns" ":level" ":compact" ":timestamp"
-			   ":formula" ":formatter" ":wstart" ":mstart"))))
+			   ":hidefiles" ":tcolumns" ":level" ":compact"
+			   ":timestamp" ":formula" ":formatter"
+			   ":wstart" ":mstart"))))
 
 \f
 ;;; Finish up
-- 
2.22.0


[-- Attachment #3: 0002-Add-test-for-the-hidefiles-parameter-in-clocktables.patch --]
[-- Type: text/x-patch, Size: 1542 bytes --]

From a8e4d713e7c9d6a3ad0b5d0e3244c685bbef2163 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
Date: Wed, 28 Aug 2019 18:15:40 -0500
Subject: [PATCH 2/3] Add test for the hidefiles parameter in clocktables.

* testing/lisp/test-org-clock.el (test-org-clock/clocktable/hidefiles):
Add test.
---
 testing/lisp/test-org-clock.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index fa336f680..ad75a2ba5 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -1175,6 +1175,23 @@ CLOCK: [2017-10-02 Mon 11:00]--[2017-10-02 Mon 13:00] =>  2:00"
               (test-org-clock-clocktable-contents
                ":step week :block 2017-10 :stepskip0 t"))))))
 
+(ert-deftest test-org-clock/clocktable/hidefiles ()
+  "Test \":hidefiles\" parameter in Clock table."
+  ;; Test that hidefiles removes the file column.
+  (should
+   (equal
+    "| Headline     | Time   |
+|--------------+--------|
+| *Total time* | *1:00* |
+|--------------+--------|
+| Test         | 1:00   |"
+    (org-test-with-temp-text-in-file
+        "* Test
+CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] =>  1:00"
+      (let ((the-file (buffer-file-name)))
+        (org-test-with-temp-text-in-file ""
+          (test-org-clock-clocktable-contents
+           (format ":hidefiles t :scope (lambda () (list %S))" the-file))))))))
 
 (provide 'test-org-clock)
 ;;; test-org-clock.el end here
-- 
2.22.0


[-- Attachment #4: 0003-Document-hidefiles-in-clocktable.patch --]
[-- Type: text/x-patch, Size: 799 bytes --]

From cc6744a089199a913cd602539990097c5fe691e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
Date: Wed, 28 Aug 2019 18:22:46 -0500
Subject: [PATCH 3/3] Document :hidefiles in clocktable

* doc/org-manual.org (The clock table): Do it.
---
 doc/org-manual.org | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f964b81e2..d81a722ba 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -6638,6 +6638,11 @@ using the =:formatter= parameter.
 
   Indent each headline field according to its level.
 
+- =:hidefiles= ::
+
+  Hide the file column when multiple files are used to produce the
+  table.
+
 - =:tcolumns= ::
 
   Number of columns to be used for times.  If this is smaller than
-- 
2.22.0


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

* Re: [Patch] Hide the file column in a clock report.
  2019-08-28 23:25       ` Michaël Cadilhac
@ 2019-09-05 16:58         ` Nicolas Goaziou
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2019-09-05 16:58 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-orgmode

Hello,

Michaël Cadilhac <michael@cadilhac.name> writes:

> Here attached.  Let me know if that's all good!

It is. Applied. Could you provide an ORG-NEWS entry?

Thank you!

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2019-09-05 16:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31 18:44 [Patch] Hide the file column in a clock report Michaël Cadilhac
2017-09-02  2:20 ` Adam Porter
2017-09-02  9:14   ` Michaël Cadilhac
2017-09-03  1:11     ` Adam Porter
2017-09-03  8:15     ` Nicolas Goaziou
2019-08-28 23:25       ` Michaël Cadilhac
2019-09-05 16:58         ` Nicolas Goaziou

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