help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs mylin-like tool ?


From: Bastien
Subject: Re: emacs mylin-like tool ?
Date: Sun, 30 Dec 2012 23:40:17 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

Hi Luca,

Luca Ferrari <fluca1978@infinito.it> writes:

> I'm curious to know if there is some tool like Eclipse Mylin
> (http://www.eclipse.org/mylyn/) that "records" which files have been
> visited when working about a specific task. And in the case it would
> be great to get it tied to org mode tasks...any suggestion?

Here is a small hack.  It empty the list of recent files when you
clock in a task, and it write it as a dynamic block when you clock out.
I don't use recentf-mode myself, so this may need more testing.

Feedback welcome!

(defun org-recentf-save-and-empty ()
  "Save and empty recentf"
  (if (not recentf-mode)
      (recentf-mode)
    (recentf-save-list)
    (setq recentf-list nil)
    (message "Recentf list reinitialized")))

(defun org-recentf-dblock-update ()
  "Insert and/or update #+BEGIN: recentf block"
  (save-excursion
    (org-back-to-heading)
    (if (search-forward "#+BEGIN: recentf")
        (org-dblock-update)
      (outline-next-heading)
      (insert "#+BEGIN: recentf\n#+END:\n")
      (search-backward "#+BEGIN")
      (org-dblock-update))))

(defun org-dblock-write:recentf (params)
  "Write the RECENTF dblock."
  (interactive)
  (let* ((rf "(setq recentf-list %s)")
         (rfl (format rf (prin1-to-string recentf-list))))
    (insert "#+begin_src emacs-lisp\n" rfl
            "\n(recentf-load-list)\n#+end_src")))

(add-hook 'org-clock-in-hook 'org-recentf-save-and-empty)
(add-hook 'org-clock-out-hook 'org-recentf-dblock-update)

HTH,

-- 
 Bastien



reply via email to

[Prev in Thread] Current Thread [Next in Thread]