org-colview.el 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586
  1. ;;; org-colview.el --- Column View in Org -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
  3. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; Homepage: http://orgmode.org
  6. ;;
  7. ;; This file is part of GNU Emacs.
  8. ;;
  9. ;; GNU Emacs is free software: you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation, either version 3 of the License, or
  12. ;; (at your option) any later version.
  13. ;; GNU Emacs is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ;;
  21. ;;; Commentary:
  22. ;; This file contains the column view for Org.
  23. ;;; Code:
  24. (require 'cl-lib)
  25. (require 'org)
  26. (declare-function org-agenda-redo "org-agenda" ())
  27. (declare-function org-agenda-do-context-action "org-agenda" ())
  28. (declare-function org-clock-sum-today "org-clock" (&optional headline-filter))
  29. (declare-function org-element-extract-element "org-element" (element))
  30. (declare-function org-element-interpret-data "org-element" (data))
  31. (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
  32. (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
  33. (declare-function org-element-restriction "org-element" (element))
  34. (defvar org-agenda-columns-add-appointments-to-effort-sum)
  35. (defvar org-agenda-columns-compute-summary-properties)
  36. (defvar org-agenda-columns-show-summaries)
  37. (defvar org-agenda-view-columns-initially)
  38. (defvar org-inlinetask-min-level)
  39. ;;; Configuration
  40. (defcustom org-columns-modify-value-for-display-function nil
  41. "Function that modifies values for display in column view.
  42. For example, it can be used to cut out a certain part from a time stamp.
  43. The function must take 2 arguments:
  44. column-title The title of the column (*not* the property name)
  45. value The value that should be modified.
  46. The function should return the value that should be displayed,
  47. or nil if the normal value should be used."
  48. :group 'org-properties
  49. :type '(choice (const nil) (function)))
  50. ;;; Column View
  51. (defvar org-columns-overlays nil
  52. "Holds the list of current column overlays.")
  53. (defvar org-columns--time 0.0
  54. "Number of seconds since the epoch, as a floating point number.")
  55. (defvar-local org-columns-current-fmt nil
  56. "Local variable, holds the currently active column format.")
  57. (defvar-local org-columns-current-fmt-compiled nil
  58. "Local variable, holds the currently active column format.
  59. This is the compiled version of the format.")
  60. (defvar-local org-columns-current-maxwidths nil
  61. "Loval variable, holds the currently active maximum column widths.")
  62. (defvar org-columns-begin-marker (make-marker)
  63. "Points to the position where last a column creation command was called.")
  64. (defvar org-columns-top-level-marker (make-marker)
  65. "Points to the position where current columns region starts.")
  66. (defvar org-columns-map (make-sparse-keymap)
  67. "The keymap valid in column display.")
  68. (defconst org-columns-compile-map
  69. '(("+" . org-columns--summary-sum)
  70. ("$" . org-columns--summary-currencies)
  71. ("X" . org-columns--summary-checkbox)
  72. ("X/" . org-columns--summary-checkbox-count)
  73. ("X%" . org-columns--summary-checkbox-percent)
  74. ("max" . org-columns--summary-max)
  75. ("mean" . org-columns--summary-mean)
  76. ("min" . org-columns--summary-min)
  77. (":" . org-columns--summary-sum-times)
  78. (":max" . org-columns--summary-max-time)
  79. (":mean" . org-columns--summary-mean-time)
  80. (":min" . org-columns--summary-min-time)
  81. ("@max" . org-columns--summary-max-age)
  82. ("@mean" . org-columns--summary-mean-age)
  83. ("@min" . org-columns--summary-min-age)
  84. ("est+" . org-columns--summary-estimate))
  85. "Map operators to summarize functions.
  86. Used to compile/uncompile columns format and completing read in
  87. interactive function `org-columns-new'.
  88. operator string used in #+COLUMNS definition describing the
  89. summary type
  90. function called with a list of values as argument to calculate
  91. the summary value")
  92. (defun org-columns-content ()
  93. "Switch to contents view while in columns view."
  94. (interactive)
  95. (org-overview)
  96. (org-content))
  97. (org-defkey org-columns-map "c" 'org-columns-content)
  98. (org-defkey org-columns-map "o" 'org-overview)
  99. (org-defkey org-columns-map "e" 'org-columns-edit-value)
  100. (org-defkey org-columns-map "\C-c\C-t" 'org-columns-todo)
  101. (org-defkey org-columns-map "\C-c\C-c" 'org-columns-set-tags-or-toggle)
  102. (org-defkey org-columns-map "\C-c\C-o" 'org-columns-open-link)
  103. (org-defkey org-columns-map "v" 'org-columns-show-value)
  104. (org-defkey org-columns-map "q" 'org-columns-quit)
  105. (org-defkey org-columns-map "r" 'org-columns-redo)
  106. (org-defkey org-columns-map "g" 'org-columns-redo)
  107. (org-defkey org-columns-map [left] 'backward-char)
  108. (org-defkey org-columns-map "\M-b" 'backward-char)
  109. (org-defkey org-columns-map "a" 'org-columns-edit-allowed)
  110. (org-defkey org-columns-map "s" 'org-columns-edit-attributes)
  111. (org-defkey org-columns-map "\M-f"
  112. (lambda () (interactive) (goto-char (1+ (point)))))
  113. (org-defkey org-columns-map [right]
  114. (lambda () (interactive) (goto-char (1+ (point)))))
  115. (org-defkey org-columns-map [down]
  116. (lambda () (interactive)
  117. (let ((col (current-column)))
  118. (beginning-of-line 2)
  119. (while (and (org-invisible-p2) (not (eobp)))
  120. (beginning-of-line 2))
  121. (move-to-column col)
  122. (if (eq major-mode 'org-agenda-mode)
  123. (org-agenda-do-context-action)))))
  124. (org-defkey org-columns-map [up]
  125. (lambda () (interactive)
  126. (let ((col (current-column)))
  127. (beginning-of-line 0)
  128. (while (and (org-invisible-p2) (not (bobp)))
  129. (beginning-of-line 0))
  130. (move-to-column col)
  131. (if (eq major-mode 'org-agenda-mode)
  132. (org-agenda-do-context-action)))))
  133. (org-defkey org-columns-map [(shift right)] 'org-columns-next-allowed-value)
  134. (org-defkey org-columns-map "n" 'org-columns-next-allowed-value)
  135. (org-defkey org-columns-map [(shift left)] 'org-columns-previous-allowed-value)
  136. (org-defkey org-columns-map "p" 'org-columns-previous-allowed-value)
  137. (org-defkey org-columns-map "<" 'org-columns-narrow)
  138. (org-defkey org-columns-map ">" 'org-columns-widen)
  139. (org-defkey org-columns-map [(meta right)] 'org-columns-move-right)
  140. (org-defkey org-columns-map [(meta left)] 'org-columns-move-left)
  141. (org-defkey org-columns-map [(shift meta right)] 'org-columns-new)
  142. (org-defkey org-columns-map [(shift meta left)] 'org-columns-delete)
  143. (dotimes (i 10)
  144. (org-defkey org-columns-map (number-to-string i)
  145. `(lambda () (interactive)
  146. (org-columns-next-allowed-value nil ,i))))
  147. (easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
  148. '("Column"
  149. ["Edit property" org-columns-edit-value t]
  150. ["Next allowed value" org-columns-next-allowed-value t]
  151. ["Previous allowed value" org-columns-previous-allowed-value t]
  152. ["Show full value" org-columns-show-value t]
  153. ["Edit allowed values" org-columns-edit-allowed t]
  154. "--"
  155. ["Edit column attributes" org-columns-edit-attributes t]
  156. ["Increase column width" org-columns-widen t]
  157. ["Decrease column width" org-columns-narrow t]
  158. "--"
  159. ["Move column right" org-columns-move-right t]
  160. ["Move column left" org-columns-move-left t]
  161. ["Add column" org-columns-new t]
  162. ["Delete column" org-columns-delete t]
  163. "--"
  164. ["CONTENTS" org-columns-content t]
  165. ["OVERVIEW" org-overview t]
  166. ["Refresh columns display" org-columns-redo t]
  167. "--"
  168. ["Open link" org-columns-open-link t]
  169. "--"
  170. ["Quit" org-columns-quit t]))
  171. (defun org-columns--displayed-value (property value)
  172. "Return displayed value for PROPERTY in current entry.
  173. VALUE is the real value of the property, as a string.
  174. This function assumes `org-columns-current-fmt-compiled' is
  175. initialized."
  176. (cond
  177. ((and (functionp org-columns-modify-value-for-display-function)
  178. (funcall
  179. org-columns-modify-value-for-display-function
  180. (nth 1 (assoc-string property org-columns-current-fmt-compiled t))
  181. value)))
  182. ((equal (upcase property) "ITEM")
  183. (concat (make-string (1- (org-current-level))
  184. (if org-hide-leading-stars ?\s ?*))
  185. "* "
  186. (org-columns-compact-links value)))
  187. (value)))
  188. (defun org-columns--collect-values (&optional agenda)
  189. "Collect values for columns on the current line.
  190. When optional argument AGENDA is non-nil, assume the value is
  191. meant for the agenda, i.e., caller is `org-agenda-columns'.
  192. Return a list of triplets (PROPERTY VALUE DISPLAYED) suitable for
  193. `org-columns--display-here'.
  194. This function assumes `org-columns-current-fmt-compiled' is
  195. initialized."
  196. (mapcar
  197. (lambda (spec)
  198. (let* ((p (car spec))
  199. (v (or (cdr (assoc-string
  200. p (get-text-property (point) 'org-summaries) t))
  201. (org-entry-get (point) p 'selective t)
  202. (and agenda
  203. ;; Effort property is not defined. Try to use
  204. ;; appointment duration.
  205. org-agenda-columns-add-appointments-to-effort-sum
  206. (string= (upcase p) (upcase org-effort-property))
  207. (get-text-property (point) 'duration)
  208. (org-propertize
  209. (org-minutes-to-clocksum-string
  210. (get-text-property (point) 'duration))
  211. 'face 'org-warning))
  212. "")))
  213. (list p v (org-columns--displayed-value p v))))
  214. org-columns-current-fmt-compiled))
  215. (defun org-columns--autowidth-alist (cache)
  216. "Derive the maximum column widths from the format and the cache.
  217. Return an alist (PROPERTY . WIDTH), with PROPERTY as a string and
  218. WIDTH as an integer greater than 0."
  219. (mapcar
  220. (lambda (spec)
  221. (pcase spec
  222. (`(,property ,name ,width . ,_)
  223. (if width (cons property width)
  224. ;; No width is specified in the columns format. Compute it
  225. ;; by checking all possible values for PROPERTY.
  226. (let ((width (length name)))
  227. (dolist (entry cache (cons property width))
  228. (let ((value (nth 2 (assoc-string property (cdr entry) t))))
  229. (setq width (max (length value) width)))))))))
  230. org-columns-current-fmt-compiled))
  231. (defun org-columns-new-overlay (beg end &optional string face)
  232. "Create a new column overlay and add it to the list."
  233. (let ((ov (make-overlay beg end)))
  234. (overlay-put ov 'face (or face 'secondary-selection))
  235. (org-overlay-display ov string face)
  236. (push ov org-columns-overlays)
  237. ov))
  238. (defun org-columns--overlay-text (value fmt width property original)
  239. "Return text "
  240. (format fmt
  241. (let ((v (org-columns-add-ellipses value width)))
  242. (pcase (upcase property)
  243. ("PRIORITY"
  244. (propertize v 'face (org-get-priority-face original)))
  245. ("TAGS"
  246. (if (not org-tags-special-faces-re)
  247. (propertize v 'face 'org-tag)
  248. (replace-regexp-in-string
  249. org-tags-special-faces-re
  250. (lambda (m) (propertize m 'face (org-get-tag-face m)))
  251. v nil nil 1)))
  252. ("TODO" (propertize v 'face (org-get-todo-face original)))
  253. (_ v)))))
  254. (defun org-columns--display-here (columns &optional dateline)
  255. "Overlay the current line with column display.
  256. COLUMNS is an alist (PROPERTY VALUE DISPLAYED). Optional
  257. argument DATELINE is non-nil when the face used should be
  258. `org-agenda-column-dateline'."
  259. (save-excursion
  260. (beginning-of-line)
  261. (let* ((level-face (and (looking-at "\\(\\**\\)\\(\\* \\)")
  262. (org-get-level-face 2)))
  263. (ref-face (or level-face
  264. (and (eq major-mode 'org-agenda-mode)
  265. (org-get-at-bol 'face))
  266. 'default))
  267. (color (list :foreground (face-attribute ref-face :foreground)))
  268. (font (list :height (face-attribute 'default :height)
  269. :family (face-attribute 'default :family)))
  270. (face (list color font 'org-column ref-face))
  271. (face1 (list color font 'org-agenda-column-dateline ref-face)))
  272. ;; Each column is an overlay on top of a character. So there has
  273. ;; to be at least as many characters available on the line as
  274. ;; columns to display.
  275. (let ((columns (length org-columns-current-fmt-compiled))
  276. (chars (- (line-end-position) (line-beginning-position))))
  277. (when (> columns chars)
  278. (save-excursion
  279. (end-of-line)
  280. (let ((inhibit-read-only t))
  281. (insert (make-string (- columns chars) ?\s))))))
  282. ;; Display columns. Create and install the overlay for the
  283. ;; current column on the next character.
  284. (let ((limit (+ (- (length columns) 1) (line-beginning-position))))
  285. (dolist (column columns)
  286. (pcase column
  287. (`(,property ,original ,value)
  288. (let* ((width
  289. (cdr
  290. (assoc-string property org-columns-current-maxwidths t)))
  291. (fmt (format (if (= (point) limit) "%%-%d.%ds |"
  292. "%%-%d.%ds | ")
  293. width width))
  294. (ov (org-columns-new-overlay
  295. (point) (1+ (point))
  296. (org-columns--overlay-text
  297. value fmt width property original)
  298. (if dateline face1 face))))
  299. (overlay-put ov 'keymap org-columns-map)
  300. (overlay-put ov 'org-columns-key property)
  301. (overlay-put ov 'org-columns-value original)
  302. (overlay-put ov 'org-columns-value-modified value)
  303. (overlay-put ov 'org-columns-format fmt)
  304. (overlay-put ov 'line-prefix "")
  305. (overlay-put ov 'wrap-prefix "")
  306. (forward-char))))))
  307. ;; Make the rest of the line disappear.
  308. (let ((ov (org-columns-new-overlay (point) (line-end-position))))
  309. (overlay-put ov 'invisible t)
  310. (overlay-put ov 'keymap org-columns-map)
  311. (overlay-put ov 'line-prefix "")
  312. (overlay-put ov 'wrap-prefix ""))
  313. (let ((ov (make-overlay (1- (line-end-position))
  314. (line-beginning-position 2))))
  315. (overlay-put ov 'keymap org-columns-map)
  316. (push ov org-columns-overlays))
  317. (org-with-silent-modifications
  318. (let ((inhibit-read-only t))
  319. (put-text-property
  320. (line-end-position 0)
  321. (line-beginning-position 2)
  322. 'read-only
  323. (substitute-command-keys
  324. "Type \\<org-columns-map>\\[org-columns-edit-value] \
  325. to edit property")))))))
  326. (defun org-columns-add-ellipses (string width)
  327. "Truncate STRING with WIDTH characters, with ellipses."
  328. (cond
  329. ((<= (length string) width) string)
  330. ((<= width (length org-columns-ellipses))
  331. (substring org-columns-ellipses 0 width))
  332. (t (concat (substring string 0 (- width (length org-columns-ellipses)))
  333. org-columns-ellipses))))
  334. (defvar org-columns-full-header-line-format nil
  335. "The full header line format, will be shifted by horizontal scrolling." )
  336. (defvar org-previous-header-line-format nil
  337. "The header line format before column view was turned on.")
  338. (defvar org-columns-inhibit-recalculation nil
  339. "Inhibit recomputing of columns on column view startup.")
  340. (defvar org-columns-flyspell-was-active nil
  341. "Remember the state of `flyspell-mode' before column view.
  342. Flyspell-mode can cause problems in columns view, so it is turned off
  343. for the duration of the command.")
  344. (defvar header-line-format)
  345. (defvar org-columns-previous-hscroll 0)
  346. (defun org-columns--display-here-title ()
  347. "Overlay the newline before the current line with the table title."
  348. (interactive)
  349. (let ((title ""))
  350. (dolist (column org-columns-current-fmt-compiled)
  351. (pcase column
  352. (`(,property ,name . ,_)
  353. (let* ((width
  354. (cdr (assoc-string property org-columns-current-maxwidths t)))
  355. (fmt (format "%%-%d.%ds | " width width)))
  356. (setq title (concat title (format fmt (or name property))))))))
  357. (setq-local org-previous-header-line-format header-line-format)
  358. (setq org-columns-full-header-line-format
  359. (concat
  360. (org-add-props " " nil 'display '(space :align-to 0))
  361. (org-add-props (substring title 0 -1) nil 'face 'org-column-title)))
  362. (setq org-columns-previous-hscroll -1)
  363. (org-add-hook 'post-command-hook 'org-columns-hscoll-title nil 'local)))
  364. (defun org-columns-hscoll-title ()
  365. "Set the `header-line-format' so that it scrolls along with the table."
  366. (sit-for .0001) ; need to force a redisplay to update window-hscroll
  367. (when (not (= (window-hscroll) org-columns-previous-hscroll))
  368. (setq header-line-format
  369. (concat (substring org-columns-full-header-line-format 0 1)
  370. (substring org-columns-full-header-line-format
  371. (1+ (window-hscroll))))
  372. org-columns-previous-hscroll (window-hscroll))
  373. (force-mode-line-update)))
  374. (defvar org-colview-initial-truncate-line-value nil
  375. "Remember the value of `truncate-lines' across colview.")
  376. ;;;###autoload
  377. (defun org-columns-remove-overlays ()
  378. "Remove all currently active column overlays."
  379. (interactive)
  380. (when (marker-buffer org-columns-begin-marker)
  381. (with-current-buffer (marker-buffer org-columns-begin-marker)
  382. (when (local-variable-p 'org-previous-header-line-format)
  383. (setq header-line-format org-previous-header-line-format)
  384. (kill-local-variable 'org-previous-header-line-format)
  385. (remove-hook 'post-command-hook 'org-columns-hscoll-title 'local))
  386. (move-marker org-columns-begin-marker nil)
  387. (move-marker org-columns-top-level-marker nil)
  388. (org-with-silent-modifications
  389. (mapc 'delete-overlay org-columns-overlays)
  390. (setq org-columns-overlays nil)
  391. (let ((inhibit-read-only t))
  392. (remove-text-properties (point-min) (point-max) '(read-only t))))
  393. (when org-columns-flyspell-was-active
  394. (flyspell-mode 1))
  395. (when (local-variable-p 'org-colview-initial-truncate-line-value)
  396. (setq truncate-lines org-colview-initial-truncate-line-value)))))
  397. (defun org-columns-compact-links (s)
  398. "Replace [[link][desc]] with [desc] or [link]."
  399. (while (string-match org-bracket-link-regexp s)
  400. (setq s (replace-match
  401. (concat "[" (match-string (if (match-end 3) 3 1) s) "]")
  402. t t s)))
  403. s)
  404. (defun org-columns-show-value ()
  405. "Show the full value of the property."
  406. (interactive)
  407. (let ((value (get-char-property (point) 'org-columns-value)))
  408. (message "Value is: %s" (or value ""))))
  409. (defvar org-agenda-columns-active) ;; defined in org-agenda.el
  410. (defun org-columns-quit ()
  411. "Remove the column overlays and in this way exit column editing."
  412. (interactive)
  413. (org-with-silent-modifications
  414. (org-columns-remove-overlays)
  415. (let ((inhibit-read-only t))
  416. (remove-text-properties (point-min) (point-max) '(read-only t))))
  417. (when (eq major-mode 'org-agenda-mode)
  418. (setq org-agenda-columns-active nil)
  419. (message
  420. "Modification not yet reflected in Agenda buffer, use `r' to refresh")))
  421. (defun org-columns-check-computed ()
  422. "Check if this column value is computed.
  423. If yes, throw an error indicating that changing it does not make sense."
  424. (let ((val (get-char-property (point) 'org-columns-value)))
  425. (when (and (stringp val)
  426. (get-char-property 0 'org-computed val))
  427. (error "This value is computed from the entry's children"))))
  428. (defun org-columns-todo (&optional _arg)
  429. "Change the TODO state during column view."
  430. (interactive "P")
  431. (org-columns-edit-value "TODO"))
  432. (defun org-columns-set-tags-or-toggle (&optional _arg)
  433. "Toggle checkbox at point, or set tags for current headline."
  434. (interactive "P")
  435. (if (string-match "\\`\\[[ xX-]\\]\\'"
  436. (get-char-property (point) 'org-columns-value))
  437. (org-columns-next-allowed-value)
  438. (org-columns-edit-value "TAGS")))
  439. (defvar org-agenda-overriding-columns-format nil
  440. "When set, overrides any other format definition for the agenda.
  441. Don't set this, this is meant for dynamic scoping.")
  442. (defun org-columns-edit-value (&optional key)
  443. "Edit the value of the property at point in column view.
  444. Where possible, use the standard interface for changing this line."
  445. (interactive)
  446. (org-columns-check-computed)
  447. (let* ((col (current-column))
  448. (key (or key (get-char-property (point) 'org-columns-key)))
  449. (value (get-char-property (point) 'org-columns-value))
  450. (bol (point-at-bol)) (eol (point-at-eol))
  451. (pom (or (get-text-property bol 'org-hd-marker)
  452. (point))) ; keep despite of compiler waring
  453. (org-columns--time (float-time (current-time)))
  454. nval eval allowed)
  455. (cond
  456. ((equal key "CLOCKSUM")
  457. (error "This special column cannot be edited"))
  458. ((equal key "ITEM")
  459. (setq eval `(org-with-point-at ,pom
  460. (org-edit-headline))))
  461. ((equal key "TODO")
  462. (setq eval `(org-with-point-at ,pom
  463. (call-interactively 'org-todo))))
  464. ((equal key "PRIORITY")
  465. (setq eval `(org-with-point-at ,pom
  466. (call-interactively 'org-priority))))
  467. ((equal key "TAGS")
  468. (setq eval `(org-with-point-at ,pom
  469. (let ((org-fast-tag-selection-single-key
  470. (if (eq org-fast-tag-selection-single-key 'expert)
  471. t org-fast-tag-selection-single-key)))
  472. (call-interactively 'org-set-tags)))))
  473. ((equal key "DEADLINE")
  474. (setq eval `(org-with-point-at ,pom
  475. (call-interactively 'org-deadline))))
  476. ((equal key "SCHEDULED")
  477. (setq eval `(org-with-point-at ,pom
  478. (call-interactively 'org-schedule))))
  479. ((equal key "BEAMER_env")
  480. (setq eval `(org-with-point-at ,pom
  481. (call-interactively 'org-beamer-select-environment))))
  482. (t
  483. (setq allowed (org-property-get-allowed-values pom key 'table))
  484. (if allowed
  485. (setq nval (completing-read
  486. "Value: " allowed nil
  487. (not (get-text-property 0 'org-unrestricted
  488. (caar allowed)))))
  489. (setq nval (read-string "Edit: " value)))
  490. (setq nval (org-trim nval))
  491. (when (not (equal nval value))
  492. (setq eval `(org-entry-put ,pom ,key ,nval)))))
  493. (when eval
  494. (cond
  495. ((equal major-mode 'org-agenda-mode)
  496. (org-columns-eval eval)
  497. ;; The following let preserves the current format, and makes sure
  498. ;; that in only a single file things need to be updated.
  499. (let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
  500. (buffer (marker-buffer pom))
  501. (org-agenda-contributing-files
  502. (list (with-current-buffer buffer
  503. (buffer-file-name (buffer-base-buffer))))))
  504. (org-agenda-columns)))
  505. (t
  506. (let ((inhibit-read-only t))
  507. (org-with-silent-modifications
  508. (remove-text-properties
  509. (max (point-min) (1- bol)) eol '(read-only t)))
  510. (org-columns-eval eval))
  511. (org-move-to-column col)
  512. (org-columns-update key))))))
  513. (defun org-edit-headline () ; FIXME: this is not columns specific. Make interactive????? Use from agenda????
  514. "Edit the current headline, the part without TODO keyword, TAGS."
  515. (org-back-to-heading)
  516. (when (looking-at org-todo-line-regexp)
  517. (let ((pos (point))
  518. (pre (buffer-substring (match-beginning 0) (match-beginning 3)))
  519. (txt (match-string 3))
  520. (post "")
  521. txt2)
  522. (if (string-match (org-re "[ \t]+:[[:alnum:]:_@#%]+:[ \t]*$") txt)
  523. (setq post (match-string 0 txt)
  524. txt (substring txt 0 (match-beginning 0))))
  525. (setq txt2 (read-string "Edit: " txt))
  526. (when (not (equal txt txt2))
  527. (goto-char pos)
  528. (insert pre txt2 post)
  529. (delete-region (point) (point-at-eol))
  530. (org-set-tags nil t)))))
  531. (defun org-columns-edit-allowed ()
  532. "Edit the list of allowed values for the current property."
  533. (interactive)
  534. (let* ((pom (or (org-get-at-bol 'org-marker)
  535. (org-get-at-bol 'org-hd-marker)
  536. (point)))
  537. (key (get-char-property (point) 'org-columns-key))
  538. (key1 (concat key "_ALL"))
  539. (allowed (org-entry-get pom key1 t))
  540. nval)
  541. ;; FIXME: Cover editing TODO, TAGS etc in-buffer settings.????
  542. ;; FIXME: Write back to #+PROPERTY setting if that is needed.
  543. (setq nval (read-string "Allowed: " allowed))
  544. (org-entry-put
  545. (cond ((marker-position org-entry-property-inherited-from)
  546. org-entry-property-inherited-from)
  547. ((marker-position org-columns-top-level-marker)
  548. org-columns-top-level-marker)
  549. (t pom))
  550. key1 nval)))
  551. (defun org-columns-eval (form)
  552. (let (hidep)
  553. (save-excursion
  554. (beginning-of-line 1)
  555. ;; `next-line' is needed here, because it skips invisible line.
  556. (condition-case nil (org-no-warnings (next-line 1)) (error nil))
  557. (setq hidep (org-at-heading-p 1)))
  558. (eval form)
  559. (and hidep (outline-hide-entry))))
  560. (defun org-columns-previous-allowed-value ()
  561. "Switch to the previous allowed value for this column."
  562. (interactive)
  563. (org-columns-next-allowed-value t))
  564. (defun org-columns-next-allowed-value (&optional previous nth)
  565. "Switch to the next allowed value for this column.
  566. When PREVIOUS is set, go to the previous value. When NTH is
  567. an integer, select that value."
  568. (interactive)
  569. (org-columns-check-computed)
  570. (let* ((col (current-column))
  571. (key (get-char-property (point) 'org-columns-key))
  572. (value (get-char-property (point) 'org-columns-value))
  573. (bol (point-at-bol)) (eol (point-at-eol))
  574. (pom (or (get-text-property bol 'org-hd-marker)
  575. (point))) ; keep despite of compiler waring
  576. (allowed
  577. (or (org-property-get-allowed-values pom key)
  578. (and (member (nth 3 (assoc-string key
  579. org-columns-current-fmt-compiled
  580. t))
  581. '("X" "X/" "X%"))
  582. '("[ ]" "[X]"))
  583. (org-colview-construct-allowed-dates value)))
  584. nval)
  585. (when (integerp nth)
  586. (setq nth (1- nth))
  587. (if (= nth -1) (setq nth 9)))
  588. (when (equal key "ITEM")
  589. (error "Cannot edit item headline from here"))
  590. (unless (or allowed (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM")))
  591. (error "Allowed values for this property have not been defined"))
  592. (if (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM"))
  593. (setq nval (if previous 'earlier 'later))
  594. (if previous (setq allowed (reverse allowed)))
  595. (cond
  596. (nth
  597. (setq nval (nth nth allowed))
  598. (if (not nval)
  599. (error "There are only %d allowed values for property `%s'"
  600. (length allowed) key)))
  601. ((member value allowed)
  602. (setq nval (or (car (cdr (member value allowed)))
  603. (car allowed)))
  604. (if (equal nval value)
  605. (error "Only one allowed value for this property")))
  606. (t (setq nval (car allowed)))))
  607. (cond
  608. ((equal major-mode 'org-agenda-mode)
  609. (org-columns-eval `(org-entry-put ,pom ,key ,nval))
  610. ;; The following let preserves the current format, and makes sure
  611. ;; that in only a single file things need to be updated.
  612. (let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
  613. (buffer (marker-buffer pom))
  614. (org-agenda-contributing-files
  615. (list (with-current-buffer buffer
  616. (buffer-file-name (buffer-base-buffer))))))
  617. (org-agenda-columns)))
  618. (t
  619. (let ((inhibit-read-only t))
  620. (remove-text-properties (max (1- bol) (point-min)) eol '(read-only t))
  621. (org-columns-eval `(org-entry-put ,pom ,key ,nval)))
  622. (org-move-to-column col)
  623. (org-columns-update key)))))
  624. (defun org-colview-construct-allowed-dates (s)
  625. "Construct a list of three dates around the date in S.
  626. This respects the format of the time stamp in S, active or non-active,
  627. and also including time or not. S must be just a time stamp, no text
  628. around it."
  629. (when (and s (string-match (concat "^" org-ts-regexp3 "$") s))
  630. (let* ((time (org-parse-time-string s 'nodefaults))
  631. (active (equal (string-to-char s) ?<))
  632. (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats))
  633. time-before time-after)
  634. (unless active (setq fmt (concat "[" (substring fmt 1 -1) "]")))
  635. (setf (car time) (or (car time) 0))
  636. (setf (nth 1 time) (or (nth 1 time) 0))
  637. (setf (nth 2 time) (or (nth 2 time) 0))
  638. (setq time-before (copy-sequence time))
  639. (setq time-after (copy-sequence time))
  640. (setf (nth 3 time-before) (1- (nth 3 time)))
  641. (setf (nth 3 time-after) (1+ (nth 3 time)))
  642. (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x)))
  643. (list time-before time time-after)))))
  644. (defun org-columns-open-link (&optional arg)
  645. (interactive "P")
  646. (let ((value (get-char-property (point) 'org-columns-value)))
  647. (org-open-link-from-string value arg)))
  648. ;;;###autoload
  649. (defun org-columns-get-format-and-top-level ()
  650. (let ((fmt (org-columns-get-format)))
  651. (org-columns-goto-top-level)
  652. fmt))
  653. (defun org-columns-get-format (&optional fmt-string)
  654. (interactive)
  655. (let (fmt-as-property fmt)
  656. (when (condition-case nil (org-back-to-heading) (error nil))
  657. (setq fmt-as-property (org-entry-get nil "COLUMNS" t)))
  658. (setq fmt (or fmt-string fmt-as-property org-columns-default-format))
  659. (setq-local org-columns-current-fmt fmt)
  660. (org-columns-compile-format fmt)
  661. fmt))
  662. (defun org-columns-goto-top-level ()
  663. "Move to the beginning of the column view area.
  664. Also sets `org-columns-top-level-marker' to the new position."
  665. (goto-char
  666. (move-marker
  667. org-columns-top-level-marker
  668. (cond ((org-before-first-heading-p) (point-min))
  669. ((org-entry-get nil "COLUMNS" t) org-entry-property-inherited-from)
  670. (t (org-back-to-heading) (point))))))
  671. ;;;###autoload
  672. (defun org-columns (&optional global columns-fmt-string)
  673. "Turn on column view on an Org mode file.
  674. Column view applies to the whole buffer if point is before the
  675. first headline. Otherwise, it applies to the first ancestor
  676. setting \"COLUMNS\" property. If there is none, it defaults to
  677. the current headline. With a \\[universal-argument] prefix \
  678. argument, turn on column
  679. view for the whole buffer unconditionally.
  680. When COLUMNS-FMT-STRING is non-nil, use it as the column format."
  681. (interactive "P")
  682. (org-columns-remove-overlays)
  683. (move-marker org-columns-begin-marker (point))
  684. (org-columns-goto-top-level)
  685. ;; Initialize `org-columns-current-fmt' and
  686. ;; `org-columns-current-fmt-compiled'.
  687. (let ((org-columns--time (float-time (current-time))))
  688. (org-columns-get-format columns-fmt-string)
  689. (unless org-columns-inhibit-recalculation (org-columns-compute-all))
  690. (save-excursion
  691. (save-restriction
  692. (when (and (not global) (org-at-heading-p))
  693. (narrow-to-region (point) (org-end-of-subtree t t)))
  694. (when (assoc-string "CLOCKSUM" org-columns-current-fmt-compiled t)
  695. (org-clock-sum))
  696. (when (assoc-string "CLOCKSUM_T" org-columns-current-fmt-compiled t)
  697. (org-clock-sum-today))
  698. (let ((cache
  699. ;; Collect contents of columns ahead of time so as to
  700. ;; compute their maximum width.
  701. (org-map-entries
  702. (lambda () (cons (point) (org-columns--collect-values)))
  703. nil nil (and org-columns-skip-archived-trees 'archive))))
  704. (when cache
  705. (setq-local org-columns-current-maxwidths
  706. (org-columns--autowidth-alist cache))
  707. (org-columns--display-here-title)
  708. (when (setq-local org-columns-flyspell-was-active
  709. (org-bound-and-true-p flyspell-mode))
  710. (flyspell-mode 0))
  711. (unless (local-variable-p 'org-colview-initial-truncate-line-value)
  712. (setq-local org-colview-initial-truncate-line-value
  713. truncate-lines))
  714. (setq truncate-lines t)
  715. (dolist (entry cache)
  716. (goto-char (car entry))
  717. (org-columns--display-here (cdr entry)))))))))
  718. (defun org-columns-new (&optional prop title width operator _f _p summarize)
  719. "Insert a new column, to the left of the current column."
  720. (interactive)
  721. (let* ((prop (or prop (completing-read
  722. "Property: "
  723. (mapcar #'list (org-buffer-property-keys t nil t)))))
  724. (title (or title
  725. (read-string (format "Column title [%s]: " prop) prop)))
  726. (width
  727. ;; WIDTH may be nil, but if PROP is provided, assume this is
  728. ;; the expected width.
  729. (if prop width
  730. ;; Use `read-string' instead of `read-number' to allow
  731. ;; empty width.
  732. (let ((w (read-string "Column width: ")))
  733. (and (org-string-nw-p w) (string-to-number w)))))
  734. (operator
  735. (or operator
  736. (org-string-nw-p
  737. (completing-read
  738. "Summary: "
  739. (mapcar (lambda (x) (list (car x))) org-columns-compile-map)
  740. nil t))))
  741. (summarize (or summarize
  742. (cdr (assoc operator org-columns-compile-map))))
  743. (edit (and prop
  744. (assoc-string prop org-columns-current-fmt-compiled t))))
  745. (if edit
  746. (progn
  747. (setcar edit prop)
  748. (setcdr edit (list title width nil operator nil summarize)))
  749. (let ((cell (nthcdr (1- (current-column))
  750. org-columns-current-fmt-compiled)))
  751. (push (list prop title width nil operator nil summarize) (cdr cell))))
  752. (org-columns-store-format)
  753. (org-columns-redo)))
  754. (defun org-columns-delete ()
  755. "Delete the column at point from columns view."
  756. (interactive)
  757. (let* ((n (current-column))
  758. (title (nth 1 (nth n org-columns-current-fmt-compiled))))
  759. (when (y-or-n-p
  760. (format "Are you sure you want to remove column \"%s\"? " title))
  761. (setq org-columns-current-fmt-compiled
  762. (delq (nth n org-columns-current-fmt-compiled)
  763. org-columns-current-fmt-compiled))
  764. (org-columns-store-format)
  765. (org-columns-redo)
  766. (if (>= (current-column) (length org-columns-current-fmt-compiled))
  767. (backward-char 1)))))
  768. (defun org-columns-edit-attributes ()
  769. "Edit the attributes of the current column."
  770. (interactive)
  771. (let* ((n (current-column))
  772. (info (nth n org-columns-current-fmt-compiled)))
  773. (apply 'org-columns-new info)))
  774. (defun org-columns-widen (arg)
  775. "Make the column wider by ARG characters."
  776. (interactive "p")
  777. (let* ((n (current-column))
  778. (entry (nth n org-columns-current-fmt-compiled))
  779. (width (or (nth 2 entry)
  780. (cdr (assoc-string (car entry)
  781. org-columns-current-maxwidths
  782. t)))))
  783. (setq width (max 1 (+ width arg)))
  784. (setcar (nthcdr 2 entry) width)
  785. (org-columns-store-format)
  786. (org-columns-redo)))
  787. (defun org-columns-narrow (arg)
  788. "Make the column narrower by ARG characters."
  789. (interactive "p")
  790. (org-columns-widen (- arg)))
  791. (defun org-columns-move-right ()
  792. "Swap this column with the one to the right."
  793. (interactive)
  794. (let* ((n (current-column))
  795. (cell (nthcdr n org-columns-current-fmt-compiled))
  796. e)
  797. (when (>= n (1- (length org-columns-current-fmt-compiled)))
  798. (error "Cannot shift this column further to the right"))
  799. (setq e (car cell))
  800. (setcar cell (car (cdr cell)))
  801. (setcdr cell (cons e (cdr (cdr cell))))
  802. (org-columns-store-format)
  803. (org-columns-redo)
  804. (forward-char 1)))
  805. (defun org-columns-move-left ()
  806. "Swap this column with the one to the left."
  807. (interactive)
  808. (let* ((n (current-column)))
  809. (when (= n 0)
  810. (error "Cannot shift this column further to the left"))
  811. (backward-char 1)
  812. (org-columns-move-right)
  813. (backward-char 1)))
  814. (defun org-columns-store-format ()
  815. "Store the text version of the current columns format in appropriate place.
  816. This is either in the COLUMNS property of the node starting the current column
  817. display, or in the #+COLUMNS line of the current buffer."
  818. (let (fmt (cnt 0))
  819. (setq fmt (org-columns-uncompile-format org-columns-current-fmt-compiled))
  820. (setq-local org-columns-current-fmt fmt)
  821. (if (marker-position org-columns-top-level-marker)
  822. (save-excursion
  823. (goto-char org-columns-top-level-marker)
  824. (if (and (org-at-heading-p)
  825. (org-entry-get nil "COLUMNS"))
  826. (org-entry-put nil "COLUMNS" fmt)
  827. (goto-char (point-min))
  828. ;; Overwrite all #+COLUMNS lines....
  829. (while (re-search-forward "^[ \t]*#\\+COLUMNS:.*" nil t)
  830. (setq cnt (1+ cnt))
  831. (replace-match (concat "#+COLUMNS: " fmt) t t))
  832. (unless (> cnt 0)
  833. (goto-char (point-min))
  834. (or (org-at-heading-p t) (outline-next-heading))
  835. (let ((inhibit-read-only t))
  836. (insert-before-markers "#+COLUMNS: " fmt "\n")))
  837. (setq-local org-columns-default-format fmt))))))
  838. (defun org-columns-update (property)
  839. "Recompute PROPERTY, and update the columns display for it."
  840. (org-columns-compute property)
  841. (org-with-wide-buffer
  842. (let ((p (upcase property)))
  843. (dolist (ov org-columns-overlays)
  844. (when (let ((key (overlay-get ov 'org-columns-key)))
  845. (and key (equal (upcase key) p) (overlay-start ov)))
  846. (goto-char (overlay-start ov))
  847. (let ((value (cdr
  848. (assoc-string
  849. property
  850. (get-text-property (line-beginning-position)
  851. 'org-summaries)
  852. t))))
  853. (when value
  854. (let ((displayed (org-columns--displayed-value property value))
  855. (format (overlay-get ov 'org-columns-format))
  856. (width (cdr (assoc-string property
  857. org-columns-current-maxwidths
  858. t))))
  859. (overlay-put ov 'org-columns-value value)
  860. (overlay-put ov 'org-columns-value-modified displayed)
  861. (overlay-put ov
  862. 'display
  863. (org-columns--overlay-text
  864. displayed format width property value))))))))))
  865. (defun org-columns-redo ()
  866. "Construct the column display again."
  867. (interactive)
  868. (message "Recomputing columns...")
  869. (let ((line (org-current-line))
  870. (col (current-column)))
  871. (save-excursion
  872. (if (marker-position org-columns-begin-marker)
  873. (goto-char org-columns-begin-marker))
  874. (org-columns-remove-overlays)
  875. (if (derived-mode-p 'org-mode)
  876. (call-interactively 'org-columns)
  877. (org-agenda-redo)
  878. (call-interactively 'org-agenda-columns)))
  879. (org-goto-line line)
  880. (move-to-column col))
  881. (message "Recomputing columns...done"))
  882. (defun org-columns-uncompile-format (compiled)
  883. "Turn the compiled columns format back into a string representation.
  884. COMPILED is an alist, as returned by
  885. `org-columns-compile-format', which see."
  886. (mapconcat
  887. (lambda (spec)
  888. (pcase spec
  889. (`(,prop ,title ,width ,op ,printf ,_)
  890. (concat "%"
  891. (and width (number-to-string width))
  892. prop
  893. (and title (not (equal prop title)) (format "(%s)" title))
  894. (cond ((not op) nil)
  895. (printf (format "{%s;%s}" op printf))
  896. (t (format "{%s}" op)))))))
  897. compiled " "))
  898. (defun org-columns-compile-format (fmt)
  899. "Turn a column format string FMT into an alist of specifications.
  900. The alist has one entry for each column in the format. The elements of
  901. that list are:
  902. property the property name
  903. title the title field for the columns
  904. width the column width in characters, can be nil for automatic
  905. operator the summary operator if any
  906. printf a printf format for computed values
  907. fun the lisp function to compute summary values, derived from operator
  908. This function updates `org-columns-current-fmt-compiled'."
  909. (setq org-columns-current-fmt-compiled nil)
  910. (let ((start 0))
  911. (while (string-match
  912. "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\
  913. \\(?:{\\([^}]+\\)}\\)?\\s-*"
  914. fmt start)
  915. (setq start (match-end 0))
  916. (let* ((width (and (match-end 1) (string-to-number (match-string 1 fmt))))
  917. (prop (match-string 2 fmt))
  918. (title (or (match-string 3 fmt) prop))
  919. (op (match-string 4 fmt))
  920. (printf nil)
  921. (fun '+))
  922. (when (and op (string-match ";" op))
  923. (setq printf (substring op (match-end 0)))
  924. (setq op (substring op 0 (match-beginning 0))))
  925. (let ((op-match (assoc op org-columns-compile-map)))
  926. (when op-match (setq fun (cdr op-match))))
  927. (push (list prop title width op printf fun)
  928. org-columns-current-fmt-compiled)))
  929. (setq org-columns-current-fmt-compiled
  930. (nreverse org-columns-current-fmt-compiled))))
  931. ;;;; Column View Summary
  932. (defconst org-columns--duration-re
  933. (concat "[0-9.]+ *" (regexp-opt (mapcar #'car org-effort-durations)))
  934. "Regexp matching a duration.")
  935. (defun org-columns--time-to-seconds (s)
  936. "Turn time string S into a number of seconds.
  937. A time is expressed as HH:MM, HH:MM:SS, or with units defined in
  938. `org-effort-durations'. Plain numbers are considered as hours."
  939. (cond
  940. ((string-match "\\([0-9]+\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?" s)
  941. (+ (* 3600 (string-to-number (match-string 1 s)))
  942. (* 60 (string-to-number (match-string 2 s)))
  943. (if (match-end 3) (string-to-number (match-string 3 s)) 0)))
  944. ((string-match-p org-columns--duration-re s)
  945. (* 60 (org-duration-string-to-minutes s)))
  946. (t (* 3600 (string-to-number s)))))
  947. (defun org-columns--age-to-seconds (s)
  948. "Turn age string S into a number of seconds.
  949. An age is either computed from a given time-stamp, or indicated
  950. as days/hours/minutes/seconds."
  951. (cond
  952. ((string-match-p org-ts-regexp s)
  953. (floor
  954. (- org-columns--time
  955. (float-time (apply #'encode-time (org-parse-time-string s))))))
  956. ;; Match own output for computations in upper levels.
  957. ((string-match "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" s)
  958. (+ (* 86400 (string-to-number (match-string 1 s)))
  959. (* 3600 (string-to-number (match-string 2 s)))
  960. (* 60 (string-to-number (match-string 3 s)))
  961. (string-to-number (match-string 4 s))))
  962. (t (user-error "Invalid age: %S" s))))
  963. (defun org-columns--summary-apply-times (fun times)
  964. "Apply FUN to time values TIMES.
  965. If TIMES contains any time value expressed as a duration, return
  966. the result as a duration. If it contains any H:M:S, use that
  967. format instead. Otherwise, use H:M format."
  968. (let* ((hms-flag nil)
  969. (duration-flag nil)
  970. (seconds
  971. (apply fun
  972. (mapcar
  973. (lambda (time)
  974. (cond
  975. (duration-flag)
  976. ((string-match-p org-columns--duration-re time)
  977. (setq duration-flag t))
  978. (hms-flag)
  979. ((string-match-p "\\`[0-9]+:[0-9]+:[0-9]+\\'" time)
  980. (setq hms-flag t)))
  981. (org-columns--time-to-seconds time))
  982. times))))
  983. (cond (duration-flag (org-minutes-to-clocksum-string (/ seconds 60.0)))
  984. (hms-flag (format-seconds "%h:%.2m:%.2s" seconds))
  985. (t (format-seconds "%h:%.2m" seconds)))))
  986. ;;;###autoload
  987. (defun org-columns-compute (property)
  988. "Summarize the values of property PROPERTY hierarchically."
  989. (interactive)
  990. (let* ((lmax (if (org-bound-and-true-p org-inlinetask-min-level)
  991. org-inlinetask-min-level
  992. 29)) ;Hard-code deepest level.
  993. (lvals (make-vector (1+ lmax) nil))
  994. (spec (assoc-string property org-columns-current-fmt-compiled t))
  995. (printf (nth 4 spec))
  996. (summarize (nth 5 spec))
  997. (level 0)
  998. (inminlevel lmax)
  999. (last-level lmax))
  1000. (org-with-wide-buffer
  1001. ;; Find the region to compute.
  1002. (goto-char org-columns-top-level-marker)
  1003. (goto-char (condition-case nil (org-end-of-subtree t) (error (point-max))))
  1004. ;; Walk the tree from the back and do the computations.
  1005. (while (re-search-backward
  1006. org-outline-regexp-bol org-columns-top-level-marker t)
  1007. (unless (or (= level 0) (eq level inminlevel))
  1008. (setq last-level level))
  1009. (setq level (org-reduced-level (org-outline-level)))
  1010. (let* ((pos (match-beginning 0))
  1011. (value (org-entry-get nil property))
  1012. (value-set (org-string-nw-p value)))
  1013. (cond
  1014. ((< level last-level)
  1015. ;; Collect values from lower levels and inline tasks here
  1016. ;; and summarize them using SUMMARIZE. Store them as text
  1017. ;; property.
  1018. (let* ((summary
  1019. (let ((all (append (and (/= last-level inminlevel)
  1020. (aref lvals last-level))
  1021. (aref lvals inminlevel))))
  1022. (and all (funcall summarize all printf)))))
  1023. (let* ((summaries-alist (get-text-property pos 'org-summaries))
  1024. (old (assoc-string property summaries-alist t))
  1025. (new
  1026. (cond
  1027. (summary (propertize summary 'org-computed t 'face 'bold))
  1028. (value-set value)
  1029. (t ""))))
  1030. (if old (setcdr old new)
  1031. (push (cons property new) summaries-alist)
  1032. (org-with-silent-modifications
  1033. (add-text-properties pos (1+ pos)
  1034. (list 'org-summaries summaries-alist)))))
  1035. ;; When PROPERTY is set in current node, but its value
  1036. ;; doesn't match the one computed, use the latter
  1037. ;; instead.
  1038. (when (and value summary (not (equal value summary)))
  1039. (org-entry-put nil property summary))
  1040. ;; Add current to current level accumulator.
  1041. (when (or summary value-set)
  1042. (push (or summary value) (aref lvals level)))
  1043. ;; Clear accumulators for deeper levels.
  1044. (cl-loop for l from (1+ level) to lmax do
  1045. (aset lvals l nil))))
  1046. (value-set (push value (aref lvals level)))
  1047. (t nil)))))))
  1048. (defun org-columns-compute-all ()
  1049. "Compute all columns that have operators defined."
  1050. (org-with-silent-modifications
  1051. (remove-text-properties (point-min) (point-max) '(org-summaries t)))
  1052. (let ((org-columns--time (float-time (current-time))))
  1053. (dolist (spec org-columns-current-fmt-compiled)
  1054. (pcase spec
  1055. (`(,property ,_ ,_ ,operator . ,_)
  1056. (when operator (save-excursion (org-columns-compute property))))))))
  1057. (defun org-columns--summary-sum (values printf)
  1058. "Compute the sum of VALUES.
  1059. When PRINTF is non-nil, use it to format the result."
  1060. (format (or printf "%s") (apply #'+ (mapcar #'string-to-number values))))
  1061. (defun org-columns--summary-currencies (values _)
  1062. "Compute the sum of VALUES, with two decimals."
  1063. (format "%.2f" (apply #'+ (mapcar #'string-to-number values))))
  1064. (defun org-columns--summary-checkbox (check-boxes _)
  1065. "Summarize CHECK-BOXES with a check-box."
  1066. (let ((done (cl-count "[X]" check-boxes :test #'equal))
  1067. (all (length check-boxes)))
  1068. (cond ((= done all) "[X]")
  1069. ((> done 0) "[-]")
  1070. (t "[ ]"))))
  1071. (defun org-columns--summary-checkbox-count (check-boxes _)
  1072. "Summarize CHECK-BOXES with a check-box cookie."
  1073. (format "[%d/%d]"
  1074. (cl-count "[X]" check-boxes :test #'equal)
  1075. (length check-boxes)))
  1076. (defun org-columns--summary-checkbox-percent (check-boxes _)
  1077. "Summarize CHECK-BOXES with a check-box percent."
  1078. (format "[%d%%]"
  1079. (round (* 100.0 (cl-count "[X]" check-boxes :test #'equal))
  1080. (float (length check-boxes)))))
  1081. (defun org-columns--summary-min (values printf)
  1082. "Compute the minimum of VALUES.
  1083. When PRINTF is non-nil, use it to format the result."
  1084. (format (or printf "%s")
  1085. (apply #'min (mapcar #'string-to-number values))))
  1086. (defun org-columns--summary-max (values printf)
  1087. "Compute the maximum of VALUES.
  1088. When PRINTF is non-nil, use it to format the result."
  1089. (format (or printf "%s")
  1090. (apply #'max (mapcar #'string-to-number values))))
  1091. (defun org-columns--summary-mean (values printf)
  1092. "Compute the mean of VALUES.
  1093. When PRINTF is non-nil, use it to format the result."
  1094. (format (or printf "%s")
  1095. (/ (apply #'+ (mapcar #'string-to-number values))
  1096. (float (length values)))))
  1097. (defun org-columns--summary-sum-times (times _)
  1098. "Sum TIMES."
  1099. (org-columns--summary-apply-times #'+ times))
  1100. (defun org-columns--summary-min-time (times _)
  1101. "Compute the minimum time among TIMES."
  1102. (org-columns--summary-apply-times #'min times))
  1103. (defun org-columns--summary-max-time (times _)
  1104. "Compute the maximum time among TIMES."
  1105. (org-columns--summary-apply-times #'max times))
  1106. (defun org-columns--summary-mean-time (times _)
  1107. "Compute the mean time among TIMES."
  1108. (org-columns--summary-apply-times
  1109. (lambda (&rest values) (/ (apply #'+ values) (float (length values))))
  1110. times))
  1111. (defun org-columns--summary-min-age (ages _)
  1112. "Compute the minimum time among TIMES."
  1113. (format-seconds
  1114. "%dd %.2hh %mm %ss"
  1115. (apply #'min (mapcar #'org-columns--age-to-seconds ages))))
  1116. (defun org-columns--summary-max-age (ages _)
  1117. "Compute the maximum time among TIMES."
  1118. (format-seconds
  1119. "%dd %.2hh %mm %ss"
  1120. (apply #'max (mapcar #'org-columns--age-to-seconds ages))))
  1121. (defun org-columns--summary-mean-age (ages _)
  1122. "Compute the minimum time among TIMES."
  1123. (format-seconds
  1124. "%dd %.2hh %mm %ss"
  1125. (/ (apply #'+ (mapcar #'org-columns--age-to-seconds ages))
  1126. (float (length ages)))))
  1127. (defun org-columns--summary-estimate (estimates printf)
  1128. "Combine a list of estimates, using mean and variance.
  1129. The mean and variance of the result will be the sum of the means
  1130. and variances (respectively) of the individual estimates."
  1131. (let ((mean 0)
  1132. (var 0))
  1133. (dolist (e estimates)
  1134. (pcase (mapcar #'string-to-number (split-string e "-"))
  1135. (`(,low ,high)
  1136. (let ((m (/ (+ low high) 2.0)))
  1137. (cl-incf mean m)
  1138. (cl-incf var (- (/ (+ (* low low) (* high high)) 2.0) (* m m)))))
  1139. (`(,value) (cl-incf mean value))))
  1140. (let ((sd (sqrt var)))
  1141. (format "%s-%s"
  1142. (format (or printf "%.0f") (- mean sd))
  1143. (format (or printf "%.0f") (+ mean sd))))))
  1144. ;;; Dynamic block for Column view
  1145. (defun org-columns--capture-view (maxlevel skip-empty format local)
  1146. "Get the column view of the current buffer.
  1147. MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip
  1148. empty rows, an empty row being one where all the column view
  1149. specifiers but ITEM are empty. FORMAT is a format string for
  1150. columns, or nil. When LOCAL is non-nil, only capture headings in
  1151. current subtree.
  1152. This function returns a list containing the title row and all
  1153. other rows. Each row is a list of fields, as strings, or
  1154. `hline'."
  1155. (org-columns (not local) format)
  1156. (goto-char org-columns-top-level-marker)
  1157. (let ((columns (length org-columns-current-fmt-compiled))
  1158. (has-item (assoc-string "ITEM" org-columns-current-fmt-compiled t))
  1159. table)
  1160. (org-map-entries
  1161. (lambda ()
  1162. (when (get-char-property (point) 'org-columns-key)
  1163. (let (row)
  1164. (dotimes (i columns)
  1165. (let* ((col (+ (line-beginning-position) i))
  1166. (p (get-char-property col 'org-columns-key)))
  1167. (push (org-quote-vert
  1168. (get-char-property col
  1169. (if (string= (upcase p) "ITEM")
  1170. 'org-columns-value
  1171. 'org-columns-value-modified)))
  1172. row)))
  1173. (unless (and skip-empty
  1174. (let ((r (delete-dups (remove "" row))))
  1175. (or (null r) (and has-item (= (length r) 1)))))
  1176. (push (cons (org-reduced-level (org-current-level)) (nreverse row))
  1177. table)))))
  1178. (and maxlevel (format "LEVEL<=%d" maxlevel))
  1179. (and local 'tree)
  1180. 'archive 'comment)
  1181. (org-columns-quit)
  1182. ;; Add column titles and a horizontal rule in front of the table.
  1183. (cons (mapcar #'cadr org-columns-current-fmt-compiled)
  1184. (cons 'hline (nreverse table)))))
  1185. (defun org-columns--clean-item (item)
  1186. "Remove sensitive contents from string ITEM.
  1187. This includes objects that may not be duplicated within
  1188. a document, e.g., a target, or those forbidden in tables, e.g.,
  1189. an inline src-block."
  1190. (let ((data (org-element-parse-secondary-string
  1191. item (org-element-restriction 'headline))))
  1192. (org-element-map data
  1193. '(footnote-reference inline-babel-call inline-src-block target
  1194. radio-target statistics-cookie)
  1195. #'org-element-extract-element)
  1196. (org-no-properties (org-element-interpret-data data))))
  1197. ;;;###autoload
  1198. (defun org-dblock-write:columnview (params)
  1199. "Write the column view table.
  1200. PARAMS is a property list of parameters:
  1201. :id the :ID: property of the entry where the columns view
  1202. should be built. When the symbol `local', call locally.
  1203. When `global' call column view with the cursor at the beginning
  1204. of the buffer (usually this means that the whole buffer switches
  1205. to column view). When \"file:path/to/file.org\", invoke column
  1206. view at the start of that file. Otherwise, the ID is located
  1207. using `org-id-find'.
  1208. :hlines When t, insert a hline before each item. When a number, insert
  1209. a hline before each level <= that number.
  1210. :indent When non-nil, indent each ITEM field according to its level.
  1211. :vlines When t, make each column a colgroup to enforce vertical lines.
  1212. :maxlevel When set to a number, don't capture headlines below this level.
  1213. :skip-empty-rows
  1214. When t, skip rows where all specifiers other than ITEM are empty.
  1215. :width apply widths specified in columns format using <N> specifiers.
  1216. :format When non-nil, specify the column view format to use."
  1217. (let ((table
  1218. (let ((id (plist-get params :id))
  1219. view-file view-pos)
  1220. (pcase id
  1221. (`global nil)
  1222. ((or `local `nil) (setq view-pos (point)))
  1223. ((and (let id-string (format "%s" id))
  1224. (guard (string-match "^file:\\(.*\\)" id-string)))
  1225. (setq view-file (match-string-no-properties 1 id-string))
  1226. (unless (file-exists-p view-file)
  1227. (user-error "No such file: %S" id-string)))
  1228. ((and (let idpos (org-find-entry-with-id id)) idpos)
  1229. (setq view-pos idpos))
  1230. ((let `(,filename . ,position) (org-id-find id))
  1231. (setq view-file filename)
  1232. (setq view-pos position))
  1233. (_ (user-error "Cannot find entry with :ID: %s" id)))
  1234. (with-current-buffer (if view-file (get-file-buffer view-file)
  1235. (current-buffer))
  1236. (org-with-wide-buffer
  1237. (when view-pos (goto-char view-pos))
  1238. (org-columns--capture-view (plist-get params :maxlevel)
  1239. (plist-get params :skip-empty-rows)
  1240. (plist-get params :format)
  1241. view-pos))))))
  1242. (when table
  1243. ;; Prune level information from the table. Also normalize
  1244. ;; headings: remove stars, add indentation entities, if
  1245. ;; required, and possibly precede some of them with a horizontal
  1246. ;; rule.
  1247. (let ((item-index
  1248. (let ((p (assoc-string "ITEM" org-columns-current-fmt-compiled t)))
  1249. (and p (cl-position p
  1250. org-columns-current-fmt-compiled
  1251. :test #'equal))))
  1252. (hlines (plist-get params :hlines))
  1253. (indent (plist-get params :indent))
  1254. new-table)
  1255. ;; Copy header and first rule.
  1256. (push (pop table) new-table)
  1257. (push (pop table) new-table)
  1258. (dolist (row table (setq table (nreverse new-table)))
  1259. (let ((level (car row)))
  1260. (when (and (not (eq (car new-table) 'hline))
  1261. (or (eq hlines t)
  1262. (and (numberp hlines) (<= level hlines))))
  1263. (push 'hline new-table))
  1264. (when item-index
  1265. (let ((item (org-columns--clean-item (nth item-index (cdr row)))))
  1266. (setf (nth item-index (cdr row))
  1267. (if (and indent (> level 1))
  1268. (concat "\\_" (make-string (* 2 (1- level)) ?\s) item)
  1269. item))))
  1270. (push (cdr row) new-table))))
  1271. (when (plist-get params :width)
  1272. (setq table
  1273. (append table
  1274. (list
  1275. (mapcar (lambda (spec)
  1276. (let ((w (nth 2 spec)))
  1277. (if w (format "<%d>" (max 3 w)) "")))
  1278. org-columns-current-fmt-compiled)))))
  1279. (when (plist-get params :vlines)
  1280. (setq table
  1281. (let ((size (length org-columns-current-fmt-compiled)))
  1282. (append (mapcar (lambda (x) (if (eq 'hline x) x (cons "" x)))
  1283. table)
  1284. (list (cons "/" (make-list size "<>")))))))
  1285. (let ((content-lines (org-split-string (plist-get params :content) "\n"))
  1286. recalc)
  1287. ;; Insert affiliated keywords before the table.
  1288. (when content-lines
  1289. (while (string-match-p "\\`[ \t]*#\\+" (car content-lines))
  1290. (insert (pop content-lines) "\n")))
  1291. (save-excursion
  1292. ;; Insert table at point.
  1293. (insert
  1294. (mapconcat (lambda (row)
  1295. (if (eq row 'hline) "|-|"
  1296. (format "|%s|" (mapconcat #'identity row "|"))))
  1297. table
  1298. "\n"))
  1299. ;; Insert TBLFM lines following table.
  1300. (let ((case-fold-search t))
  1301. (dolist (line content-lines)
  1302. (when (string-match-p "\\`[ \t]*#\\+TBLFM:" line)
  1303. (insert "\n" line)
  1304. (unless recalc (setq recalc t))))))
  1305. (when recalc (org-table-recalculate 'all t))
  1306. (org-table-align)))))
  1307. ;;;###autoload
  1308. (defun org-columns-insert-dblock ()
  1309. "Create a dynamic block capturing a column view table."
  1310. (interactive)
  1311. (let ((id (completing-read
  1312. "Capture columns (local, global, entry with :ID: property) [local]: "
  1313. (append '(("global") ("local"))
  1314. (mapcar #'list (org-property-values "ID"))))))
  1315. (org-create-dblock
  1316. (list :name "columnview"
  1317. :hlines 1
  1318. :id (cond ((string= id "global") 'global)
  1319. ((member id '("" "local")) 'local)
  1320. (id)))))
  1321. (org-update-dblock))
  1322. (define-obsolete-function-alias 'org-insert-columns-dblock
  1323. 'org-columns-insert-dblock "Org 9.0")
  1324. ;;; Column view in the agenda
  1325. ;;;###autoload
  1326. (defun org-agenda-columns ()
  1327. "Turn on or update column view in the agenda."
  1328. (interactive)
  1329. (org-columns-remove-overlays)
  1330. (move-marker org-columns-begin-marker (point))
  1331. (let ((org-columns--time (float-time (current-time)))
  1332. (fmt
  1333. (cond
  1334. ((org-bound-and-true-p org-agenda-overriding-columns-format))
  1335. ((let ((m (org-get-at-bol 'org-hd-marker)))
  1336. (and m
  1337. (or (org-entry-get m "COLUMNS" t)
  1338. (with-current-buffer (marker-buffer m)
  1339. org-columns-default-format)))))
  1340. ((and (local-variable-p 'org-columns-current-fmt)
  1341. org-columns-current-fmt))
  1342. ((let ((m (next-single-property-change (point-min) 'org-hd-marker)))
  1343. (and m
  1344. (let ((m (get-text-property m 'org-hd-marker)))
  1345. (or (org-entry-get m "COLUMNS" t)
  1346. (with-current-buffer (marker-buffer m)
  1347. org-columns-default-format))))))
  1348. (t org-columns-default-format))))
  1349. (setq-local org-columns-current-fmt fmt)
  1350. (org-columns-compile-format fmt)
  1351. (when org-agenda-columns-compute-summary-properties
  1352. (org-agenda-colview-compute org-columns-current-fmt-compiled))
  1353. (save-excursion
  1354. ;; Collect properties for each headline in current view.
  1355. (goto-char (point-min))
  1356. (let (cache)
  1357. (while (not (eobp))
  1358. (let ((m (or (org-get-at-bol 'org-hd-marker)
  1359. (org-get-at-bol 'org-marker))))
  1360. (when m
  1361. (push (cons (line-beginning-position)
  1362. (org-with-point-at m
  1363. (org-columns--collect-values 'agenda)))
  1364. cache)))
  1365. (forward-line))
  1366. (when cache
  1367. (setq-local org-columns-current-maxwidths
  1368. (org-columns--autowidth-alist cache))
  1369. (org-columns--display-here-title)
  1370. (when (setq-local org-columns-flyspell-was-active
  1371. (org-bound-and-true-p flyspell-mode))
  1372. (flyspell-mode 0))
  1373. (dolist (entry cache)
  1374. (goto-char (car entry))
  1375. (org-columns--display-here (cdr entry)))
  1376. (when org-agenda-columns-show-summaries
  1377. (org-agenda-colview-summarize cache)))))))
  1378. (defun org-agenda-colview-summarize (cache)
  1379. "Summarize the summarizable columns in column view in the agenda.
  1380. This will add overlays to the date lines, to show the summary for each day."
  1381. (let ((fmt (mapcar
  1382. (lambda (spec)
  1383. (pcase spec
  1384. (`(,property ,title ,width . ,_)
  1385. (if (member-ignore-case property '("CLOCKSUM" "CLOCKSUM_T"))
  1386. (list property title width ":" 'add_times nil '+ nil)
  1387. spec))))
  1388. org-columns-current-fmt-compiled))
  1389. entries)
  1390. ;; Ensure there's at least one summation column.
  1391. (when (cl-some (lambda (spec) (nth 3 spec)) fmt)
  1392. (goto-char (point-max))
  1393. (while (not (bobp))
  1394. (when (or (get-text-property (point) 'org-date-line)
  1395. (eq (get-text-property (point) 'face)
  1396. 'org-agenda-structure))
  1397. ;; OK, this is a date line that should be used.
  1398. (let (rest)
  1399. (dolist (c cache (setq cache rest))
  1400. (if (> (car c) (point))
  1401. (push c entries)
  1402. (push c rest))))
  1403. ;; Now ENTRIES contains entries below the current one.
  1404. ;; CACHE is the rest. Compute the summaries for the
  1405. ;; properties we want, set nil properties for the rest.
  1406. (when (setq entries (mapcar 'cdr entries))
  1407. (org-columns--display-here
  1408. (mapcar
  1409. (lambda (spec)
  1410. (pcase spec
  1411. (`(,(and prop (guard (equal (upcase prop) "ITEM"))) . ,_)
  1412. ;; Replace ITEM with current date. Preserve
  1413. ;; properties for fontification.
  1414. (let ((date (buffer-substring
  1415. (line-beginning-position)
  1416. (line-end-position))))
  1417. (list prop date date)))
  1418. (`(,prop ,_ ,_ nil . ,_)
  1419. (list prop "" ""))
  1420. (`(,prop ,_ ,_ ,_ ,printf ,summarize)
  1421. (let* ((values
  1422. ;; Use real values for summary, not those
  1423. ;; prepared for display.
  1424. (delq nil
  1425. (mapcar
  1426. (lambda (entry)
  1427. (org-string-nw-p
  1428. (nth 1 (assoc-string prop entry t))))
  1429. entries)))
  1430. (final (if values (funcall summarize values printf)
  1431. "")))
  1432. (unless (equal final "")
  1433. (put-text-property 0 (length final) 'face 'bold final))
  1434. (list prop final final)))))
  1435. fmt)
  1436. 'dateline)
  1437. (setq-local org-agenda-columns-active t)))
  1438. (forward-line -1)))))
  1439. (defun org-agenda-colview-compute (fmt)
  1440. "Compute the relevant columns in the contributing source buffers."
  1441. (let ((files org-agenda-contributing-files)
  1442. (org-columns-begin-marker (make-marker))
  1443. (org-columns-top-level-marker (make-marker)))
  1444. (dolist (f files)
  1445. (let ((b (find-buffer-visiting f)))
  1446. (with-current-buffer (or (buffer-base-buffer b) b)
  1447. (org-with-wide-buffer
  1448. (org-with-silent-modifications
  1449. (remove-text-properties (point-min) (point-max) '(org-summaries t)))
  1450. (goto-char (point-min))
  1451. (org-columns-get-format-and-top-level)
  1452. (dolist (spec fmt)
  1453. (let ((prop (car spec)))
  1454. (cond
  1455. ((equal (upcase prop) "CLOCKSUM") (org-clock-sum))
  1456. ((equal (upcase prop) "CLOCKSUM_T") (org-clock-sum-today))
  1457. ((and (nth 3 spec)
  1458. (let ((a (assoc prop org-columns-current-fmt-compiled)))
  1459. (equal (nth 3 a) (nth 3 spec))))
  1460. (org-columns-compute prop)))))))))))
  1461. (provide 'org-colview)
  1462. ;;; org-colview.el ends here