From 2edd05eaac6c62ce76572c469415602e6de94cda Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 17 Aug 2011 16:56:27 +0200 Subject: [PATCH] org-colview: Clean up items in agenda mode too. * org-colview.el (org-columns-display-here): Clean up items in org-agenda-mode too. (org-columns-cleanup-item): Take a new argument CPHR to allow passing a complex heading regexp. Rewrite to cleanup ITEM correctly in `org-agenda-mode'. Thanks to Christian Schmidt for pointing at this problem. --- lisp/org-colview.el | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 2ad5f9561..f0585193c 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -209,9 +209,9 @@ This is the compiled version of the format.") (funcall org-columns-modify-value-for-display-function title val)) ((equal property "ITEM") - (if (org-mode-p) - (org-columns-cleanup-item - val org-columns-current-fmt-compiled))) + (org-columns-cleanup-item + val org-columns-current-fmt-compiled + (or org-complex-heading-regexp cphr))) ((and calc (functionp calc) (not (string= val "")) (not (get-text-property 0 'org-computed val))) @@ -341,24 +341,28 @@ for the duration of the command.") (when (local-variable-p 'org-colview-initial-truncate-line-value) (setq truncate-lines org-colview-initial-truncate-line-value))))) -(defun org-columns-cleanup-item (item fmt) - "Remove from ITEM what is a column in the format FMT." - (if (not org-complex-heading-regexp) - item - (when (string-match org-complex-heading-regexp item) - (setq item - (concat - (org-add-props (match-string 1 item) nil - 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1)))))) - (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item))) - (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item))) - " " (save-match-data (org-columns-compact-links (match-string 4 item))) - (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item))))) - (add-text-properties - 0 (1+ (match-end 1)) - (list 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1)))))) - item) - item))) +(defun org-columns-cleanup-item (item fmt cphr) + "Remove from ITEM what is a column in the format FMT. +CPHR is the complex heading regexp to use for parsing ITEM." + (let (fixitem) + (if (not cphr) + item + (unless (string-match "\*+ " item) + (setq item (concat "* " item) fixitem t)) + (if (string-match cphr item) + (setq item + (concat + (org-add-props (match-string 1 item) nil + 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1)))))) + (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item))) + (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item))) + " " (save-match-data (org-columns-compact-links (match-string 4 item))) + (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item))))) + (add-text-properties + 0 (1+ (match-end 1)) + (list 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1)))))) + item) + (if fixitem (replace-regexp-in-string "^\*+ " "" item) item))))) (defun org-columns-compact-links (s) "Replace [[link][desc]] with [desc] or [link]." -- 2.11.4.GIT