|
@@ -171,7 +171,8 @@ This is the compiled version of the format.")
|
|
|
string (format f (or modval val)))
|
|
|
;; Create the overlay
|
|
|
(org-unmodified
|
|
|
- (setq ov (org-columns-new-overlay beg (setq beg (1+ beg)) string face))
|
|
|
+ (setq ov (org-columns-new-overlay
|
|
|
+ beg (setq beg (1+ beg)) string face))
|
|
|
(org-overlay-put ov 'keymap org-columns-map)
|
|
|
(org-overlay-put ov 'org-columns-key property)
|
|
|
(org-overlay-put ov 'org-columns-value (cdr ass))
|
|
@@ -290,6 +291,7 @@ This is the compiled version of the format.")
|
|
|
(let ((inhibit-read-only t))
|
|
|
(remove-text-properties (point-min) (point-max) '(read-only t))))
|
|
|
(when (eq major-mode 'org-agenda-mode)
|
|
|
+ (setq org-agenda-columns-active nil)
|
|
|
(message
|
|
|
"Modification not yet reflected in Agenda buffer, use `r' to refresh")))
|
|
|
|
|
@@ -370,7 +372,8 @@ Where possible, use the standard interface for changing this line."
|
|
|
(setq eval '(org-entry-put pom key nval)))))
|
|
|
(when eval
|
|
|
(let ((inhibit-read-only t))
|
|
|
- (remove-text-properties (max (point-min) (1- bol)) eol '(read-only t))
|
|
|
+ (org-unmodified
|
|
|
+ (remove-text-properties (max (point-min) (1- bol)) eol '(read-only t)))
|
|
|
(unwind-protect
|
|
|
(progn
|
|
|
(setq org-columns-overlays
|
|
@@ -482,9 +485,12 @@ Where possible, use the standard interface for changing this line."
|
|
|
(org-columns-eval '(org-entry-put pom key nval)))
|
|
|
(org-columns-display-here)))
|
|
|
(move-to-column col)
|
|
|
- (if (and (org-mode-p)
|
|
|
- (nth 3 (assoc key org-columns-current-fmt-compiled)))
|
|
|
- (org-columns-update key))))
|
|
|
+ (cond
|
|
|
+ ((equal major-mode 'org-agenda-mode)
|
|
|
+ (org-agenda-redo))
|
|
|
+ ((and (org-mode-p)
|
|
|
+ (nth 3 (assoc key org-columns-current-fmt-compiled)))
|
|
|
+ (org-columns-update key)))))
|
|
|
|
|
|
(defun org-verify-version (task)
|
|
|
(cond
|
|
@@ -667,131 +673,6 @@ display, or in the #+COLUMNS line of the current buffer."
|
|
|
|
|
|
(defvar org-overriding-columns-format nil
|
|
|
"When set, overrides any other definition.")
|
|
|
-(defvar org-agenda-view-columns-initially nil
|
|
|
- "When set, switch to columns view immediately after creating the agenda.")
|
|
|
-
|
|
|
-(defvar org-agenda-columns-show-summaries) ; defined in org-agenda.el
|
|
|
-(defun org-agenda-columns ()
|
|
|
- "Turn on column view in the agenda."
|
|
|
- (interactive)
|
|
|
- (org-verify-version 'columns)
|
|
|
- (org-columns-remove-overlays)
|
|
|
- (move-marker org-columns-begin-marker (point))
|
|
|
- (let (fmt cache maxwidths m)
|
|
|
- (cond
|
|
|
- ((and (local-variable-p 'org-overriding-columns-format)
|
|
|
- org-overriding-columns-format)
|
|
|
- (setq fmt org-overriding-columns-format))
|
|
|
- ((setq m (get-text-property (point-at-bol) 'org-hd-marker))
|
|
|
- (setq fmt (or (org-entry-get m "COLUMNS" t)
|
|
|
- (with-current-buffer (marker-buffer m)
|
|
|
- org-columns-default-format))))
|
|
|
- ((and (boundp 'org-columns-current-fmt)
|
|
|
- (local-variable-p 'org-columns-current-fmt)
|
|
|
- org-columns-current-fmt)
|
|
|
- (setq fmt org-columns-current-fmt))
|
|
|
- ((setq m (next-single-property-change (point-min) 'org-hd-marker))
|
|
|
- (setq m (get-text-property m 'org-hd-marker))
|
|
|
- (setq fmt (or (org-entry-get m "COLUMNS" t)
|
|
|
- (with-current-buffer (marker-buffer m)
|
|
|
- org-columns-default-format)))))
|
|
|
- (setq fmt (or fmt org-columns-default-format))
|
|
|
- (org-set-local 'org-columns-current-fmt fmt)
|
|
|
- (org-columns-compile-format fmt)
|
|
|
- (org-agenda-colview-compute org-columns-current-fmt-compiled)
|
|
|
- (save-excursion
|
|
|
- ;; Get and cache the properties
|
|
|
- (goto-char (point-min))
|
|
|
- (while (not (eobp))
|
|
|
- (when (setq m (or (get-text-property (point) 'org-hd-marker)
|
|
|
- (get-text-property (point) 'org-marker)))
|
|
|
- (push (cons (org-current-line) (org-entry-properties m)) cache))
|
|
|
- (beginning-of-line 2))
|
|
|
- (when cache
|
|
|
- (setq maxwidths (org-columns-get-autowidth-alist fmt cache))
|
|
|
- (org-set-local 'org-columns-current-maxwidths maxwidths)
|
|
|
- (org-columns-display-here-title)
|
|
|
- (mapc (lambda (x)
|
|
|
- (goto-line (car x))
|
|
|
- (org-columns-display-here (cdr x)))
|
|
|
- cache)
|
|
|
- (when org-agenda-columns-show-summaries
|
|
|
- (org-agenda-colview-summarize cache))))))
|
|
|
-
|
|
|
-(defun org-agenda-colview-summarize (cache)
|
|
|
- "Summarize the summarizable columns in column view in the agenda.
|
|
|
-This will add overlays to the date lines, to show the summary for each day."
|
|
|
- (let* ((fmt (mapcar (lambda (x)
|
|
|
- (list (car x) (if (equal (car x) "CLOCKSUM")
|
|
|
- 'add_times (nth 4 x))))
|
|
|
- org-columns-current-fmt-compiled))
|
|
|
- line c c1 stype props lsum entries prop v)
|
|
|
- (when (delq nil (mapcar 'cadr fmt))
|
|
|
- ;; OK, at least one summation column, it makes sense to try this
|
|
|
- (goto-char (point-max))
|
|
|
- (while (not (bobp))
|
|
|
- (if (not (or (get-text-property (point) 'org-date-line)
|
|
|
- (eq (get-text-property (point) 'face)
|
|
|
- 'org-agenda-structure)))
|
|
|
- (beginning-of-line 0)
|
|
|
- ;; OK, this is a date line
|
|
|
- (setq line (org-current-line))
|
|
|
- (setq entries nil c cache cache nil)
|
|
|
- (while (setq c1 (pop c))
|
|
|
- (if (> (car c1) line)
|
|
|
- (push c1 entries)
|
|
|
- (push c1 cache)))
|
|
|
- ;; now ENTRIES are the ones we want to use, CACHE is the rest
|
|
|
- ;; Compute the summaries for the properties we want,
|
|
|
- ;; set nil properties for the rest.
|
|
|
- (when (setq entries (mapcar 'cdr entries))
|
|
|
- (setq props
|
|
|
- (mapcar
|
|
|
- (lambda (f)
|
|
|
- (setq prop (car f) stype (nth 1 f))
|
|
|
- (cond
|
|
|
- ((equal prop "ITEM")
|
|
|
- (cons prop (buffer-substring (point-at-bol)
|
|
|
- (point-at-eol))))
|
|
|
- ((not stype) (cons prop ""))
|
|
|
- (t
|
|
|
- ;; do the summary
|
|
|
- (setq lsum 0)
|
|
|
- (mapc (lambda (x)
|
|
|
- (setq v (cdr (assoc prop x)))
|
|
|
- (if v (setq lsum (+ lsum
|
|
|
- (org-column-string-to-number
|
|
|
- v stype)))))
|
|
|
- entries)
|
|
|
- (cons prop (org-columns-number-to-string lsum stype)))))
|
|
|
- fmt))
|
|
|
- (org-columns-display-here props)
|
|
|
- (org-set-local 'org-agenda-columns-active t))
|
|
|
- (beginning-of-line 0))))))
|
|
|
-
|
|
|
-(defvar org-agenda-columns-compute-summary-properties); defined in org-agenda.el
|
|
|
-(defun org-agenda-colview-compute (fmt)
|
|
|
- "Compute the relevant columns in the contributing source buffers."
|
|
|
- (when org-agenda-columns-compute-summary-properties
|
|
|
- (let ((files org-agenda-contributing-files)
|
|
|
- (org-columns-begin-marker (make-marker))
|
|
|
- (org-columns-top-level-marker (make-marker))
|
|
|
- f fm a b)
|
|
|
- (while (setq f (pop files))
|
|
|
- (setq b (find-buffer-visiting f))
|
|
|
- (with-current-buffer (or (buffer-base-buffer b) b)
|
|
|
- (save-excursion
|
|
|
- (save-restriction
|
|
|
- (goto-char (point-min))
|
|
|
- (org-columns-get-format-and-top-level)
|
|
|
- (while (setq fm (pop fmt))
|
|
|
- (if (equal (car fm) "CLOCKSUM")
|
|
|
- (org-clock-sum)
|
|
|
- (when (and (nth 4 fm)
|
|
|
- (setq a (assoc (car fm)
|
|
|
- org-columns-current-fmt-compiled))
|
|
|
- (equal (nth 4 a) (nth 4 fm)))
|
|
|
- (org-columns-compute (car fm))))))))))))
|
|
|
|
|
|
(defun org-columns-get-autowidth-alist (s cache)
|
|
|
"Derive the maximum column widths from the format and the cache."
|
|
@@ -875,7 +756,7 @@ This will add overlays to the date lines, to show the summary for each day."
|
|
|
(org-unmodified
|
|
|
(add-text-properties sumpos (1+ sumpos)
|
|
|
(list 'org-summaries sum-alist))))
|
|
|
- (when val
|
|
|
+ (when (and val (not (equal val (if flag str val))))
|
|
|
(org-entry-put nil property (if flag str val)))
|
|
|
;; add current to current level accumulator
|
|
|
(when (or flag valflag)
|
|
@@ -1144,6 +1025,152 @@ and tailing newline characters."
|
|
|
(org-create-dblock defaults)
|
|
|
(org-update-dblock)))
|
|
|
|
|
|
+;;; Column view in the agenda
|
|
|
+
|
|
|
+(defvar org-agenda-view-columns-initially nil
|
|
|
+ "When set, switch to columns view immediately after creating the agenda.")
|
|
|
+
|
|
|
+(defvar org-agenda-columns-show-summaries) ; defined in org-agenda.el
|
|
|
+
|
|
|
+(defun org-agenda-columns ()
|
|
|
+ "Turn on column view in the agenda."
|
|
|
+ (interactive)
|
|
|
+ (org-verify-version 'columns)
|
|
|
+ (org-columns-remove-overlays)
|
|
|
+ (move-marker org-columns-begin-marker (point))
|
|
|
+ (let (fmt cache maxwidths m p a)
|
|
|
+ (cond
|
|
|
+ ((and (local-variable-p 'org-overriding-columns-format)
|
|
|
+ org-overriding-columns-format)
|
|
|
+ (setq fmt org-overriding-columns-format))
|
|
|
+ ((setq m (get-text-property (point-at-bol) 'org-hd-marker))
|
|
|
+ (setq fmt (or (org-entry-get m "COLUMNS" t)
|
|
|
+ (with-current-buffer (marker-buffer m)
|
|
|
+ org-columns-default-format))))
|
|
|
+ ((and (boundp 'org-columns-current-fmt)
|
|
|
+ (local-variable-p 'org-columns-current-fmt)
|
|
|
+ org-columns-current-fmt)
|
|
|
+ (setq fmt org-columns-current-fmt))
|
|
|
+ ((setq m (next-single-property-change (point-min) 'org-hd-marker))
|
|
|
+ (setq m (get-text-property m 'org-hd-marker))
|
|
|
+ (setq fmt (or (org-entry-get m "COLUMNS" t)
|
|
|
+ (with-current-buffer (marker-buffer m)
|
|
|
+ org-columns-default-format)))))
|
|
|
+ (setq fmt (or fmt org-columns-default-format))
|
|
|
+ (org-set-local 'org-columns-current-fmt fmt)
|
|
|
+ (org-columns-compile-format fmt)
|
|
|
+ (org-agenda-colview-compute org-columns-current-fmt-compiled)
|
|
|
+ (save-excursion
|
|
|
+ ;; Get and cache the properties
|
|
|
+ (goto-char (point-min))
|
|
|
+ (while (not (eobp))
|
|
|
+ (when (setq m (or (get-text-property (point) 'org-hd-marker)
|
|
|
+ (get-text-property (point) 'org-marker)))
|
|
|
+ (setq p (org-entry-properties m))
|
|
|
+
|
|
|
+ (when (or (not (setq a (assoc org-time-estimates-property p)))
|
|
|
+ (not (string-match "\\S-" (or (cdr a) ""))))
|
|
|
+ ;; OK, no property gives us a value
|
|
|
+ (when (and org-time-estimate-include-appointments
|
|
|
+ (setq d (get-text-property (point) 'duration)))
|
|
|
+ (setq d (org-minutes-to-hours d))
|
|
|
+ (put-text-property 0 (length d) 'face 'org-warning d)
|
|
|
+ (push (cons org-time-estimates-property d) p)))
|
|
|
+ (push (cons (org-current-line) p) cache))
|
|
|
+ (beginning-of-line 2))
|
|
|
+ (when cache
|
|
|
+ (setq maxwidths (org-columns-get-autowidth-alist fmt cache))
|
|
|
+ (org-set-local 'org-columns-current-maxwidths maxwidths)
|
|
|
+ (org-columns-display-here-title)
|
|
|
+ (mapc (lambda (x)
|
|
|
+ (goto-line (car x))
|
|
|
+ (org-columns-display-here (cdr x)))
|
|
|
+ cache)
|
|
|
+ (when org-agenda-columns-show-summaries
|
|
|
+ (org-agenda-colview-summarize cache))))))
|
|
|
+
|
|
|
+(defun org-agenda-colview-summarize (cache)
|
|
|
+ "Summarize the summarizable columns in column view in the agenda.
|
|
|
+This will add overlays to the date lines, to show the summary for each day."
|
|
|
+ (let* ((fmt (mapcar (lambda (x)
|
|
|
+ (list (car x) (if (equal (car x) "CLOCKSUM")
|
|
|
+ 'add_times (nth 4 x))))
|
|
|
+ org-columns-current-fmt-compiled))
|
|
|
+ line c c1 stype props lsum entries prop v)
|
|
|
+ (when (delq nil (mapcar 'cadr fmt))
|
|
|
+ ;; OK, at least one summation column, it makes sense to try this
|
|
|
+ (goto-char (point-max))
|
|
|
+ (while (not (bobp))
|
|
|
+ (if (not (or (get-text-property (point) 'org-date-line)
|
|
|
+ (eq (get-text-property (point) 'face)
|
|
|
+ 'org-agenda-structure)))
|
|
|
+ (beginning-of-line 0)
|
|
|
+ ;; OK, this is a date line
|
|
|
+ (setq line (org-current-line))
|
|
|
+ (setq entries nil c cache cache nil)
|
|
|
+ (while (setq c1 (pop c))
|
|
|
+ (if (> (car c1) line)
|
|
|
+ (push c1 entries)
|
|
|
+ (push c1 cache)))
|
|
|
+ ;; now ENTRIES are the ones we want to use, CACHE is the rest
|
|
|
+ ;; Compute the summaries for the properties we want,
|
|
|
+ ;; set nil properties for the rest.
|
|
|
+ (when (setq entries (mapcar 'cdr entries))
|
|
|
+ (setq props
|
|
|
+ (mapcar
|
|
|
+ (lambda (f)
|
|
|
+ (setq prop (car f) stype (nth 1 f))
|
|
|
+ (cond
|
|
|
+ ((equal prop "ITEM")
|
|
|
+ (cons prop (buffer-substring (point-at-bol)
|
|
|
+ (point-at-eol))))
|
|
|
+ ((not stype) (cons prop ""))
|
|
|
+ (t
|
|
|
+ ;; do the summary
|
|
|
+ (setq lsum 0)
|
|
|
+ (mapc (lambda (x)
|
|
|
+ (setq v (cdr (assoc prop x)))
|
|
|
+ (if v (setq lsum (+ lsum
|
|
|
+ (org-column-string-to-number
|
|
|
+ v stype)))))
|
|
|
+ entries)
|
|
|
+ (setq lsum (org-columns-number-to-string lsum stype))
|
|
|
+ (put-text-property
|
|
|
+ 0 (length lsum) 'face 'bold lsum)
|
|
|
+ (cons prop lsum))))
|
|
|
+ fmt))
|
|
|
+ (org-columns-display-here props)
|
|
|
+ (org-set-local 'org-agenda-columns-active t))
|
|
|
+ (beginning-of-line 0))))))
|
|
|
+
|
|
|
+(defvar org-agenda-columns-compute-summary-properties); defined in org-agenda.el
|
|
|
+(defun org-agenda-colview-compute (fmt)
|
|
|
+ "Compute the relevant columns in the contributing source buffers."
|
|
|
+ (when org-agenda-columns-compute-summary-properties
|
|
|
+ (let ((files org-agenda-contributing-files)
|
|
|
+ (org-columns-begin-marker (make-marker))
|
|
|
+ (org-columns-top-level-marker (make-marker))
|
|
|
+ f fm a b)
|
|
|
+ (while (setq f (pop files))
|
|
|
+ (setq b (find-buffer-visiting f))
|
|
|
+ (with-current-buffer (or (buffer-base-buffer b) b)
|
|
|
+ (save-excursion
|
|
|
+ (save-restriction
|
|
|
+ (widen)
|
|
|
+ (org-unmodified
|
|
|
+ (remove-text-properties (point-min) (point-max)
|
|
|
+ '(org-summaries t)))
|
|
|
+ (goto-char (point-min))
|
|
|
+ (org-columns-get-format-and-top-level)
|
|
|
+ (while (setq fm (pop fmt))
|
|
|
+ (if (equal (car fm) "CLOCKSUM")
|
|
|
+ (org-clock-sum)
|
|
|
+ (when (and (nth 4 fm)
|
|
|
+ (setq a (assoc (car fm)
|
|
|
+ org-columns-current-fmt-compiled))
|
|
|
+ (equal (nth 4 a) (nth 4 fm)))
|
|
|
+ (org-columns-compute (car fm))))))))))))
|
|
|
+
|
|
|
(provide 'org-colview)
|
|
|
|
|
|
;;; org-colview.el ends here
|