org-colview: Fix `org-agenda-overriding-columns-format'

* lisp/org-colview.el (org-columns--collect-values): Change signature.
(org-agenda-columns): Apply signature change.

When calling `org-agenda-columns' compiled columns format is set
locally to Agenda buffer, but `org-columns--collect-values' is called
from source buffers.  Therefore, it uses default format instead of the
compiled one.

Reported-by: Christian Prothmann <ckprothmann@yahoo.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/110748>
This commit is contained in:
Nicolas Goaziou 2016-12-11 01:34:55 +01:00
parent 00ea6a286c
commit d777418ac6

View file

@ -239,17 +239,15 @@ display, as a string."
(org-columns-compact-links value))) (org-columns-compact-links value)))
(value))) (value)))
(defun org-columns--collect-values (&optional agenda) (defun org-columns--collect-values (&optional compiled-fmt)
"Collect values for columns on the current line. "Collect values for columns on the current line.
When optional argument AGENDA is non-nil, assume the value is
meant for the agenda, i.e., caller is `org-agenda-columns'.
Return a list of triplets (SPEC VALUE DISPLAYED) suitable for Return a list of triplets (SPEC VALUE DISPLAYED) suitable for
`org-columns--display-here'. `org-columns--display-here'.
This function assumes `org-columns-current-fmt-compiled' is This function assumes `org-columns-current-fmt-compiled' is
initialized." initialized is set in the current buffer. However, it is
possible to override it with optional argument COMPILED-FMT."
(let ((summaries (get-text-property (point) 'org-summaries))) (let ((summaries (get-text-property (point) 'org-summaries)))
(mapcar (mapcar
(lambda (spec) (lambda (spec)
@ -257,19 +255,18 @@ initialized."
(`(,p . ,_) (`(,p . ,_)
(let* ((v (or (cdr (assoc spec summaries)) (let* ((v (or (cdr (assoc spec summaries))
(org-entry-get (point) p 'selective t) (org-entry-get (point) p 'selective t)
(and agenda (and compiled-fmt ;assume `org-agenda-columns'
;; Effort property is not defined. Try ;; Effort property is not defined. Try
;; to use appointment duration. ;; to use appointment duration.
org-agenda-columns-add-appointments-to-effort-sum org-agenda-columns-add-appointments-to-effort-sum
(string= p (upcase org-effort-property)) (string= p (upcase org-effort-property))
(get-text-property (point) 'duration) (get-text-property (point) 'duration)
(propertize (propertize (org-minutes-to-clocksum-string
(org-minutes-to-clocksum-string (get-text-property (point) 'duration))
(get-text-property (point) 'duration)) 'face 'org-warning))
'face 'org-warning))
""))) "")))
(list spec v (org-columns--displayed-value spec v)))))) (list spec v (org-columns--displayed-value spec v))))))
org-columns-current-fmt-compiled))) (or compiled-fmt org-columns-current-fmt-compiled))))
(defun org-columns--set-widths (cache) (defun org-columns--set-widths (cache)
"Compute the maximum column widths from the format and CACHE. "Compute the maximum column widths from the format and CACHE.
@ -1507,26 +1504,26 @@ PARAMS is a property list of parameters:
(interactive) (interactive)
(org-columns-remove-overlays) (org-columns-remove-overlays)
(move-marker org-columns-begin-marker (point)) (move-marker org-columns-begin-marker (point))
(let ((org-columns--time (float-time (current-time))) (let* ((org-columns--time (float-time (current-time)))
(fmt (fmt
(cond (cond
((bound-and-true-p org-agenda-overriding-columns-format)) ((bound-and-true-p org-agenda-overriding-columns-format))
((let ((m (org-get-at-bol 'org-hd-marker))) ((let ((m (org-get-at-bol 'org-hd-marker)))
(and m (and m
(or (org-entry-get m "COLUMNS" t) (or (org-entry-get m "COLUMNS" t)
(with-current-buffer (marker-buffer m) (with-current-buffer (marker-buffer m)
org-columns-default-format))))) org-columns-default-format)))))
((and (local-variable-p 'org-columns-current-fmt) ((and (local-variable-p 'org-columns-current-fmt)
org-columns-current-fmt)) org-columns-current-fmt))
((let ((m (next-single-property-change (point-min) 'org-hd-marker))) ((let ((m (next-single-property-change (point-min) 'org-hd-marker)))
(and m (and m
(let ((m (get-text-property m 'org-hd-marker))) (let ((m (get-text-property m 'org-hd-marker)))
(or (org-entry-get m "COLUMNS" t) (or (org-entry-get m "COLUMNS" t)
(with-current-buffer (marker-buffer m) (with-current-buffer (marker-buffer m)
org-columns-default-format)))))) org-columns-default-format))))))
(t org-columns-default-format)))) (t org-columns-default-format)))
(setq-local org-columns-current-fmt fmt) (compiled-fmt (org-columns-compile-format fmt)))
(org-columns-compile-format fmt) (setq org-columns-current-fmt fmt)
(when org-agenda-columns-compute-summary-properties (when org-agenda-columns-compute-summary-properties
(org-agenda-colview-compute org-columns-current-fmt-compiled)) (org-agenda-colview-compute org-columns-current-fmt-compiled))
(save-excursion (save-excursion
@ -1538,8 +1535,13 @@ PARAMS is a property list of parameters:
(org-get-at-bol 'org-marker)))) (org-get-at-bol 'org-marker))))
(when m (when m
(push (cons (line-beginning-position) (push (cons (line-beginning-position)
;; `org-columns-current-fmt-compiled' is
;; initialized but only set locally to the
;; agenda buffer. Since current buffer is
;; changing, we need to force the original
;; compiled-fmt there.
(org-with-point-at m (org-with-point-at m
(org-columns--collect-values 'agenda))) (org-columns--collect-values compiled-fmt)))
cache))) cache)))
(forward-line)) (forward-line))
(when cache (when cache