X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-lib.el;h=85950da14f49ab40d0508c628cd6aa6d3358e2a7;hp=822387ddee860173a9022b2bdbf83e09c79119f7;hb=abd4d6b92e488109a155fdee27285e6df485c583;hpb=9cf89a3c049bce8374333ad69d97e78a6c6d8b2d diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 822387dd..85950da1 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -112,13 +112,25 @@ For example, if you wanted to remove an \"inbox\" tag and add an (select-window (posn-window (event-start last-input-event))) (button-activate button))) +(defun notmuch-command-to-string (&rest args) + "Synchronously invoke \"notmuch\" with the given list of arguments. + +If notmuch exits with a non-zero status, output from the process +will appear in a buffer named \"*Notmuch errors*\" and an error +will be signaled. + +Otherwise the output will be returned" + (with-temp-buffer + (let* ((status (apply #'call-process notmuch-command nil t nil args)) + (output (buffer-string))) + (notmuch-check-exit-status status (cons notmuch-command args) output) + output))) + (defun notmuch-version () "Return a string with the notmuch version number." (let ((long-string ;; Trim off the trailing newline. - (substring (shell-command-to-string - (concat notmuch-command " --version")) - 0 -1))) + (substring (notmuch-command-to-string "--version") 0 -1))) (if (string-match "^notmuch\\( version\\)? \\(.*\\)$" long-string) (match-string 2 long-string) @@ -127,9 +139,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an (defun notmuch-config-get (item) "Return a value from the notmuch configuration." ;; Trim off the trailing newline - (substring (shell-command-to-string - (concat notmuch-command " config get " item)) - 0 -1)) + (substring (notmuch-command-to-string "config" "get" item) 0 -1)) (defun notmuch-database-path () "Return the database.path value from the notmuch configuration." @@ -355,6 +365,14 @@ OBJECT." (setq pos next)))) object) +(defun notmuch-combine-face-text-property-string (string face &optional below) + (notmuch-combine-face-text-property + 0 + (length string) + face + below + string)) + (defun notmuch-logged-error (msg &optional extra) "Log MSG and EXTRA to *Notmuch errors* and signal MSG.