X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=479b39f1fb81bd0c8a9d1b8f84c580cfa14cce58;hb=4f4ec48df25c8d2963e7124d2781b13e5a7f6a78;hp=d2e87b1b1256f5aaa456b726df8667e13cead700;hpb=9ca1f945d9f5030600dc14ffff10d4dad14db4ca;p=notmuch diff --git a/emacs/notmuch.el b/emacs/notmuch.el index d2e87b1b..479b39f1 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -88,18 +88,21 @@ ("authors" . "%-20s ") ("subject" . "%s ") ("tags" . "(%s)")) - "Search result formatting. Supported fields are: - date, count, authors, subject, tags + "Search result formatting. + +Supported fields are: date, count, authors, subject, tags. For example: - (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\) - \(\"subject\" . \"%s\"\)\)\) + (setq notmuch-search-result-format + '((\"authors\" . \"%-40s\") + (\"subject\" . \"%s\"))) + Line breaks are permitted in format strings (though this is currently experimental). Note that a line break at the end of an \"authors\" field will get elided if the authors list is long; place it instead at the beginning of the following field. To enter a line break when setting this variable with setq, use \\n. To enter a line break in customize, press \\[quoted-insert] C-j." - :type '(alist :key-type (string) :value-type (string)) + :type '(alist :key-type string :value-type string) :group 'notmuch-search) ;; The name of this variable `notmuch-init-file' is consistent with the @@ -577,7 +580,7 @@ thread." (notmuch-search-foreach-result beg end (lambda (pos) (setq output (append output (notmuch-search-get-tags pos))))) - output)) + (delete-dups output))) (defun notmuch-search-interactive-tag-changes (&optional initial-input) "Prompt for tag changes for the current thread or region. @@ -814,13 +817,13 @@ non-authors is found, assume that all of the authors match." (setq invisible-string (notmuch-search-author-propertize invisible-string))) ;; If there is any invisible text, add it as a tooltip to the ;; visible text. - (unless (string= invisible-string "") + (unless (string-empty-p 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) - (unless (string= invisible-string "") + (unless (string-empty-p invisible-string) (let ((start (point)) overlay) (insert invisible-string) @@ -830,26 +833,28 @@ non-authors is found, assume that all of the authors match." (insert padding)))) (defun notmuch-search-insert-field (field format-string result) - (cond - ((string-equal field "date") - (insert (propertize (format format-string (plist-get result :date_relative)) - 'face 'notmuch-search-date))) - ((string-equal field "count") - (insert (propertize (format format-string - (format "[%s/%s]" (plist-get result :matched) - (plist-get result :total))) - 'face 'notmuch-search-count))) - ((string-equal field "subject") - (insert (propertize (format format-string - (notmuch-sanitize (plist-get result :subject))) - 'face 'notmuch-search-subject))) - ((string-equal field "authors") - (notmuch-search-insert-authors - format-string (notmuch-sanitize (plist-get result :authors)))) - ((string-equal field "tags") - (let ((tags (plist-get result :tags)) - (orig-tags (plist-get result :orig-tags))) - (insert (format format-string (notmuch-tag-format-tags tags orig-tags))))))) + (pcase field + ((pred functionp) + (insert (funcall field format-string result))) + ("date" + (insert (propertize (format format-string (plist-get result :date_relative)) + 'face 'notmuch-search-date))) + ("count" + (insert (propertize (format format-string + (format "[%s/%s]" (plist-get result :matched) + (plist-get result :total))) + 'face 'notmuch-search-count))) + ("subject" + (insert (propertize (format format-string + (notmuch-sanitize (plist-get result :subject))) + 'face 'notmuch-search-subject))) + ("authors" + (notmuch-search-insert-authors format-string + (notmuch-sanitize (plist-get result :authors)))) + ("tags" + (let ((tags (plist-get result :tags)) + (orig-tags (plist-get result :orig-tags))) + (insert (format format-string (notmuch-tag-format-tags tags orig-tags))))))) (defun notmuch-search-show-result (result pos) "Insert RESULT at POS." @@ -973,7 +978,8 @@ PROMPT is the string to prompt with." (put 'notmuch-search 'notmuch-doc "Search for messages.") ;;;###autoload -(defun notmuch-search (&optional query oldest-first target-thread target-line no-display) +(defun notmuch-search (&optional query oldest-first target-thread target-line + no-display) "Display threads matching QUERY in a notmuch-search buffer. If QUERY is nil, it is read interactively from the minibuffer. @@ -1019,7 +1025,7 @@ the configured default sort order." (save-excursion (let ((proc (notmuch-start-notmuch "notmuch-search" buffer #'notmuch-search-process-sentinel - "search" "--format=sexp" "--format-version=4" + "search" "--format=sexp" "--format-version=5" (if oldest-first "--sort=oldest-first" "--sort=newest-first") @@ -1162,8 +1168,6 @@ Point should be at the beginning of the line." ;;; _ -(setq mail-user-agent 'notmuch-user-agent) - (provide 'notmuch) ;; After provide to avoid loops if notmuch was require'd via notmuch-init-file.