]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.el
notmuch.el: Don't use literal control characters in strings.
[notmuch] / notmuch.el
index 1934ddfc4febf36e625dd67fd0486ddcbf2b6910..cbb240f31eab688920134989edde5e3e58b82420 100644 (file)
@@ -71,17 +71,17 @@ 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    "\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-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]*\\) ")
@@ -249,18 +249,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" 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.
@@ -651,6 +654,12 @@ view, (remove the \"inbox\" tag from each), with
   :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 ()
@@ -658,6 +667,9 @@ view, (remove the \"inbox\" tag from each), with
   (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.
@@ -708,6 +720,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)
@@ -824,6 +837,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.
 
@@ -901,7 +920,8 @@ This function advances point to the next line when finished."
            (call-process "notmuch" nil t nil "search" "--sort=oldest-first" query)
          (call-process "notmuch" 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.
@@ -962,4 +982,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)