aboutsummaryrefslogtreecommitdiff
path: root/emacs/notmuch.el
AgeCommit message (Collapse)Author
2026-01-25emacs: fix `notmuch-*-filter-by-tag' query stringsKristoffer Balintona
`notmuch-tree-filter-by-tag' and `notmuch-search-filter-by-tag' are described, in their docstrings, as matching all the messages in the current view that are ALSO tagged by a given tag. However, since the current view's search query was not logically grouped together (with parentheses), the actual behavior was different for sufficiently complex search queries. Fix this by grouping the current view's search query in parentheses first.
2025-06-20emacs/search: call notmuch-search-mode before popping to bufferjonah
This makes derived-mode matching in display-buffer-alist work.
2025-03-14Set 'untrusted-content' to t in all modesStefan Kangas
Instead of trying to guess in which modes this is safe not to set in, let's just set it in all of them. Background (added by db): untrusted-content was added in Emacs 29.3 and is currently set by Gnus and used by org-mode to prevent certain unsafe operations. I think the intent is to use it for blocking more unsafe operations in the future.
2025-03-13emacs: replace use of hook to draw hl-line in search modeDavid Bremner
In the thread at id:87fsfuuxwn.fsf@thinkbox, a bug is discussed where the point and hl-line overlay get out of sync, leading the user to open the wrong message. As far as I can tell this is caused by notmuch-hl-mode being invoked too early. This change bypasses the logic preventing notmuch-search-hook being called only once, so that the overlay is updated later after the buffer is full(er). This change may lead to the overlay being updated multiple times; if this is annoying we can add a similar buffer local variable to ensure it is only called once. The extra logic to check notmuch-search-target-line reduces the flicker somewhat by not highlighting the first line every time.
2025-03-13emacs: add defcustom to control hl-line modeDavid Bremner
Currently the presence of hl-line highlighting is controlled implicitely by hooks. In future commits it will be migrated to use this variable.
2024-08-09Revert "emacs: Fix saved-search buffer titles"David Bremner
This reverts commit bc989209171d406b3671024542e59b86b0ecb23d. This was applied unintentionally to master while still under discussion.
2024-08-06emacs: Fix saved-search buffer titlesRudolf Adamkovič
REPRODUCTION STEPS: (let ((notmuch-saved-searches (list (list :name "Emacs List" :query "query:lists-emacs") (list :name "All Lists" :query "query:lists")))) (notmuch-search-buffer-title "query:lists-emacs" )) ACTUAL: "*notmuch-saved-search-[ All Lists ]-emacs*" EXPECTED: "*notmuch-saved-search-Emacs List*"
2024-04-06emacs: Add new option notmuch-search-hide-excludedMohsin Kaleem
The new notmuch-search-hide-excluded option allows users to configure whether to show or hide excluded messages (as determined by search.exclude_tags in the local notmuch config file). It defaults to true for now to maintain backwards-compatibility with how notmuch-{search,tree} already worked. New commands notmuch-search-toggle-hide-excluded and notmuch-tree-toggle-exclude have also been added. They toggle the value of notmuch-search-hide-excluded for the search in the current search or tree buffer. It's bound to "i" in the respective keymaps for these modes. Lastly I've amended some calls to notmuch-tree and notmuch-unthreaded which didn't pass through the buffer local value of notmuch-search-oldest-first (and now notmuch-search-exclude). Examples of where I've done this include: + notmuch-jump-search + notmuch-tree-from-search-current-query + notmuch-unthreaded-from-search-current-query + notmuch-tree-from-search-thread A new test file for Emacs has been added which covers the usage of the new `notmuch-search-hide-excluded' option and interactively hiding or showing mail with excluded tags. These test cover the basic usage of the `notmuch-search-toggle-hide-excluded' command in notmuch-search, notmuch-tree and notmuch-unthreaded searches. These tests also cover the persistence of the current value of the hide-excluded mail option as a user switches from between these different search commands. [1]: id:87ilxlxsng.fsf@kisara.moe Amended-by: db, fix indentation in T461-emacs-search-exclude.sh
2022-11-05emacs: fix dangling overlays in notmuch-searchMatt Armstrong
notmuch-search-insert-authors now sets the evaporate property on the ellipsis overlays. Emacs will delete them when the buffer contents are zeroed out, which happens with `notmuch-refresh-buffer`. This prevents them from being collapsed to zero-width overlays in position 1. See Emacs bug#58479. An upcoming change in Emacs will make these dangling overlays visible to the user.
2022-09-23emacs: add notmuch-search-edit-search and notmuch-tree-edit-searchTomi Ollila
...and bind these to "E" in their respective keymaps. Expected to be called interactively, then using read-from-minibuffer with current search string as initial contents for editing. (Noninteractive use makes little sense, but is supported.) With this one can expand (as an opposite to limit) their query and have e.g. (some of their) saved searches as search "templates". While at it, removed `(defvar notmuch-search-query-string)` from notmuch-tree.el; it is unused (`notmuch-tree-basic-query` is used instead). Thanks to Jose Antonio Ortega Ruiz for his example for notmuch-tree code, and better interactive use.
2022-07-30emacs: update defcustom for notmuch-search-result-format.David Bremner
It seems redundant to have the previous example, since the default value is always show by describe variable. Enforce more restrictions on the keys in the alist, since arbitrary strings don't work as field names. Document that functions can be used in lieu of field names.
2022-06-13emacs: Make notmuch-show-next-thread return nil on failureLeo Okawa Ericson
Having notmuch-show-next-thread return non-nil on success and nil on failure makes it easier for users to interact with notmuch via elisp. This commit changes notmuch-search-show-thread too since the return value of notmuch-show-next-thread depends on notmuch-search-show-thread. Amended by db: fix whitespace in T450-emacs-show
2022-02-16emacs: escape quote in notmuch-search-result-format docstringDavid Bremner
Prevent Emacs' mangling of quotes, which breaks the code sample.
2022-01-23emacs: customizable names for search buffersjao
Customizable names for buffers presenting search results, via two custom variables (notmuch-search-buffer-name-format and notmuch-saved-search-buffer-name-format), defaulting to values currently used for plain searches and including too tree and unthreaded search buffers. Amended by db: spelling fix.
2021-12-04emacs: run notmuch-search-hook lazilyDavid Bremner
In message id:YT3ueuZHKW931NW3@localhost, Fabio Natali isolated a visual glitch caused by running notmuch-search-hook too early. This change moves the running of that hook to notmuch-search-process-filter, which ensures there is some output in the buffer before running the hook. Since n-s-p-f can be called many times for a given buffer, add a buffer local flag to make sure it is only run once per buffer.
2021-10-30emacs: improve notmuch-*-from-current-query docstringsDavid Bremner
Err on the side of providing better user documentation, rather than documentation for developers.
2021-09-11emacs: wrap process-linesDavid Bremner
Initially just set the working directory, to avoid (the implicit) call-process crashing when the default-directory points to a non-existent location. Use of a macro here is over-engineering for this change, but the same change needs to be applied to several other process creation primitives.
2021-09-08emacs: Allow functions in notmuch-search-result-formatDavid Edmondson
If the car of an element in notmuch-search-result-format is a function, insert the result of calling the function into the buffer. This allows a user to generate custom fields in the output of a search result. For example, with: (defun -notmuch-result-flags (format-string result) (let ((tags-to-letters '(("flagged" . "!") ("unread" . "u") ("mine" . "m") ("sent" . "s") ("replied" . "r"))) (tags (plist-get result :tags))) (format format-string (mapconcat (lambda (t2l) (if (member (car t2l) tags) (cdr t2l) " ")) tags-to-letters "")))) (setq notmuch-search-result-format '((-notmuch-result-flags . "%s ") ("date" . "%12s ") ("count" . "%9s ") ("authors" . "%-30s ") ("subject" . "%s ") ("tags" . "(%s)"))) The first few characters on each line of the search result are used to show information about some significant tags associated with the thread.
2021-09-08emacs: Use pcase in notmuch-search-insert-fieldDavid Edmondson
Rather than lots of string-equal calls, use the pcase macro.
2021-08-29emacs: fix some option type declarationsJonas Bernoulli
Also improve their doc-strings.
2021-08-22CLI: define and use format version 5David Bremner
This is a bit of a cheat, since the format does not actually change. On the other hand it is fairly common to do something like this to shared libary SONAMEs when the ABI changes in some subtle way. It does rely on the format-version argument being early enough on the command line to generate a sensible error message.
2021-06-05emacs: fix declare-function definitions with related line breaksTomi Ollila
- declare-function notmuch-unthreaded lacked file name - declare-function notmuch-search had differently named last arg - note: check-declare-directory did not complain about that - declare-function notmuch-search-show-thread without nil - some functions declared to be in different file than those existed ("notmuch" -> "notmuch-lib") - some related function/declare lines were (/are now) wider than 80-columns; added line breaks (and proper indentation) there
2021-06-04emacs: drop setting mail-user-agent, and document how to set itDavid Bremner
After some discussion [1], I decided it is better to make notmuch users who rely on this behaviour customize mail-user-agent. This is consistent with the behaviour of other emacs mail packages. [1]: id:87k0nuhfrk.fsf@toryanderson.com
2021-02-05emacs: When completing tags, offer each tag onceDavid Edmondson
When prompting for one or more tags to add or remove to/from one or more threads, ensure that the set of tags offered for completion contains no duplicates. Some completion packages (e.g. selectrum) will include every member of the offered list, resulting in the same tag being indicated as a possibility several times.
2021-01-15emacs: use string-empty-pJonas Bernoulli
2021-01-15emacs: improve how cl-lib and pcase are requiredJonas Bernoulli
We need to load `cl-lib' at run-time because we use more from it than just macros. Never-the-less many, but not all libraries required it only at compile-time, which we got away with because at least some libraries already required it at run-time as well. We use `cl-lib' and (currently to a lesser extend) `pcase' throughout the code-base, which means that we should require these features in most libraries. In the past we tried to only require these features in just the libraries that actually need them, without fully succeeding. We did not succeed in doing so because that means we would have to check every time that we use a function from these features whether they are already being required in the current library. An alternative would be to add the `require' forms at the top of every library but that is a bit annoying too. In order to make sure that these features are loaded when needed but also to keep the noise down we only require them in "notmuch-lib.el", which most other libraries require, and in most of the few libraries that do not do so, namely "notmuch-draft.el", "notmuch-message.el" and "notmuch-parser.el". ("coolj.el", "make-deps.el", various generated libraries, and "notmuch-compat.el" are left touched.)
2021-01-15emacs: avoid unnecessary let-bindingsJonas Bernoulli
To some extend this is a personal preference, but the preference is strongly dependent on whether one is used to a language that makes it necessary to use variables like this. This makes it perfectly clear that we are first getting and then using a "foo": (use-foo (get-foo)) Sure this has to be read "inside out", but that's something one better gets used to quickly when dealing with lisp. I don't understand why one would want to write this instead: (let ((the-foo (get-foo))) (use-foo the-foo)) Both `get-foo' and `use-foo' are named in a way that make it very clear that we are dealing with a "foo". Storing the value in an additional variable `the-foo' does not make this any more clear. On the contrary I makes the reader wonder why the author choose to use a variable. Is the value used more than once? Is the value being retrieved in one context and then used in another (e.g. when the current buffer changes)?
2021-01-15emacs: reorder notmuch.el a bitJonas Bernoulli
2021-01-15emacs: notmuch-search-stash-thread-id: use notmuch-search-query-stringJonas Bernoulli
No longer use the function `notmuch-search-get-query', which does nothing but return the value of that variable. That function was added in [1: f47eeac0] for use in `notmuch-read-query' along-side related `notmuch-show-get-query' and `notmuch-tree-get-query' but using it here makes little sense. 1: f47eeac0b0186c3559eb559c4f0bee0e1fac1961 emacs: set default in notmuch-read-query
2021-01-15emacs: define a few variables as automatically buffer-localJonas Bernoulli
Define these variables as automatically buffer-local, meaning that they always become buffer-local when set unless explicitly told otherwise using `setq-default' or when using the Custom interface. Previously they were declared, which keeps the byte-compiler quiet but is not actually the same as being defined. `notmuch-search-mode' then made them buffer-local in the current buffer and then set the local values. This works but is not kosher. The definitions of the three non-option variables have to be moved up a bit to enable the change in the next commit, which see.
2021-01-15emacs: remove variable notmuch-search-disjunctive-regexpJonas Bernoulli
The value is the only possible value, it is only used in one place, and using a global variable serves no purpose but to make things more complicated.
2021-01-15emacs: various doc-string improvementsJonas Bernoulli
2021-01-15emacs: various cosmetic improvementsJonas Bernoulli
2021-01-13emacs: deal with unused lexical arguments and variablesJonas Bernoulli
The previous commit switched to lexical-binding but without dealing with the new warnings about unused lexical arguments and variables. This commit deals with most of them, in most cases by either removing leftover bindings that are actually unnecessary, or by marking certain arguments as "known to be unused" by prefixing their names with "_". In the case of the functions named `notmuch-show-insert-...' the amount of silencing that is required is a bit extreme and we might want to investigate if there is a better way. In the case of `notmuch-mua-mail', ignoring CONTINUE means that we do not fully follow the intended behavior described in `compose-mail's doc-string.
2021-01-13emacs: use lexical-bindings in all librariesJonas Bernoulli
Doing so causes many new compile warnings. Some of these warnings concern genuine changes in behavior that have to be addressed right away. Many other warnings are due to unused variables. Nothing has changed here, except that the byte-compiler can now detect these pre-existing and harmless issues. We delay addressing these issues so that we can focus on the important ones here. A third group of warnings concern arguments that are not actually used inside the function but which cannot be removed because the functions signature is dictated by some outside convention. Silencing these warning is also delayed until subsequent commits.
2021-01-13emacs: make headings outline-minor-mode compatibleJonas Bernoulli
`outline-minor-mode' treats comments that begin with three or more semicolons as headings. That makes it very convenient to navigate code and to show/hide parts of a file. Elips libraries typically have four top-level sections, e.g.: ;;; notmuch.el --- run notmuch within emacs... ;;; Commentary:... ;;; Code:... ;;; notmuch.el ends here In this package many libraries lack a "Commentary:" section, which is not optimal but okay for most libraries, except major entry points. Depending on how one chooses to look at it, the "... ends here" line is not really a heading that begins a section, because it should never have a "section" body (after all it marks eof). If the file is rather short, then I left "Code:" as the only section that contains code. Otherwise I split the file into multiple sibling sections. The "Code:" section continues to contain `require' and `declare-function' forms and other such "front matter". If and only if I have split the code into multiple sections anyway, then I also added an additional section named just "_" before the `provide' form and shortly before the "...end here" line. This section could also be called "Back matter", but I feel it would be distracting to be that explicit about it. (The IMO unnecessary but unfortunately still obligatory "... ends here" line is already distracting enough as far as I am concerned.) Before this commit some libraries already uses section headings, some of them consistently. When a library already had some headings, then this commit often sticks to that style, even at the cost inconsistent styling across all libraries. A very limited number of variable and function definitions have to be moved around because they would otherwise end up in sections they do not belong into. Sections, including but not limited to their heading, can and should be further improved in the future.
2021-01-13emacs: use setq instead of setJonas Bernoulli
Commonly `set' is only used if there is no way around it; i.e. when the variable cannot be known until runtime.
2020-12-25Revert "emacs: notmuch-search: avoid wiping out buffer-local variables"Jonas Bernoulli
This reverts commit f9fbd1ee3bfd679175d88af403752d87a730349f. Emacs provides a mechanism for avoiding wiping out buffer-local variables: marking them as "permanent local", which essentially means "don't wip out the local value when enabling major-mode". (put 'the-variable 'permanent-local t) See (info "(elisp)Creating Buffer-Local"). Whether refreshing the buffer contents should involve re-enable the mode is a different question, which should not be decided based on the fact that we want keep the value of some random variable, not least because some other (e.g. cache) variables are likely expected to be wiped.
2020-12-06emacs: use setq-localJonas Bernoulli
It is available since Emacs 24.3 and we require at least Emacs 25. It makes the variable buffer-local if it isn't always buffer-local anyway.
2020-12-06emacs: always use elisp quoting style in doc-stringsJonas Bernoulli
Emacs doc-strings use neither markdown nor lisp symbol quoting.
2020-11-11emacs: don't fset keymapsJonas Bernoulli
These keymaps are never invoked as commands so the function definitions serve no purpose.
2020-08-22Emacs: Fix notmuch-message-summary-face definitionTeemu Likonen
Emacs face definition forms are either ((DISPLAY . PLIST) (DISPLAY . PLIST)) or ((DISPLAY PLIST) ;For backward compatibility. (DISPLAY PLIST)) Commit a2388bc56e55da5d5695816818274f8a84b0ed92 (2020-08-08) follows neither of the correct formats. It defines: `((((class color) (background light)) ,@(and (>= emacs-major-version 27) '(:extend t)) (:background "#f0f0f0")) (((class color) (background dark)) ,@(and (>= emacs-major-version 27) '(:extend t)) (:background "#303030"))) which produces: ((DISPLAY :extend t (:background "#f0f0f0")) (DISPLAY :extend t (:background "#303030"))) And that is wrong format. This change fixes the face definition form to produce: ((DISPLAY :extend t :background "#f0f0f0") (DISPLAY :extend t :background "#303030")) which follows the (DISPLAY . PLIST) format (see above).
2020-08-22emacs: Use pop-to-buffer-same-window rather than switch-to-bufferSean Whitton
This means that notmuch commands obey display-buffer-alist so the user can customize how buffers show up. It also permits the use of C-x 4 4, C-x 5 5 and C-x t t, available in Emacs 28. For example, one can use C-x 4 4 M-x notmuch-jump-search RET to open a saved search in another window rather than the current window. Or in notmuch-search mode, C-x 5 5 RET to view the message at point in a new frame. notmuch-tree has custom buffer display logic, so bind display-buffer-overriding-action to make pop-to-buffer-same-window behave exactly as switch-to-buffer while that function is running.
2020-08-16emacs/tree: introduce notmuch-tree-parent-buffer variableWilliam Casarin
This variable will be used in a similar fashion to notmuch-show-parent-buffer. It will be used to navigate between threads from the parent search buffer. Signed-off-by: William Casarin <jb55@jb55.com>
2020-08-09emacs: Increase consistency of library headersJonas Bernoulli
2020-08-09emacs: Improve doc-stringsJonas Bernoulli
- The first sentence should fit on the first line in full. This is even the case when that causes the line to get a bit long. If it gets very long, then it should be made shorter. - Even even the second sentence would fit on the first line, if it just provides some details, then it shouldn't be done. - Symbols are quoted like `so'. - There is no clear rule on how to (not) quote non-atomic s-expressions, but quoting like '(this) is definitely weird. - It is a good idea to remember that \" becomes " and to take that in mind when adjusting the automatic filling by hand. - Use the imperative form. - Arguments are written in all uppercase.
2020-08-09emacs: Extend face to window edge againJonas Bernoulli
Since Emacs 27 each face has to be explicitly configured to "extend to the edge of the window". Without doing that the face used for the newline character only has an effect that spans "one character" (i.e. it looks like there is a single trailing space character). We don't want that so extend the face in Emacs 27, so that it looks the same as it did in older Emacs releases. We have to do this conditionally, otherwise older Emacsen would choke on it.
2020-08-09emacs: Use 'when' instead of 'if' when there is no ELSE partJonas Bernoulli
2020-08-09emacs: Use 'unless' instead of 'when' and 'not'Jonas Bernoulli
Also use 'unless' in a few cases where previously 'if' was used with 'not' but without an ELSE part.
2020-08-09emacs: Use 'and' instead of 'when' when the return value mattersJonas Bernoulli
Also do so for some 'if' forms that lack an ELSE part. Even go as far as using 'and' and 'not' instead of 'unless'.