X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=40b730df52459d58913340595312f9ec1875c07c;hb=25a8873c68f9ef033d393efaf7f4c46a29f798f4;hp=c4ee9e6321a14cf640a822b629950d262d666c8d;hpb=16b2db0986ce0ed7c420a69d0a98bb41e9ca4bd8;p=notmuch diff --git a/emacs/notmuch.el b/emacs/notmuch.el index c4ee9e63..40b730df 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -70,6 +70,8 @@ (require 'mm-view) (require 'message) +(require 'hl-line) + (require 'notmuch-lib) (require 'notmuch-tag) (require 'notmuch-show) @@ -114,8 +116,12 @@ there will be called at other points of notmuch execution." :type 'file :group 'notmuch) -(defvar notmuch-query-history nil - "Variable to store minibuffer history for notmuch queries.") +(defcustom notmuch-search-hook '(notmuch-hl-line-mode) + "List of functions to call when notmuch displays the search results." + :type 'hook + :options '(notmuch-hl-line-mode) + :group 'notmuch-search + :group 'notmuch-hooks) ;;; Mime Utilities @@ -155,24 +161,6 @@ there will be called at other points of notmuch execution." (mm-save-part p)))) mm-handle)) -;;; Integrations - -(require 'hl-line) - -(defun notmuch-hl-line-mode () - (prog1 (hl-line-mode) - (when hl-line-overlay - (overlay-put hl-line-overlay 'priority 1)))) - -;;; Options - -(defcustom notmuch-search-hook '(notmuch-hl-line-mode) - "List of functions to call when notmuch displays the search results." - :type 'hook - :options '(notmuch-hl-line-mode) - :group 'notmuch-search - :group 'notmuch-hooks) - ;;; Keymap (defvar notmuch-search-mode-map @@ -205,6 +193,15 @@ there will be called at other points of notmuch execution." map) "Keymap for \"notmuch search\" buffers.") +;;; Internal Variables + +(defvar notmuch-query-history nil + "Variable to store minibuffer history for notmuch queries.") + +(defvar-local notmuch-search-query-string nil) +(defvar-local notmuch-search-target-thread nil) +(defvar-local notmuch-search-target-line nil) + ;;; Stashing (defvar notmuch-search-stash-map @@ -224,15 +221,7 @@ there will be called at other points of notmuch execution." (defun notmuch-stash-query () "Copy current query to kill-ring." (interactive) - (notmuch-common-do-stash (notmuch-search-get-query))) - -;;; Variables - -(defvar notmuch-search-query-string) -(defvar notmuch-search-target-thread) -(defvar notmuch-search-target-line) - -(defvar notmuch-search-disjunctive-regexp "\\<[oO][rR]\\>") + (notmuch-common-do-stash notmuch-search-query-string)) ;;; Movement @@ -406,10 +395,6 @@ new, global search. Complete list of currently available key bindings: \\{notmuch-search-mode-map}" - (make-local-variable 'notmuch-search-query-string) - (make-local-variable 'notmuch-search-oldest-first) - (make-local-variable 'notmuch-search-target-thread) - (make-local-variable 'notmuch-search-target-line) (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view) (setq-local scroll-preserve-screen-position t) (add-to-invisibility-spec (cons 'ellipsis t)) @@ -494,7 +479,7 @@ If BARE is set then do not prefix with \"thread:\"." (defun notmuch-search-find-stable-query () "Return the stable queries for the current thread. -This returns a list (MATCHED-QUERY UNMATCHED-QUERY) for the +Return a list (MATCHED-QUERY UNMATCHED-QUERY) for the matched and unmatched messages in the current thread." (plist-get (notmuch-search-get-result) :query)) @@ -599,7 +584,7 @@ thread." (defun notmuch-search-interactive-tag-changes (&optional initial-input) "Prompt for tag changes for the current thread or region. -Returns (TAG-CHANGES REGION-BEGIN REGION-END)." +Return (TAG-CHANGES REGION-BEGIN REGION-END)." (pcase-let ((`(,beg ,end) (notmuch-interactive-region))) (list (notmuch-read-tag-changes (notmuch-search-get-tags-region beg end) (if (= beg end) "Tag thread" "Tag region") @@ -1079,10 +1064,8 @@ default sort order is defined by `notmuch-search-oldest-first'." (defun notmuch-group-disjunctive-query-string (query-string) "Group query if it contains a complex expression. - -Enclose QUERY-STRING in parentheses if it matches -`notmuch-search-disjunctive-regexp'." - (if (string-match-p notmuch-search-disjunctive-regexp query-string) +Enclose QUERY-STRING in parentheses if contains \"OR\" operators." + (if (string-match-p "\\<[oO][rR]\\>" query-string) (concat "( " query-string " )") query-string)) @@ -1101,10 +1084,10 @@ current search results AND the additional query string provided." notmuch-search-oldest-first))) (defun notmuch-search-filter-by-tag (tag) - "Filter the current search results based on a single tag. + "Filter the current search results based on a single TAG. -Runs a new search matching only messages that match both the -current search results AND that are tagged with the given tag." +Run a new search matching only messages that match the current +search results and that are also tagged with the given TAG." (interactive (list (notmuch-select-tag-with-completion "Filter by tag: " notmuch-search-query-string))) @@ -1124,7 +1107,7 @@ current search results AND that are tagged with the given tag." (notmuch-hello)) (defun notmuch-interesting-buffer (b) - "Is the current buffer of interest to a notmuch user?" + "Whether the current buffer's major-mode is a notmuch mode." (with-current-buffer b (memq major-mode '(notmuch-show-mode notmuch-search-mode @@ -1136,8 +1119,8 @@ current search results AND that are tagged with the given tag." (defun notmuch-cycle-notmuch-buffers () "Cycle through any existing notmuch buffers (search, show or hello). -If the current buffer is the only notmuch buffer, bury it. If no -notmuch buffers exist, run `notmuch'." +If the current buffer is the only notmuch buffer, bury it. +If no notmuch buffers exist, run `notmuch'." (interactive) (let (start first) ;; If the current buffer is a notmuch buffer, remember it and then @@ -1158,19 +1141,25 @@ notmuch buffers exist, run `notmuch'." (pop-to-buffer-same-window first)) (notmuch)))) -;;; Imenu Support +;;; Integrations +;;;; Hl-line Support + +(defun notmuch-hl-line-mode () + (prog1 (hl-line-mode) + (when hl-line-overlay + (overlay-put hl-line-overlay 'priority 1)))) + +;;;; Imenu Support (defun notmuch-search-imenu-prev-index-position-function () "Move point to previous message in notmuch-search buffer. -This function is used as a value for -`imenu-prev-index-position-function'." +Used as`imenu-prev-index-position-function' in notmuch buffers." (notmuch-search-previous-thread)) (defun notmuch-search-imenu-extract-index-name-function () "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." +Used as `imenu-extract-index-name-function' in notmuch buffers. +Point should be at the beginning of the line." (let ((subject (notmuch-search-find-subject)) (author (notmuch-search-find-authors))) (format "%s (%s)" subject author)))