Hey there, I wrote a bit of code to do the things in the subject.
I'm interested if someone has a better way to deal with the subtree copying thing I'm doing. I'm not really happy with using the kill-ring like that. `org-narrow-subtree' won't work, because `save-excursion' doesn't revert it to the previous state and the org-sort already uses it. Thanks in advance for looking over it! (defun ba/org-heading-clock-times () "Return alist of clocktimes from current heading." (let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*" org-clock-string "[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)")) t1 ts te tsf tef dt results) (save-excursion ;; shut up about copying (flet ((message (&rest ignored) nil)) (org-copy-subtree)) (with-temp-buffer (yank) (while (re-search-backward re nil t) (when (match-end 2) ;; Two time stamps (setq ts (match-string-no-properties 2) te (match-string-no-properties 3) tsf (org-float-time (apply 'encode-time (org-parse-time-string ts))) tef (org-float-time (apply 'encode-time (org-parse-time-string te))) dt (- tef tsf) t1 (floor (/ dt 60))) (add-to-list 'results `(,ts . ,t1)))))) results)) (defun ba/org-sort-most-time-spend () (let ((org-ts-w/mins (ba/org-heading-clock-times))) (- (apply '+ (mapcar '(lambda (a) (cdr a)) org-ts-w/mins))))) (defun ba/org-sort-most-recently-clocked () (let ((org-ts-w/mins (ba/org-heading-clock-times))) (if (not org-ts-w/mins) (org-float-time) (- (org-float-time) (org-float-time (apply 'encode-time (org-parse-time-string (caar org-ts-w/mins)))))))) br, benny _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode