]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch.el
emacs: Shorten long lines
[notmuch] / emacs / notmuch.el
index a980c7a212358a9e54943d90b1a3b4bcbd9e3e45..07a58da73931dc26c841d493e46856737d5b580c 100644 (file)
@@ -113,7 +113,7 @@ there will be called at other points of notmuch execution."
   :group 'notmuch)
 
 (defvar notmuch-query-history nil
   :group 'notmuch)
 
 (defvar notmuch-query-history nil
-  "Variable to store minibuffer history for notmuch queries")
+  "Variable to store minibuffer history for notmuch queries.")
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
@@ -202,7 +202,7 @@ there will be called at other points of notmuch execution."
     (define-key map "q" 'notmuch-stash-query)
     (define-key map "?" 'notmuch-subkeymap-help)
     map)
     (define-key map "q" 'notmuch-stash-query)
     (define-key map "?" 'notmuch-subkeymap-help)
     map)
-  "Submap for stash commands")
+  "Submap for stash commands.")
 (fset 'notmuch-search-stash-map notmuch-search-stash-map)
 
 (defun notmuch-search-stash-thread-id ()
 (fset 'notmuch-search-stash-map notmuch-search-stash-map)
 
 (defun notmuch-search-stash-thread-id ()
@@ -417,7 +417,7 @@ If there is no thread at POS (or point), returns nil."
 
 The returned point will be just after the newline character that
 ends the result line.  If there is no thread at POS (or point),
 
 The returned point will be just after the newline character that
 ends the result line.  If there is no thread at POS (or point),
-returns nil"
+returns nil."
   (when (notmuch-search-get-result pos)
     (next-single-property-change (or pos (point)) 'notmuch-search-result
                                 nil (point-max))))
   (when (notmuch-search-get-result pos)
     (next-single-property-change (or pos (point)) 'notmuch-search-result
                                 nil (point-max))))
@@ -457,9 +457,9 @@ BEG."
     output))
 
 (defun notmuch-search-find-thread-id (&optional bare)
     output))
 
 (defun notmuch-search-find-thread-id (&optional bare)
-  "Return the thread for the current thread
+  "Return the thread for the current thread.
 
 
-If BARE is set then do not prefix with \"thread:\""
+If BARE is set then do not prefix with \"thread:\"."
   (let ((thread (plist-get (notmuch-search-get-result) :thread)))
     (when thread (concat (unless bare "thread:") thread))))
 
   (let ((thread (plist-get (notmuch-search-get-result) :thread)))
     (when thread (concat (unless bare "thread:") thread))))
 
@@ -486,19 +486,19 @@ no messages in the region then return nil."
       (concat "(" (mapconcat 'identity query-list ") or (") ")"))))
 
 (defun notmuch-search-find-authors ()
       (concat "(" (mapconcat 'identity query-list ") or (") ")"))))
 
 (defun notmuch-search-find-authors ()
-  "Return the authors for the current thread"
+  "Return the authors for the current thread."
   (plist-get (notmuch-search-get-result) :authors))
 
 (defun notmuch-search-find-authors-region (beg end)
   (plist-get (notmuch-search-get-result) :authors))
 
 (defun notmuch-search-find-authors-region (beg end)
-  "Return a list of authors for the current region"
+  "Return a list of authors for the current region."
   (notmuch-search-properties-in-region :authors beg end))
 
 (defun notmuch-search-find-subject ()
   (notmuch-search-properties-in-region :authors beg end))
 
 (defun notmuch-search-find-subject ()
-  "Return the subject for the current thread"
+  "Return the subject for the current thread."
   (plist-get (notmuch-search-get-result) :subject))
 
 (defun notmuch-search-find-subject-region (beg end)
   (plist-get (notmuch-search-get-result) :subject))
 
 (defun notmuch-search-find-subject-region (beg end)
-  "Return a list of authors for the current region"
+  "Return a list of authors for the current region."
   (notmuch-search-properties-in-region :subject beg end))
 
 (defun notmuch-search-show-thread (&optional elide-toggle)
   (notmuch-search-properties-in-region :subject beg end))
 
 (defun notmuch-search-show-thread (&optional elide-toggle)
@@ -516,26 +516,28 @@ thread."
                      (current-buffer)
                      notmuch-search-query-string
                      ;; Name the buffer based on the subject.
                      (current-buffer)
                      notmuch-search-query-string
                      ;; Name the buffer based on the subject.
-                     (concat "*" (truncate-string-to-width subject 30 nil nil t) "*"))
+                     (concat "*"
+                             (truncate-string-to-width subject 30 nil nil t)
+                             "*"))
       (message "End of search results."))))
 
 (defun notmuch-tree-from-search-current-query ()
       (message "End of search results."))))
 
 (defun notmuch-tree-from-search-current-query ()
-  "Call notmuch tree with the current query"
+  "Call notmuch tree with the current query."
   (interactive)
   (notmuch-tree notmuch-search-query-string))
 
 (defun notmuch-unthreaded-from-search-current-query ()
   (interactive)
   (notmuch-tree notmuch-search-query-string))
 
 (defun notmuch-unthreaded-from-search-current-query ()
-  "Call notmuch tree with the current query"
+  "Call notmuch tree with the current query."
   (interactive)
   (notmuch-unthreaded notmuch-search-query-string))
 
 (defun notmuch-tree-from-search-thread ()
   (interactive)
   (notmuch-unthreaded notmuch-search-query-string))
 
 (defun notmuch-tree-from-search-thread ()
-  "Show the selected thread with notmuch-tree"
+  "Show the selected thread with notmuch-tree."
   (interactive)
   (notmuch-tree (notmuch-search-find-thread-id)
   (interactive)
   (notmuch-tree (notmuch-search-find-thread-id)
-                notmuch-search-query-string
+               notmuch-search-query-string
                nil
                nil
-                (notmuch-prettify-subject (notmuch-search-find-subject))
+               (notmuch-prettify-subject (notmuch-search-find-subject))
                t))
 
 (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)
                t))
 
 (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)
@@ -660,7 +662,7 @@ of the result."
        (goto-char new-point)))))
 
 (defun notmuch-search-process-sentinel (proc msg)
        (goto-char new-point)))))
 
 (defun notmuch-search-process-sentinel (proc msg)
-  "Add a message to let user know when \"notmuch search\" exits"
+  "Add a message to let user know when \"notmuch search\" exits."
   (let ((buffer (process-buffer proc))
        (status (process-status proc))
        (exit-status (process-exit-status proc))
   (let ((buffer (process-buffer proc))
        (status (process-status proc))
        (exit-status (process-exit-status proc))
@@ -800,7 +802,9 @@ non-authors is found, assume that all of the authors match."
       ;; If there is any invisible text, add it as a tooltip to the
       ;; visible text.
       (when (not (string= invisible-string ""))
       ;; If there is any invisible text, add it as a tooltip to the
       ;; visible text.
       (when (not (string= invisible-string ""))
-       (setq visible-string (propertize visible-string 'help-echo (concat "..." invisible-string))))
+       (setq visible-string
+             (propertize visible-string
+                         'help-echo (concat "..." invisible-string))))
 
       ;; Insert the visible and, if present, invisible author strings.
       (insert visible-string)
 
       ;; Insert the visible and, if present, invisible author strings.
       (insert visible-string)
@@ -862,7 +866,7 @@ sets the :orig-tag property."
       (goto-char pos))))
 
 (defun notmuch-search-process-filter (proc string)
       (goto-char pos))))
 
 (defun notmuch-search-process-filter (proc string)
-  "Process and filter the output of \"notmuch search\""
+  "Process and filter the output of \"notmuch search\"."
   (let ((results-buf (process-buffer proc))
        (parse-buf (process-get proc 'parse-buf))
        (inhibit-read-only t)
   (let ((results-buf (process-buffer proc))
        (parse-buf (process-get proc 'parse-buf))
        (inhibit-read-only t)
@@ -892,7 +896,8 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
                (longest-length 0))
            (cl-loop for tuple in notmuch-saved-searches
                     if (let ((quoted-query
                (longest-length 0))
            (cl-loop for tuple in notmuch-saved-searches
                     if (let ((quoted-query
-                              (regexp-quote (notmuch-saved-search-get tuple :query))))
+                              (regexp-quote
+                               (notmuch-saved-search-get tuple :query))))
                          (and (string-match (concat "^" quoted-query) query)
                               (> (length (match-string 0 query))
                                  longest-length)))
                          (and (string-match (concat "^" quoted-query) query)
                               (> (length (match-string 0 query))
                                  longest-length)))
@@ -905,9 +910,10 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
           (concat "*notmuch-saved-search-" saved-search-name "*"))
          (saved-search
           (concat "*notmuch-search-"
           (concat "*notmuch-saved-search-" saved-search-name "*"))
          (saved-search
           (concat "*notmuch-search-"
-                  (replace-regexp-in-string (concat "^" (regexp-quote saved-search-query))
-                                            (concat "[ " saved-search-name " ]")
-                                            query)
+                  (replace-regexp-in-string
+                   (concat "^" (regexp-quote saved-search-query))
+                   (concat "[ " saved-search-name " ]")
+                   query)
                   "*"))
          (t
           (concat "*notmuch-search-" query "*"))
                   "*"))
          (t
           (concat "*notmuch-search-" query "*"))
@@ -926,7 +932,8 @@ PROMPT is the string to prompt with."
                       "subject:" "attachment:")
                 (mapcar (lambda (tag) (concat "tag:" tag)) all-tags)
                 (mapcar (lambda (tag) (concat "is:" tag)) all-tags)
                       "subject:" "attachment:")
                 (mapcar (lambda (tag) (concat "tag:" tag)) all-tags)
                 (mapcar (lambda (tag) (concat "is:" tag)) all-tags)
-                (mapcar (lambda (mimetype) (concat "mimetype:" mimetype)) (mailcap-mime-types)))))
+                (mapcar (lambda (mimetype) (concat "mimetype:" mimetype))
+                        (mailcap-mime-types)))))
     (let ((keymap (copy-keymap minibuffer-local-map))
          (current-query (cl-case major-mode
                           (notmuch-search-mode (notmuch-search-get-query))
     (let ((keymap (copy-keymap minibuffer-local-map))
          (current-query (cl-case major-mode
                           (notmuch-search-mode (notmuch-search-get-query))
@@ -952,7 +959,7 @@ PROMPT is the string to prompt with."
                              'notmuch-search-history current-query nil)))))
 
 (defun notmuch-search-get-query ()
                              'notmuch-search-history current-query nil)))))
 
 (defun notmuch-search-get-query ()
-  "Return the current query in this search buffer"
+  "Return the current query in this search buffer."
   notmuch-search-query-string)
 
 (put 'notmuch-search 'notmuch-doc "Search for messages.")
   notmuch-search-query-string)
 
 (put 'notmuch-search 'notmuch-doc "Search for messages.")
@@ -987,7 +994,11 @@ the configured default sort order."
     (if no-display
        (set-buffer buffer)
       (switch-to-buffer buffer))
     (if no-display
        (set-buffer buffer)
       (switch-to-buffer buffer))
-    (notmuch-search-mode)
+    ;; avoid wiping out third party buffer-local variables in the case
+    ;; where we're just refreshing or changing the sort order of an
+    ;; existing search results buffer
+    (unless (eq major-mode 'notmuch-search-mode)
+      (notmuch-search-mode))
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
     (set 'notmuch-search-query-string query)
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
     (set 'notmuch-search-query-string query)
@@ -1074,8 +1085,10 @@ current search results AND the additional query string provided."
 Runs a new search matching only messages that match both the
 current search results AND that are tagged with the given tag."
   (interactive
 Runs a new search matching only messages that match both the
 current search results AND that are tagged with the given tag."
   (interactive
-   (list (notmuch-select-tag-with-completion "Filter by tag: " notmuch-search-query-string)))
-  (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first))
+   (list (notmuch-select-tag-with-completion "Filter by tag: "
+                                            notmuch-search-query-string)))
+  (notmuch-search (concat notmuch-search-query-string " and tag:" tag)
+                 notmuch-search-oldest-first))
 
 (defun notmuch-search-by-tag (tag)
   "Display threads matching TAG in a notmuch-search buffer."
 
 (defun notmuch-search-by-tag (tag)
   "Display threads matching TAG in a notmuch-search buffer."
@@ -1148,8 +1161,6 @@ beginning of the line."
 
 ;; After provide to avoid loops if notmuch was require'd via notmuch-init-file.
 (if init-file-user ; don't load init file if the -q option was used.
 
 ;; After provide to avoid loops if notmuch was require'd via notmuch-init-file.
 (if init-file-user ; don't load init file if the -q option was used.
-    (let ((init-file (locate-file notmuch-init-file '("/")
-                                 (get-load-suffixes))))
-      (if init-file (load init-file nil t t))))
+    (load notmuch-init-file t t nil t))
 
 ;;; notmuch.el ends here
 
 ;;; notmuch.el ends here