emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] 9.0.6 and clock tables


From: Rainer Stengele
Subject: Re: [O] 9.0.6 and clock tables
Date: Fri, 12 May 2017 16:41:19 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

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 <address@hidden
<mailto:address@hidden>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]