X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.el;h=4b2936a9645b980b8654ec71788e010c17ab3c0b;hp=014d15bc85508edf392fe15171c5eec9a4004add;hb=5d0a01dceb67e9bdcb95bcb2328baef5e7ea7d52;hpb=2ce25b93a72b4a8d6daa5321f9ef7df0772a789f diff --git a/notmuch.el b/notmuch.el index 014d15bc..4b2936a9 100644 --- a/notmuch.el +++ b/notmuch.el @@ -53,6 +53,7 @@ (define-key map (kbd "DEL") 'notmuch-show-rewind) (define-key map " " 'notmuch-show-advance-marking-read-and-archiving) (define-key map "|" 'notmuch-show-pipe-message) + (define-key map "?" 'describe-mode) map) "Keymap for \"notmuch show\" buffers.") (fset 'notmuch-show-mode-map notmuch-show-mode-map) @@ -70,17 +71,20 @@ pattern can still test against the entire line).") (defvar notmuch-show-signature-lines-max 12 "Maximum length of signature that will be hidden by default.") -(set 'notmuch-show-message-begin-regexp " message{") -(set 'notmuch-show-message-end-regexp " message}") -(set 'notmuch-show-header-begin-regexp " header{") -(set 'notmuch-show-header-end-regexp " header}") -(set 'notmuch-show-body-begin-regexp " body{") -(set 'notmuch-show-body-end-regexp " body}") -(set 'notmuch-show-attachment-begin-regexp " attachment{") -(set 'notmuch-show-attachment-end-regexp " attachment}") -(set 'notmuch-show-part-begin-regexp " part{") -(set 'notmuch-show-part-end-regexp " part}") -(set 'notmuch-show-marker-regexp " \\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$") +(defvar notmuch-command "notmuch" + "Command to run the notmuch binary.") + +(set 'notmuch-show-message-begin-regexp "\fmessage{") +(set 'notmuch-show-message-end-regexp "\fmessage}") +(set 'notmuch-show-header-begin-regexp "\fheader{") +(set 'notmuch-show-header-end-regexp "\fheader}") +(set 'notmuch-show-body-begin-regexp "\fbody{") +(set 'notmuch-show-body-end-regexp "\fbody}") +(set 'notmuch-show-attachment-begin-regexp "\fattachment{") +(set 'notmuch-show-attachment-end-regexp "\fattachment}") +(set 'notmuch-show-part-begin-regexp "\fpart{") +(set 'notmuch-show-part-end-regexp "\fpart}") +(set 'notmuch-show-marker-regexp "\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$") (set 'notmuch-show-id-regexp "\\(id:[^ ]*\\)") (set 'notmuch-show-depth-regexp " depth:\\([0-9]*\\) ") @@ -248,18 +252,21 @@ buffer." (mm-display-parts (mm-dissect-buffer)) (kill-this-buffer)))) +(defun notmuch-reply (query-string) + (switch-to-buffer (generate-new-buffer "notmuch-draft")) + (call-process notmuch-command nil t nil "reply" query-string) + (goto-char (point-min)) + (if (re-search-forward "^$" nil t) + (progn + (insert "--text follows this line--") + (forward-line))) + (message-mode)) + (defun notmuch-show-reply () "Begin composing a reply to the current message in a new buffer." (interactive) (let ((message-id (notmuch-show-get-message-id))) - (switch-to-buffer (generate-new-buffer "notmuch-draft")) - (call-process "notmuch" nil t nil "reply" message-id) - (goto-char (point-min)) - (if (re-search-forward "^$" nil t) - (progn - (insert "--text follows this line--") - (forward-line))) - (message-mode))) + (notmuch-reply message-id))) (defun notmuch-show-pipe-message (command) "Pipe the contents of the current message to the given command. @@ -638,6 +645,35 @@ view, (remove the \"inbox\" tag from each), with mode-name "notmuch-show") (setq buffer-read-only t)) +;;;###autoload + +(defgroup notmuch nil + "Notmuch mail reader for Emacs." + :group 'mail) + +(defcustom notmuch-show-hook nil + "List of functions to call when notmuch displays a message." + :type 'hook + :options '(goto-address) + :group 'notmuch) + +(defcustom notmuch-search-hook nil + "List of functions to call when notmuch displays the search results." + :type 'hook + :options '(hl-line-mode) + :group 'notmuch) + +; Make show mode a bit prettier, highlighting URLs and using word wrap + +(defun notmuch-show-pretty-hook () + (goto-address-mode 1) + (visual-line-mode)) + +(add-hook 'notmuch-show-hook 'notmuch-show-pretty-hook) +(add-hook 'notmuch-search-hook + (lambda() + (hl-line-mode 1) )) + (defun notmuch-show (thread-id &optional parent-buffer) "Run \"notmuch show\" with the given thread ID and display results. @@ -657,9 +693,10 @@ thread from that buffer can be show when done with this one)." (erase-buffer) (goto-char (point-min)) (save-excursion - (call-process "notmuch" nil t nil "show" thread-id) + (call-process notmuch-command nil t nil "show" thread-id) (notmuch-show-markup-messages) ) + (run-hooks 'notmuch-show-hook) ; Move straight to the first unread message (if (not (notmuch-show-message-unread-p)) (progn @@ -686,6 +723,7 @@ thread from that buffer can be show when done with this one)." (define-key map "o" 'notmuch-search-toggle-order) (define-key map "p" 'previous-line) (define-key map "q" 'kill-this-buffer) + (define-key map "r" 'notmuch-search-reply-to-thread) (define-key map "s" 'notmuch-search) (define-key map "t" 'notmuch-search-filter-by-tag) (define-key map "x" 'kill-this-buffer) @@ -698,6 +736,7 @@ thread from that buffer can be show when done with this one)." (define-key map "\M->" 'notmuch-search-goto-last-thread) (define-key map " " 'notmuch-search-scroll-up) (define-key map (kbd "") 'notmuch-search-scroll-down) + (define-key map "?" 'describe-mode) map) "Keymap for \"notmuch search\" buffers.") (fset 'notmuch-search-mode-map notmuch-search-mode-map) @@ -757,6 +796,7 @@ global search. (set (make-local-variable 'scroll-preserve-screen-position) t) (add-to-invisibility-spec 'notmuch-search) (use-local-map notmuch-search-mode-map) + (setq truncate-lines t) (setq major-mode 'notmuch-search-mode mode-name "notmuch-search") (setq buffer-read-only t)) @@ -800,6 +840,12 @@ global search. (notmuch-show thread-id (current-buffer)) (error "End of search results")))) +(defun notmuch-search-reply-to-thread () + "Begin composing a reply to the entire current thread in a new buffer." + (interactive) + (let ((message-id (notmuch-search-find-thread-id))) + (notmuch-reply message-id))) + (defun notmuch-call-notmuch-process (&rest args) "Synchronously invoke \"notmuch\" with the given list of arguments. @@ -808,7 +854,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (let ((error-buffer (get-buffer-create "*Notmuch errors*"))) (with-current-buffer error-buffer (erase-buffer)) - (if (eq (apply 'call-process "notmuch" nil error-buffer nil args) 0) + (if (eq (apply 'call-process notmuch-command nil error-buffer nil args) 0) (point) (progn (with-current-buffer error-buffer @@ -874,10 +920,11 @@ This function advances point to the next line when finished." (goto-char (point-min)) (save-excursion (if oldest-first - (call-process "notmuch" nil t nil "search" "--sort=oldest-first" query) - (call-process "notmuch" nil t nil "search" "--sort=newest-first" query)) + (call-process notmuch-command nil t nil "search" "--sort=oldest-first" query) + (call-process notmuch-command nil t nil "search" "--sort=newest-first" query)) (notmuch-search-markup-thread-ids) - )))) + )) + (run-hooks 'notmuch-search-hook))) (defun notmuch-search-refresh-view () "Refresh the current view. @@ -938,4 +985,6 @@ current search results AND that are tagged with the given tag." (interactive) (notmuch-search "tag:inbox" t)) +(setq mail-user-agent 'message-user-agent) + (provide 'notmuch)