Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 1a / 568bd707b41498c10b01d7c639c78842283fd5
1 Return-Path: <bernard@marcade.biz>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id CA8B1431FAE\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 04:55:02 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.275\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.275 tagged_above=-999 required=5\r
12         tests=[FSL_HELO_NON_FQDN_1=0.001, HELO_NO_DOMAIN=1, RDNS_NONE=1.274]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id xXyHpYqTNQVL for <notmuch@notmuchmail.org>;\r
17         Mon,  3 Dec 2012 04:55:02 -0800 (PST)\r
18 X-Greylist: delayed 525 seconds by postgrey-1.32 at olra;\r
19         Mon, 03 Dec 2012 04:55:02 PST\r
20 Received: from dell-laptop (unknown [86.53.51.141])\r
21         by olra.theworths.org (Postfix) with ESMTP id 27209431FBC\r
22         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 04:55:02 -0800 (PST)\r
23 Received: by dell-laptop (Postfix, from userid 1001)\r
24         id 02097BD6058; Mon,  3 Dec 2012 12:45:56 +0000 (GMT)\r
25 From: Bernard Hurley <bernard@marcade.biz>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: Using notmuch with planner.\r
28 User-Agent: Notmuch/0.14 (http://notmuchmail.org) Emacs/24.2.1\r
29         (i686-pc-linux-gnu)\r
30 X-Attribution: Bernard\r
31 Date: Mon, 03 Dec 2012 12:45:56 +0000\r
32 Message-ID: <861uf7gv7f.fsf@marcade.biz>\r
33 MIME-Version: 1.0\r
34 Content-Type: text/plain\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.13\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39         <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Mon, 03 Dec 2012 12:55:02 -0000\r
48 \r
49 Hi all,\r
50 \r
51 I have been using the following code for stashing link to email messages\r
52 for use in planner. It might be of use to others on the list.\r
53 \r
54 Bernard\r
55 \r
56 ;; Code for using notmuch with planner\r
57 (defun notmuch-show-get-planner-link ()\r
58   "Get a planner-formatted link to a notmuch-show email message.\r
59 The format of the link is:\r
60 \r
61    [[<subject>]], <date>, <from>.\r
62    \r
63 The subject field is suitably edited to remove any characters\r
64 that would break the coding of the link. The text of the Date:\r
65 and From: fields are also also copied to the kill ring as the\r
66 user will most probably need them.\r
67 "\r
68   ;; Make sure planner understands lisp coded links\r
69   (require 'planner-lisp)\r
70   (let ((id (concat "id:" (notmuch-show-get-message-id t)))\r
71         (subject (notmuch-show-get-subject))\r
72         (date (notmuch-show-get-date))\r
73         (from (notmuch-show-get-from))\r
74         title link-code link)\r
75     ;; Replace awkward characters in subject\r
76     (setq title (replace-regexp-in-string "\"" "'" subject))\r
77     (setq title (replace-regexp-in-string "\\[" "{" subject))\r
78     (setq title (replace-regexp-in-string "\\]" "}" subject))\r
79     ;; Construct the title of the show buffer\r
80     (setq title (concat "*"\r
81                         (truncate-string-to-width subject 30 nil nil t)\r
82                         "*"))\r
83     ;; Construct link code\r
84     (setq link-code\r
85           (format "lisp:/(notmuch-show \"%s\" (current-buffer) nil \"%s\")"\r
86                   id\r
87                   title))\r
88     ;; Construct link\r
89     (setq link\r
90           (format "[[%s][%s]], %s, %s." link-code subject date from))))\r
91           \r
92 (defun notmuch-show-stash-planner-link ()\r
93   "Planner-formatted link to notmuch-show email message to kill ring."\r
94   (interactive)\r
95   (notmuch-common-do-stash (notmuch-show-get-planner-link)))\r
96   \r
97 -- \r
98 \r
99 Your fortune cookie for today:\r
100 \r
101 A bore is a man who talks so much about himself that you can't talk about\r
102 yourself.\r
103 \r
104 ** Fortune cookies are brought to you by GNU/Linux "fortunes" **\r
105 \r
106 >  LocalWords:  notmuch defun concat setq\r