From: Joseph Vidal-Rosset <joseph.vidal.rosset@gmail.com>
To: emacs-orgmode list <emacs-orgmode@gnu.org>
Subject: org-links for Gnus in imap with Gmail (for a convenient todo.org list)
Date: Thu, 25 Jul 2019 18:24:15 +0200 [thread overview]
Message-ID: <5d39d7af.1c69fb81.2893e.8fde@mx.google.com> (raw)
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#CAJ51ETqLcFTeZvPYg0AuzZL2HGwVGCOewKem8OkZnLL-ES59-g@mail.gmail.com][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#CAJ51ETqLcFTeZvPYg0AuzZL2HGwVGCOewKem8OkZnLL-ES59-g@mail.gmail.com][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.
next reply other threads:[~2019-07-25 16:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-25 16:24 Joseph Vidal-Rosset [this message]
2019-07-25 16:47 ` org-links for Gnus in imap with Gmail (for a convenient todo.org list) Fraga, Eric
2019-07-25 17:24 ` Joseph Vidal-Rosset
2019-07-25 17:33 ` Fraga, Eric
2019-07-25 17:41 ` Joseph Vidal-Rosset
2019-07-25 17:46 ` Eric Abrahamsen
2019-07-26 9:43 ` Joseph Vidal-Rosset
2019-07-25 19:15 ` Ken Mankoff
2019-07-26 7:14 ` Joseph Vidal-Rosset
2019-07-26 7:24 ` Ken Mankoff
2019-07-26 7:41 ` Joseph Vidal-Rosset
2019-07-26 17:30 ` Bob Newell
2019-07-27 9:36 ` Joseph Vidal-Rosset
[not found] ` <87zhkzduzy.fsf@bobnewell.net>
2019-07-28 7:22 ` Joseph Vidal-Rosset
2019-08-11 17:50 ` Joseph Vidal-Rosset
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d39d7af.1c69fb81.2893e.8fde@mx.google.com \
--to=joseph.vidal.rosset@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).