1 \input texinfo @c -*- texinfo -*-
3 @setfilename ./gnorb.info
5 @documentencoding UTF-8
12 * Gnorb: (gnorb). Glue code for Gnus, Org, and BBDB.
18 @subtitle for version 1, updated 3 October, 2014
31 * Restoring Window Layout::
32 * Recent Mails From BBDB Contacts::
33 * BBDB posting styles::
38 * Suggested Keybindings::
43 --- The Detailed Node Listing ---
47 * Email-Related Commands::
49 * Viewing Tracked Messages in *Summary* Buffers::
51 * Message Attachments::
55 * Searching for messages from BBDB contacts::
56 * Citing BBDB contacts::
61 * Inserting BBDB links::
62 * User Options: User Optionsx.
66 * Viewing Org headlines relevant to a message::
67 * User Options: User Optionsxx.
74 Gnorb provides glue code between the Gnus, Org, and BBDB packages.
75 It's aimed at supporting email-based project management, and generally
76 making it easier to keep track of email communication.
78 Much of the code consists of single-use convenience functions, but
79 tracking email conversations with Org requires is more complicated,
80 and requires a bit of setup.
82 Gnorb can be used in a modular fashion, by selectively loading the
83 files ``gnorb-org'', ``gnorb-gnus'' or ``gnorb-bbdb'' instead of plain old
84 ``gnorb''. The package as a whole is rather Org-centric, though, and it
85 won't do much of interest without ``gnorb-org''.
87 This means that Gnorb doesn't have hard requirements to any of the
88 three base libraries. For the libraries you are using, however, you'll
89 get best results from using the most recent stable version (yes, that
90 means BBDB 3). Some of the features in Gnorb only work with
91 development versions of these libraries (those cases are noted below).
96 Gnorb is best installed via the Elpa package manager -- look for it in
99 You can also clone the source code from
100 @uref{https://github.com/girzel/gnorb}, and put the ``gnorb'' directory on your
101 load-path. The Github site is also a good place to report bugs and
107 Loading ``gnorb'' will make the basic functions available. Using Gnorb
108 for email tracking takes a bit more setup, however:
112 Email tracking is done via the Gnus registry, so that must be
113 activated with `gnus-registry-initialize'.
115 It also requires the org-id package to be loaded, and
116 `org-id-track-globally' set to t (that's the default value, so
117 simply loading the package should be enough).
119 Add a nngnorb entry to your `gnus-secondary-select-methods'
120 variable. It will look like (nngnorb ``Server name''). This does
121 nothing but provide a place to hang nnir searches.
123 Then put a call to `gnorb-tracking-initialize' in your init files,
124 at some point after the Gnus registry is initialized.
126 If you're not using a local archive method for saving your sent
127 messages (ie you're using IMAP), you'll also need to tell Gnorb
128 where to find your sent messages. Set the variable
129 `gnorb-gnus-sent-groups' to a list of strings; each string should
130 indicate a fully-qualified group name, eg ``nnimap+SERVER:GROUP''.
133 Lastly, Gnorb doesn't bind any keys by default; see the @ref{Suggested Keybindings,Suggested
134 Keybindings} section below for possibilities.
137 @chapter Email Tracking
139 The most interesting thing Gnorb does is using Org headings to track
140 email conversations. This can mean anything from reminding yourself to
141 write to your mother, to conducting delicate business negotiations
142 over email, to running an email-based bug tracker.
144 Gnorb assists in this process by using the Gnus registry to track
145 correspondences between emails and Org headings -- specifically,
146 message IDs are associated with Org heading ids. As a conversation
147 develops, messages are collected on a heading (and/or its children).
148 You can compose new messages directly from the Org heading, and Gnorb
149 will automatically associate your sent message with the conversation.
150 You can open temporary Gnus *Summary* buffers holding all the messages
151 associated with an Org subtree, and reply from there. When you receive
152 new messages relevant to a conversation, Gnorb will notice them and
153 prompt you to associate them with the appropriate Org heading.
154 Attachments on incoming messages can be automatically saved as
155 attachments on Org headings, using org-attach.
157 In general, the goal is to keep track of whole conversations, reduce
158 friction when moving between Gnus and Org, and keep you in the Org
159 agenda rather than in Gnus.
161 * Email-Related Commands::
163 * Viewing Tracked Messages in *Summary* Buffers::
165 * Message Attachments::
168 @node Email-Related Commands
169 @section Email-Related Commands
171 Email tracking starts in one of three ways:
175 With an Org heading that represents an email TODO. Call
176 `gnorb-org-handle-mail' (see below) on the heading to compose a new
177 message, and start the tracking process.
179 By calling org-capture on a received message. Any heading captured
180 from a message will automatically be associated with that message.
182 By calling `gnorb-gnus-outgoing-do-todo' in a message composition
186 There are three main email-related commands:
190 `gnorb-org-handle-mail' is called on an Org heading to compose a
191 new message. By default, this will begin a reply to the most recent
192 message in the conversation. If there are no associated messages to
193 reply to (or you call the function with a double prefix arg), Gnorb
194 will look for mailto: or bbdb: links in the heading, and compose a
197 The sent message will be associated with the Org heading, and
198 you'll be brought back to the heading and asked to trigger an
201 `gnorb-email-subtree' is an alternative entry-point to
202 `gnorb-org-handle-mail'. It does the same thing as the latter, but
203 first exports the body of the subtree as either text or a file,
204 then inserts the text into the message body, or attaches the file
205 to the message, depending on what you've chosen.
207 `gnorb-gnus-incoming-do-todo' is called on a message in a Gnus
208 *Summary* buffer. You'll be prompted for an Org heading, taken to
209 that heading, and asked to trigger an action on it.
211 `gnorb-gnus-outgoing-do-todo' is called in message mode, while
212 composing a new message.
214 If called without a prefix arg, a new Org heading will be created
215 after the message is sent, and the sent message associated with it.
216 The new heading will be created as a capture heading, using the
217 template specified by the `gnorb-gnus-new-todo-capture-key' option.
219 If you call this function with a prefix arg, you'll be prompted to
220 choose an existing Org heading instead. After the the message is
221 sent, you'll be taken to that heading and prompted to trigger an
224 It's also possible to call this function *after* a message is sent,
225 in case you forgot. Gnorb saves information about the most recently
226 sent message for this purpose.
229 Because these three commands all express a similar intent, but are
230 called in different modes, it can make sense to give each of them the
231 same keybinding in the keymaps for Org mode, Gnus summary mode, and
232 Message mode, respectively.
234 @node Trigger Actions
235 @section Trigger Actions
237 After calling `gnorb-gnus-incoming-do-todo' on a message, or after
238 sending a message associated with an Org heading, you'll be taken to
239 the heading and asked to ``trigger an action'' on it. At the moment
240 there are four different possibilities: triggering a TODO state-change
241 on the heading, taking a note on the heading (both these options will
242 associate the message with the heading), associating the message but
243 doing nothing else, and lastly, doing nothing at all.
245 More actions will be added in the future; it's also possible to add
246 your own action: see the docstring of `gnorb-org-trigger-actions'.
248 @node Viewing Tracked Messages in *Summary* Buffers
249 @section Viewing Tracked Messages in *Summary* Buffers
251 Call `gnorb-org-view' on an Org heading to open an nnir *Summary*
252 buffer showing all the messages associated with that heading (this
253 requires that you've added an nngnorb server to your Gnus backends). A
254 minor mode will be in effect, ensuring that any replies you send to
255 messages in this buffer will automatically be associated with the
256 original Org heading. You can also invoke
257 `gnorb-summary-disassociate-message' (``C-c d'') to disassociate the
258 message with the Org heading.
260 As a bonus, it's possible to go into Gnus' *Server* buffer, find the
261 line specifying your nngnorb server, and hit ``G'' (aka
262 `gnus-group-make-nnir-group'). At the query prompt, enter an Org-style
263 tags-todo Agenda query string (eg ``+work-computer'', or what have you).
264 Gnorb will find all headings matching this query, scan their subtrees
265 for gnus links, and then give you a Summary buffer containing all the
266 linked messages. This is dog-slow at the moment; it will get faster.
268 @node Hinting in Gnus
269 @section Hinting in Gnus
271 When you receive new mails that might be relevant to existing Org
272 TODOs, Gnorb can alert you to that fact. When
273 `gnorb-gnus-hint-relevant-article' is t (the default), Gnorb will
274 display a message in the minibuffer when opening potentially relevant
275 messages. You can then use `gnorb-gnus-incoming-to-todo' to trigger an
276 action on the relevant TODO.
278 This hinting can happen in the Gnus summary buffer as well. If you use
279 the escape indicated by `gnorb-gnus-summary-mark-format-letter'' as
280 part of your `gnus-summary-line-format', articles that are relevant to
281 TODOs will be marked with a special character in the Summary buffer,
282 as determined by `gnorb-gnus-summary-mark'. By default, the format
283 letter is ``g'' (meaning it is used as ``%ug'' in the format line), and
286 @node Message Attachments
287 @section Message Attachments
289 Gnorb simplifies the handling of attachments that you receive in
290 emails. When you call `gnorb-gnus-incoming-do-todo' on a message,
291 you'll be prompted to re-attach the email's attachments onto the Org
292 heading, using the org-attach library.
294 You can also do this as part of the capture process. Set the
295 new :gnus-attachments key to ``t'' in a capture template that you use on
296 mail messages, and you'll be queried to re-attach the message's
297 attachments onto the newly-captured heading. Or set
298 `gnorb-gnus-capture-always-attach' to ``t'' to have Gnorb do this for
299 all capture templates.
301 You can also do this using the regular system of MIME commands,
302 without invoking the email tracking process. See @ref{Suggested Keybindings,Suggested
305 The same process works in reverse: when you send a message from an Org
306 heading using `gnorb-org-handle-mail', Gnorb will ask if you want to
307 attach the files in the heading's org-attach directory to the outgoing
310 @node Restoring Window Layout
311 @chapter Restoring Window Layout
313 Many Gnorb functions alter the window layout and value of point. In
314 most of these cases, you can restore the previous layout using the
315 interactive function `gnorb-restore-layout'.
317 @node Recent Mails From BBDB Contacts
318 @chapter Recent Mails From BBDB Contacts
320 If you're using a recent git version of BBDB (circa mid-May 2014 or
321 later), you can give your BBDB contacts a special field which will
322 collect links to recent emails from that contact. The default name of
323 the field is ``messages'', but you can customize that name using the
324 `gnorb-bbdb-messages-field' option.
326 Gnorb will not collect links by default: you need to call
327 `gnorb-bbdb-open-link' on a contact once to start the process.
328 Thereafter, opening mails from that contact will store a link to the
331 Once some links are stored, `gnorb-bbdb-open-link' will open them: Use
332 a prefix arg to the function call to select particular messages to
333 open. There are several options controlling how all this works; see
334 the gnorb-bbdb user options section below for details.
336 @node BBDB posting styles
337 @chapter BBDB posting styles
339 Gnorb comes with a BBDB posting-style system, inspired by (copied
340 from) gnus-posting-styles. You can specify how messages are composed
341 to specific contacts, by matching on contact field values (the same
342 way gnus-posting-styles matches on group names). See the docstring of
343 `gnorb-bbdb-posting-styles' for details.
345 In order not to be too intrusive, Gnorb doesn't alter the behavior of
346 `bbdb-mail', the usual mail-composition function. Instead it provides
347 an alternate `gnorb-bbdb-mail', which does exactly the same thing, but
348 first processes the new mail according to `gnorb-bbdb-posting-styles'.
349 If you want to use this feature regularly, you can remap `bbdb-mail'
350 to `gnorb-bbdb-mail' in the `bbdb-mode-map'.
352 @node BBDB Org tagging
353 @chapter BBDB Org tagging
355 BBDB contacts can be tagged with the same tags you use in your Org
356 files. This allows you to pop up a *BBDB* buffer alongside your Org
357 Agenda when searching for certain tags. This can happen automatically
358 for all Org tags-todo searches, if you set the option
359 `gnorb-org-agenda-popup-bbdb' to t. Or you can do it manually, by
360 calling the command of the same name. This command only shows TODOs by
361 default: use a prefix argument to show all tagged headings.
363 Tags are stored in an xfield named org-tags, by default. You can
364 customize the name of this field using `gnorb-bbdb-org-tag-field'.
370 * Searching for messages from BBDB contacts::
371 * Citing BBDB contacts::
375 @node Searching for messages from BBDB contacts
376 @section Searching for messages from BBDB contacts
378 Call `gnorb-bbdb-mail-search' to search for all mail messages from the
379 record(s) displayed. Currently supports the notmuch, mairix, and
380 namazu search backends; set `gnorb-gnus-mail-search-backend' to one of
383 @node Citing BBDB contacts
384 @section Citing BBDB contacts
386 Calling `gnorb-bbdb-cite-contact' will prompt for a BBDB record and
387 insert a string of the type ``Bob Smith <bob@@smith.com>''.
390 @section User Options
393 @item `gnorb-bbdb-org-tag-field
394 The name of the BBDB xfield, as a
395 symbol, that holds Org-related tags. Specified as a string with
396 the ``:'' separator between tags, same as for Org headings.
398 @item `gnorb-bbdb-messages-field'
399 The name of the BBDB xfield that
400 holds links to recently-received messages from this contact.
401 Defaults to `messages.
402 @item `gnorb-bbdb-collect-N-messages'
403 Collect at most this many links
404 to messages from this contact. Defaults to 5.
405 @item `gnorb-bbdb-define-recent'
406 What does ``recently-received'' mean?
407 Possible values are the symbols seen and received. When set to
408 seen, the most recently-opened messages are collected. When set
409 to received, the most recently-received (by Date header) messages
410 are collected. Defaults to seen.
411 @item `gnorb-bbdb-message-link-format-multi'
412 How is a single message's
413 link formatted in the multi-line BBDB layout format? Defaults to
414 ``%:count. %D: %:subject'' (see the docstring for details).
415 @item ` gnorb-bbdb-message-link-format-one'
416 How is a single message's
417 link formatted in the one-line BBDB layout format? Defaults to
418 nil (see the docstring for details).
419 @item `gnorb-bbdb-posting-styles'
420 Styles to use for influencing the
421 format of mails composed to the BBDB record(s) under point (see
422 the docstring for details).
429 * Inserting BBDB links::
430 * User Options: User Optionsx.
433 @node Inserting BBDB links
434 @section Inserting BBDB links
436 Calling `gnorb-org-contact-link' will prompt for a BBDB record and
437 insert an Org link to that record at point.
440 @section User Options
443 @item `gnorb-org-after-message-setup-hook'
444 Hook run in a message buffer
445 after setting up the message, from `gnorb-org-handle-mail' or
446 `gnorb-org-email-subtree'.
447 @item `gnorb-org-trigger-actions'
448 List of potential actions that can be
449 taken on headings after a message is sent. See docstring for
451 @item `gnorb-org-mail-scan-scope'
452 The number of paragraphs to scan for
453 mail-related links. This comes into play when calling
454 `gnorb-org-handle-mail' on a heading with no associated messages,
455 or when `gnorb-org-handle-mail' is called with a prefix arg.
456 @item `gnorb-org-find-candidates-match'
457 When searching all Org files
458 for headings to collect messages from, this option can limit
459 which headings are searched. It is used as the second argument to
460 a call to `org-map-entries', and has the same syntax as that used
461 in an agenda tags view.
462 @item `gnorb-org-email-subtree-text-parameters'
464 parameters corresponding to the EXT-PLIST argument to the export
465 functions, for use when exporting to text.
466 @item `gnorb-org-email-subtree-file-parameters'
468 parameters corresponding to the EXT-PLIST argument to the export
469 functions, for use when exporting to a file.
470 @item `gnorb-org-email-subtree-text-options'
471 A list of ts and nils
472 corresponding to Org's export options, to be used when exporting
473 to text. The options, in order, are async, subtreep,
474 visible-only, and body-only.
475 @item `gnorb-org-email-subtree-file-options'
476 A list of ts and nils
477 corresponding to Org's export options, to be used when exporting
478 to a file. The options, in order, are async, subtreep,
479 visible-only, and body-only.
480 @item `gnorb-org-export-extensions'
481 Correspondence between export
482 backends and their respective (usual) file extensions.
483 @item `gnorb-org-capture-collect-link-p'
484 When this is set to t, the
485 capture process will always store a link to the Gnus message or
486 BBDB record under point, even when the link isn't part of the
487 capture template. It can then be added to the captured heading
488 with org-insert-link, as usual.
489 @item `gnorb-org-agenda-popup-bbdb'
490 Set to ``t'' to automatically pop up
491 the BBDB buffer displaying records corresponding to the Org
492 Agenda tags search underway. If this is nil you can always do it
493 manually with the command of the same name.
494 @item `gnorb-org-bbdb-popup-layout'
495 Controls the layout of the
496 Agenda-related BBDB popup, takes the same values as
504 * Viewing Org headlines relevant to a message::
505 * User Options: User Optionsxx.
508 @node Viewing Org headlines relevant to a message
509 @section Viewing Org headlines relevant to a message
511 Call `gnorb-gnus-view' on a message that is associated with an Org
512 heading to jump to that heading.
515 @section User Options
518 @item `gnorb-gnus-mail-search-backend'
519 Specifies the search backend
520 that you use for searching mails. Currently supports notmuch,
521 mairix, and namazu: set this option to one of those symbols.
522 @item `gnorb-gnus-capture-always-attach'
523 Treat all capture templates as
524 if they had the :gnus-attachments key set to ``t''. This only has
525 any effect if you're capturing from a Gnus summary or article
527 @item `gnorb-trigger-todo-default'
528 Set to either `note or `todo to tell
529 `gnorb-gnus-incoming-do-todo' what to do by default. You can
530 reach the non-default behavior by calling that function with a
531 prefix argument. Alternately, set to `prompt to always prompt for
532 the appropriate action.
533 @item `gnorb-gnus-trigger-refile-targets'
535 `gnorb-gnus-incoming-do-todo' on an incoming message, Gnorb will
536 try to locate a TODO heading that's relevant to that message. If
537 it can't, it will prompt you for one, using the refile interface.
538 This option will be used as the value of `org-refile-targets'
539 during that process: see the docstring of `org-refile-targets'
540 for the appropriate syntax.
541 @item `gnorb-gnus-new-todo-capture-key'
542 Set this to a single-character
543 string pointing at an Org capture template to use when creating
544 TODOs from outgoing messages. The template is a regular capture
545 template, with a few exceptions. If Gnus helps you archive
546 outgoing messages (ie you have `gnus-message-archive-group' set
547 to something, and your outgoing messages have a ``Fcc'' header), a
548 link to that message will be made, and you'll be able to use all
549 the escapes related to gnus messages. If you don't archive
550 outgoing messages, you'll still be able to use the %:subject,
551 %:to, %:toname, %:toaddress, and %:date escapes in the capture
553 @item `gnorb-gnus-hint-relevant-article'
554 Set to ``t'' (the default) to
555 have Gnorb give you a hint in the minibuffer when opening
556 messages that might be relevant to existing Org TODOs.
557 @item `gnorb-gnus-summary-mark-format-letter'
558 The formatting letter to
559 use as part of your `gnus-summary-line-format', to indicate
560 messages which might be relevant to Org TODOs. Defaults to ``g'',
561 meaning it should be used as ``%ug'' in the format line.
562 @item `gnorb-gnus-summary-mark'
563 The mark used to indicate relevant
564 messages in the Summary buffer, when
565 `gnorb-gnus-summary-mark-format-letter' is present in the format
566 line. Defaults to ``¡''.
569 @node Suggested Keybindings
570 @chapter Suggested Keybindings
573 (eval-after-load "gnorb-bbdb"
575 (define-key bbdb-mode-map (kbd "O") 'gnorb-bbdb-tag-agenda)
576 (define-key bbdb-mode-map (kbd "S") 'gnorb-bbdb-mail-search)
577 (define-key bbdb-mode-map [remap bbdb-mail] 'gnorb-bbdb-mail)
578 (define-key bbdb-mode-map (kbd "l") 'gnorb-bbdb-open-link)
579 (global-set-key (kbd "C-c C") 'gnorb-bbdb-cite-contact)))
581 (eval-after-load "gnorb-org"
583 (org-defkey org-mode-map (kbd "C-c C") 'gnorb-org-contact-link)
584 (org-defkey org-mode-map (kbd "C-c t") 'gnorb-org-handle-mail)
585 (org-defkey org-mode-map (kbd "C-c e") 'gnorb-org-view)
586 (org-defkey org-mode-map (kbd "C-c E") 'gnorb-org-email-subtree)
587 (org-defkey org-mode-map (kbd "C-c V") 'gnorb-org-popup-bbdb)
588 (setq gnorb-org-agenda-popup-bbdb t)
589 (eval-after-load "org-agenda"
590 '(progn (org-defkey org-agenda-mode-map (kbd "H") 'gnorb-org-handle-mail)
591 (org-defkey org-agenda-mode-map (kbd "V") 'gnorb-org-popup-bbdb)))))
593 (eval-after-load "gnorb-gnus"
595 (define-key gnus-summary-mime-map "a" 'gnorb-gnus-article-org-attach)
596 (define-key gnus-summary-mode-map (kbd "C-c t") 'gnorb-gnus-incoming-do-todo)
597 (push '("attach to org heading" . gnorb-gnus-mime-org-attach)
598 gnus-mime-action-alist)
599 ;; The only way to add mime button command keys is by redefining
600 ;; gnus-mime-button-map, possibly not ideal. Ideal would be a
601 ;; setter function in gnus itself.
602 (push '(gnorb-gnus-mime-org-attach "a" "Attach to Org heading")
603 gnus-mime-button-commands)
604 (setq gnus-mime-button-map
605 (let ((map (make-sparse-keymap)))
606 (define-key map gnus-mouse-2 'gnus-article-push-button)
607 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
608 (dolist (c gnus-mime-button-commands)
609 (define-key map (cadr c) (car c)))
612 (eval-after-load "message"
614 (define-key message-mode-map (kbd "C-c t") 'gnorb-gnus-outgoing-do-todo)))
618 @chapter Wishlist/TODO
622 Provide a command that, when in the Org Agenda, does an email search
623 for messages received in the visible date span, or day under point,
624 etc. Make it work in the calendar, as well?
626 Add trigger actions that create new sibling or child headings on the
627 original Org heading.
629 Allow tagging of Gnus messages, by giving the message's registry
630 entry an `org-tags key.
632 Provide persistent nngnorb search groups.
634 Allow automatic org-tagging of BBDB contacts: when messages from a
635 contact are associated with an Org heading, make it possible for the
636 contact to inherit that heading's tags automatically.
638 Provide completion when setting Org tags on a BBDB contact.
640 Provide a `gnorb-bbdb-view' command that opens a *Summary* buffer
641 containing all the tracked messages from the contact(s) under point.
643 Provide a `gnorb-view' command that takes a tags-todo search phrase
644 (or a single Org heading ID), finds all relevant messages, Org
645 headings, and BBDB records, and sets up a four-pane view: Org
646 Agenda, **Article* SummaryBBDB* buffer, Gnus *buffer, and an *
653 @c Emacs 25.0.50.8 (Org mode 8.3beta)