all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rainer Stengele <rainer.stengele@online.de>
To: Roland Everaert <reveatwork@gmail.com>,
	Eric S Fraga <e.fraga@ucl.ac.uk>,
	emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: 9.0.6 and clock tables
Date: Fri, 12 May 2017 16:41:19 +0200	[thread overview]
Message-ID: <ab0a477e-4bae-c9b6-37d8-3fdbac9ecd74@online.de> (raw)
In-Reply-To: <CACdPZ9LStHRXFYZLgDbGK-=Ksjjdt9h5nYyj9+7OTesKTVgG7A@mail.gmail.com>

Am 08.05.2017 um 12:31 schrieb Roland Everaert:
> I just see this.
>
> Since this morning my clocktable doesn't fill a column related to a
> property, any known issue and workaround/fix for this?
>
>
> Regards,
>
> On Mon, May 8, 2017 at 10:37 AM, Eric S Fraga <e.fraga@ucl.ac.uk
> <mailto:e.fraga@ucl.ac.uk>> wrote:
>
>     On Sunday,  7 May 2017 at 10:16, Nicolas Goaziou wrote:
>     > Would you happen to have any news on it?
>
>     Had no time but ...
>
>     > BTW, you may need to remove any TBLFM: entry related to % since
>     this is
>     > no longer necessary when using :formula %.
>
>     ... removing the existing TBLFM line fixes the problem!  Many thanks!
>
>     --
>     : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50, Org
>     release_9.0.6-407-gc28ec3
>
>
Hi,

I have a wrong clock summary in my agenda and also in clock tables since 
9.0.6. Also the clock sum format suddenly includes days instead of only 
hours as before.

I have a function overriding the agenda clocktable report - see below.
What has changed in terms of clock time sum?
It seems this section is no more working as before:

  (format org-clock-total-time-cell-format
	     (org-minutes-to-clocksum-string (or total-time 0)))

org-minutes-to-clocksum-string simply contains "*%s*"

Please advise.

Thank you.
Regards, Rainer



(defun rst/org-clocktable-write-default (ipos tables params)
   "Write out a clock table at position IPOS in the current buffer.
TABLES is a list of tables with clocking data as produced by
`org-clock-get-table-data'.  PARAMS is the parameter property list obtained
from the dynamic block definition."
   ;; This function looks quite complicated, mainly because there are a
   ;; lot of options which can add or remove columns.  I have massively
   ;; commented this function, the I hope it is understandable.  If
   ;; someone wants to write their own special formatter, this maybe
   ;; much easier because there can be a fixed format with a
   ;; well-defined number of columns...
   (let* ((hlchars '((1 . "*") (2 . "/")))
	 (lwords (assoc (or (plist-get params :lang)
			    (org-bound-and-true-p org-export-default-language)
			    "en")
			org-clock-clocktable-language-setup))
	 (multifile (plist-get params :multifile))
	 (block (plist-get params :block))
	 (sort (plist-get params :sort))
	 (ts (plist-get params :tstart))
	 (te (plist-get params :tend))
	 (header (plist-get  params :header))
	 (narrow (plist-get params :narrow))
	 (ws (or (plist-get params :wstart) 1))
	 (ms (or (plist-get params :mstart) 1))
	 (link (plist-get params :link))
	 (maxlevel (or (plist-get params :maxlevel) 3))
	 (emph (plist-get params :emphasize))
	 (level-p (plist-get params :level))
	 (org-time-clocksum-use-effort-durations
	  (plist-get params :effort-durations))
	 (timestamp (plist-get params :timestamp))
	 (properties (plist-get params :properties))
	 (ntcol (max 1 (or (plist-get params :tcolumns) 100)))
	 (rm-file-column (plist-get params :one-file-with-archives))
	 (indent (plist-get params :indent))
	 (case-fold-search t)
	 range-text total-time tbl level hlc formula pcol
	 file-time entries entry headline
	 recalc content narrow-cut-p tcol)

     ;; Some consistency test for parameters
     (unless (integerp ntcol)
       (setq params (plist-put params :tcolumns (setq ntcol 100))))

     (when block
       ;; Get the range text for the header
       (setq range-text (nth 2 (org-clock-special-range block nil t ws 
ms))))

     ;; Compute the total time
     (setq total-time (apply '+ (mapcar 'cadr tables)))

     ;; Now we need to output this tsuff
     (goto-char ipos)

     ;; Insert the text *before* the actual table
     (insert-before-markers
      (or header
	 ;; Format the standard header
	 (concat
	  "#+CAPTION: "
	  (nth 9 lwords) " ["
	  (substring
	   (format-time-string (cdr org-time-stamp-formats))
	   1 -1)
	  "]"
	  (if block (concat ", for " range-text ".") "")
	  "\n")))


     ;; Insert the table header line
     (insert-before-markers
      "|"				; table line starter
      ;; (if multifile (concat (nth 1 lwords) "|") "") ; file column, maybe
      (if level-p   (concat (nth 2 lwords) "|") "") ; level column, maybe
      (if timestamp (concat (nth 3 lwords) "|") "") ; timestamp column, 
maybe
      (if properties (concat (mapconcat 'identity properties "|") "|") 
"") ;properties columns, maybe
      ;; (concat (nth 4 lwords) "|"
      (concat
	     (nth 5 lwords) "|\n"))	; headline and time columns


     ;; Insert the total time in the table
     (insert-before-markers
      ;; "|-\n"				; a hline
      ;; "\n"				; a hline

      "|"				; table line starter
      ;; (if multifile (concat "| " (nth 6 lwords) " ") "")
					; file column, maybe
      (if level-p   "|"      "")		; level column, maybe
      (if timestamp "|"      "")		; timestamp column, maybe
      (if properties (make-string (length properties) ?|) "") ; 
properties columns, maybe
      ;; (concat (format org-clock-total-time-cell-format (nth 7 
lwords))  "| ") ; instead of a headline
      (format org-clock-total-time-cell-format
	     (org-minutes-to-clocksum-string (or total-time 0))) ; the time
      "|\n")				; close line

     ;; Now iterate over the tables and insert the data
     ;; but only if any time has been collected
     (when (and total-time (> total-time 0))

       (while (setq tbl (pop tables))
	;; now tbl is the table resulting from one file.
	(setq file-time (nth 1 tbl))
	(when (or (and file-time (> file-time 0))
		  (not (plist-get params :fileskip0)))
	  (insert-before-markers "|-\n") ; a hline because a new file starts
	  ;; First the file time, if we have multiple files
	  (when (and nil multifile)
	    ;; Summarize the time collected from this file
	    (insert-before-markers
					; (format (concat "| %s %s | %s%s"
	     (format (concat "| %s | %s%s"
			     (format org-clock-file-time-cell-format (nth 8 lwords))
			     " | *%s*|\n")
		     ; (file-name-nondirectory (car tbl))
		     (if level-p   "| " "") ; level column, maybe
		     (if timestamp "| " "") ; timestamp column, maybe
		     (if properties (make-string (length properties) ?|) "") 
;properties columns, maybe
		     (org-minutes-to-clocksum-string (nth 1 tbl))))) ; the time

	  ;; Get the list of node entries and iterate over it
	  (setq entries (nth 2 tbl))
	  (while (setq entry (pop entries))
	    (setq level (car entry)
		  headline (nth 1 entry)
		  hlc (if emph (or (cdr (assoc level hlchars)) "") ""))
	    (when narrow-cut-p
	      (if (and (string-match (concat "\\`" org-bracket-link-regexp
					     "\\'")
				     headline)
		       (match-end 3))
		  (setq headline
			(format "[[%s][%s]]"
				(match-string 1 headline)
				(org-shorten-string (match-string 3 headline)
						    narrow)))
		(setq headline (org-shorten-string headline narrow))))
	    (insert-before-markers
	     "|"		    ; start the table line
	     ;; (if multifile "|" "")  ; free space for file name column?
	     (if level-p (format "%d|" (car entry)) "")	; level, maybe
	     (if timestamp (concat (nth 2 entry) "|") "") ; timestamp, maybe
	     (if properties
		 (concat
		  (mapconcat
		   (lambda (p) (or (cdr (assoc p (nth 4 entry))) ""))
		   properties "|") "|") "") ;properties columns, maybe
	     (if indent (org-clocktable-indent-string level) "") ; indentation
	     ;; hlc headline hlc "|"	; headline
	     (make-string (min (1- ntcol) (or (- level 1))) ?|)
					; empty fields for higher levels
	     hlc (org-minutes-to-clocksum-string (nth 3 entry)) hlc ; time
	     "|\n"			; close line
	     )))))
     ;; When exporting subtrees or regions the region might be
     ;; activated, so let's disable ̀delete-active-region'
     (let ((delete-active-region nil)) (backward-delete-char 1))

     ;; Back to beginning, align the table, recalculate if necessary
     (goto-char ipos)
     (skip-chars-forward "^|")
     (org-table-align)
     (when org-hide-emphasis-markers
       ;; we need to align a second time
       (org-table-align))
     (when sort
       (save-excursion
	(org-table-goto-line 3)
	(org-table-goto-column (car sort))
	(org-table-sort-lines nil (cdr sort))))
     (when recalc
       (if (eq formula '%)
	  (save-excursion
	    (if (and narrow (not narrow-cut-p)) (beginning-of-line 2))
	    (org-table-goto-column pcol nil 'force)
	    (insert "%")))
       (org-table-recalculate 'all))
     (when rm-file-column
       ;; The file column is actually not wanted
       (forward-char 1)
       (org-table-delete-column))
     total-time))

  reply	other threads:[~2017-05-12 14:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 19:12 9.0.6 and clock tables Eric S Fraga
2017-05-07 10:16 ` Nicolas Goaziou
     [not found] ` <be8d3f2cb33b4709844ed24f43da4bec@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-05-08  8:37   ` Eric S Fraga
2017-05-08 10:31     ` Roland Everaert
2017-05-12 14:41       ` Rainer Stengele [this message]
2017-05-12 15:23         ` Nicolas Goaziou
2017-05-15  6:57           ` Rainer Stengele
2017-05-15 11:35             ` 9.0.6 and clock tables -> solved Rainer Stengele
2017-05-12 15:24       ` 9.0.6 and clock tables Nicolas Goaziou

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab0a477e-4bae-c9b6-37d8-3fdbac9ecd74@online.de \
    --to=rainer.stengele@online.de \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=reveatwork@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.