org-colview.el 58 KB

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