unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Using notmuch with planner.
@ 2012-12-03 12:45 Bernard Hurley
  0 siblings, 0 replies; only message in thread
From: Bernard Hurley @ 2012-12-03 12:45 UTC (permalink / raw)
  To: notmuch

Hi all,

I have been using the following code for stashing link to email messages
for use in planner. It might be of use to others on the list.

Bernard

;; Code for using notmuch with planner
(defun notmuch-show-get-planner-link ()
  "Get a planner-formatted link to a notmuch-show email message.
The format of the link is:

   [[<subject>]], <date>, <from>.
   
The subject field is suitably edited to remove any characters
that would break the coding of the link. The text of the Date:
and From: fields are also also copied to the kill ring as the
user will most probably need them.
"
  ;; Make sure planner understands lisp coded links
  (require 'planner-lisp)
  (let ((id (concat "id:" (notmuch-show-get-message-id t)))
	(subject (notmuch-show-get-subject))
	(date (notmuch-show-get-date))
	(from (notmuch-show-get-from))
	title link-code link)
    ;; Replace awkward characters in subject
    (setq title (replace-regexp-in-string "\"" "'" subject))
    (setq title (replace-regexp-in-string "\\[" "{" subject))
    (setq title (replace-regexp-in-string "\\]" "}" subject))
    ;; Construct the title of the show buffer
    (setq title (concat "*"
			(truncate-string-to-width subject 30 nil nil t)
			"*"))
    ;; Construct link code
    (setq link-code
	  (format "lisp:/(notmuch-show \"%s\" (current-buffer) nil \"%s\")"
		  id
		  title))
    ;; Construct link
    (setq link
	  (format "[[%s][%s]], %s, %s." link-code subject date from))))
          
(defun notmuch-show-stash-planner-link ()
  "Planner-formatted link to notmuch-show email message to kill ring."
  (interactive)
  (notmuch-common-do-stash (notmuch-show-get-planner-link)))
  
-- 

Your fortune cookie for today:

A bore is a man who talks so much about himself that you can't talk about
yourself.

** Fortune cookies are brought to you by GNU/Linux "fortunes" **

>  LocalWords:  notmuch defun concat setq

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-03 12:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-03 12:45 Using notmuch with planner Bernard Hurley

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).