emacs-orgmode
[Top][All Lists]
Advanced

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

[O] org-links for Gnus in imap with Gmail (for a convenient todo.org lis


From: Joseph Vidal-Rosset
Subject: [O] org-links for Gnus in imap with Gmail (for a convenient todo.org list)
Date: Thu, 25 Jul 2019 18:24:15 +0200

Hello,

Documentation to create a todo.org list  that provides links to email as
tasks   is  not   seldom  on   the  web.   I  recommend   for  example
[[http://pragmaticemacs.com/]]. 

But for  gnus-imap-gmail users, it is  more difficult to get  the same
thing. 

Here is a the lines of code  in my setup (user.el in Kitchin's scimax)
that work for gnus in imap:

 #+BEGIN_SRC elisp
 
;;capture todo items using C-c c t
(define-key global-map (kbd "C-c c") 'org-capture)
(setq org-capture-templates
      '(("t" "todo" entry (file+headline "~/Dropbox/Orgzly/todo.org" "Tasks")
         "* TODO [#A] %?\n 
[[~/Dropbox/Orgzly/links.org::%(org-insert-time-stamp (org-read-date nil t 
\"%:date\"))]] \n* %(org-insert-time-stamp (org-read-date nil t \"%:date\")) %a 
")))


(defun hs/replace ()
   (interactive)
   (goto-char 1)
   (let ((search-invisible t)) (replace-string "gnus:INBOX#" 
"gnus:%5BGmail%5D/Tous les messages#")))
(define-key global-map (kbd "C-c r") 'hs/replace)
(add-hook 'org-capture-prepare-finalize-hook 'hs/replace)
(defun my/refile (file headline &optional arg)
  (let ((pos (save-excursion
               (find-file file)
               (org-find-exact-headline-in-buffer headline))))
    (org-refile arg nil (list headline file nil pos)))
  (switch-to-buffer (current-buffer)))

(defhydra jo/org-refile-hydra (:foreign-keys run) 
  "Refile"
  ("l" (my/refile "~/Dropbox/Orgzly/links.org" "Links") "Links")
  ("j" org-refile-goto-last-stored "Jump to last refile")
  ("q" nil "cancel"))
;; Or whatever you want your keybinding to be
(global-set-key (kbd "<f9> r") 'jo/org-refile-hydra/body)

(global-set-key (kbd "<f9> a") 'org-archive-subtree)

;;refile  
https://blog.aaronbieber.com/2017/03/19/organizing-notes-with-refile.html
(setq org-refile-targets '((org-agenda-files :maxlevel . 2)))
(setq org-refile-use-outline-path 'file)
(setq org-outline-path-complete-in-steps nil)
(setq org-refile-allow-creating-parent-nodes 'confirm)

(setq org-refile-targets '((nil :maxlevel . 2)
                                (org-agenda-files :maxlevel . 2)))
(setq org-outline-path-complete-in-steps nil)         ; Refile in a single go
(setq org-refile-use-outline-path t)                  ; Show full paths for 
refiling

(setq org-refile-targets (quote (("todo.org" :maxlevel . 2)
                                ("links.org" :level . 2)
                                 )))
#+END_SRC  

with any  file open  in emacs, like  for example this  email, C-c  c t
gives the following result that I paste below: 

 #+BEGIN_SRC elisp
 
** TODO [#A] 
  [[~/Dropbox/Orgzly/links.org::<2019-07-25 jeu.>]] 
** <2019-07-25 jeu.> [[file:~/News/drafts/drafts/129]]

#+END_SRC

Because I  like to  see my  todo list  with conky  on my  wallpaper, I
refile  the second  link into  links.org  and it  is now  easy to  get
immediately from todo.org the correct  entry that have the appropriate
link in links.org. 

In Gnus, it is the same thing. For example C-c c t in reading the last
email that I received from John Kitchin provides:

 #+BEGIN_SRC elisp
 
** TODO [#A] 
  [[~/Dropbox/Orgzly/links.org::<2019-07-25 jeu.>]] 
** <2019-07-25 jeu.> [[gnus:INBOX#address@hidden][Email from John Kitchin: Re: 
scimax question]] 
#+END_SRC

But  I need  to change  the mention  of INBOX  in the  link to  John's
email. Hence the function hs/replace via  C-c r with the cursor on the
link that gives the wanted result: 

 #+BEGIN_SRC elisp   
** TODO [#A] 
  [[~/Dropbox/Orgzly/links.org::<2019-07-25 jeu.>]] 
** <2019-07-25         jeu.>         [[gnus:%5BGmail%5D/Tous         les
messages#address@hidden][Email
from John Kitchin: Re: scimax question]]

#+END_SRC 

and then  the email can  be archived in  Tous les messages,  Gnus will
find it, via imap.gmail.com . 

That's it.  I hope  some of  you will find  this useful.  Let me know. Of
course the code  must be adapted according to the  language of the gmail
user, it goes without saying. 

(In refiling,  I do not  succeed to get other  level that level  one for
sections, but it is a detail. )

 Best wishes,
-- 
Jo.



reply via email to

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