aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-02-06CLI/count: switch to new configuration frameworkDavid Bremner
The main effort is changing from the old argv style config list iterators to the new more opaque ones provided by the library (and backed by the database+file config cache).
2021-02-06lib/config: make values iterators restartableDavid Bremner
This is relatively cheap, and makes it easier to transform existing code which uses arrays of pointers to store configuration lists.
2021-02-06lib/config: add config values iteratorDavid Bremner
This is intended to avoid duplicating the string splitting and traversal code for all clients of the config API.
2021-02-06util: add strsplit_len: simplified strtok with delimiter escapingDavid Bremner
This will be used to make iterators for configuration values.
2021-02-06CLI: add (unused) database argument to subcommands.David Bremner
This will allow transitioning individual subcommands to the new configuration framework. Eventually when they are all converted we can remove the notmuch_config_t * argument. For now, live with the parameter shadowing in some some subcommands; it will go away when they are converted.
2021-02-06lib/open: load default values for known configuration keys.David Bremner
This emulates the behaviour of notmuch_config_open defined in the CLI, in that it fills in default values if they are not otherwise defined.
2021-02-06lib/config: add notmuch_config_key_{get,set}David Bremner
By using an enum we can have better error detection than copy pasting key strings around. The question of what layer this belongs in is a bit tricky. Historically most of the keys are defined by the CLI. On the other hand features like excludes are supported in the library/bindings, and it makes sense to configure them from the library as well. The somewhat long prefix for notmuch_config_t is to avoid collisions with the existing usage in notmuch-client.h.
2021-02-06CLI: generalize notmuch_config_mode_tDavid Bremner
The renaming and extra values will make sense when we start to convert subcommands to the new configuration framework. It will also avoid collisions with a new enum for configuration keys to be introduced in a future commit.
2021-02-06lib/open: add support for config profiles and default locationsDavid Bremner
Fill in the remainder of the documented functionality for n_d_open_with_config with respect to config file location. Similar searching default locations of the database file still needs to be added.
2021-02-06lib: add stub for notmuch_database_open_with_configDavid Bremner
Initially document the intended API and copy the code from notmuch_database_open_verbose. Most of the documented functionality is not there yet.
2021-02-06lib: cache configuration information from databaseDavid Bremner
The main goal is to allow configuration information to be temporarily overridden by a separate config file. That will require further changes not in this commit. The performance impact is unclear, and will depend on the balance between number of queries and number of distinct metadata items read on the first call to n_d_get_config.
2021-02-06lib: add _notmuch_string_map_setDavid Bremner
This will be used (and tested) by the configuration caching code to be added in the next commit.
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-02-05notmuch-show: use correct format specifier for ssize_tĐoàn Trần Công Danh
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2021-01-17test: add (back) upgrade testsDavid Bremner
In ee897cab8b721 the upgrade tests from pre v3 databases were removed. The reasons for that are still valid, but we should still test the code paths that do the upgrade, and it is relatively straightforward to do that for v3 to v3 upgrades.
2021-01-15test/T391-python-cffiDavid Bremner
Make bindings test verbose. This helps in debugging.
2021-01-15test/T750-gzip: don't compress the xapian databaseDavid Bremner
This causes mysterious failures in trying to detect if a database exists.
2021-01-15emacs: avoid type errors due to nil as content-typeJonas Bernoulli
The output of "notmuch show --format=sexp --format-version=4" may contain `:content-type' entries with `nil' as the value, when it fails to detect the correct value. Account for that in a few places where we would otherwise risk a type error. Note that `string=' does not choke on `nil' because it uses the `symbol-name' when encountering a symbol.
2021-01-15emacs: notmuch-show--get-cid-content: cosmeticsJonas Bernoulli
2021-01-15emacs: notmuch-show--register-cids: fix names of bindingsJonas Bernoulli
2021-01-15emacs: notmuch-mua-add-more-hidden-headers: use local bindingJonas Bernoulli
2021-01-15emacs: notmuch-address-expand-name: use the actual initial-inputJonas Bernoulli
Users may type some text into the buffer on an address line, before actually invoking address completion. We now use that text as the initial input when we begin address completion. Previously we did knowingly replace the actual initial input with some completion candidate that happens to match. Which candidate is used is essentially random, at least when the actual initial input is short. As a result users very often had to begin completion by deleting the less than helpful "initial input".
2021-01-15emacs: allow opting out of notmuch's address completionJonas Bernoulli
IMO Notmuch should not override the default completion mechanism by default, at least not globally. But since users are already used to this behavior it is probably too late to change it. Do the next best thing and at least allow users to opt out.
2021-01-15emacs: notmuch-tree-get-match: No longer define as commandJonas Bernoulli
When called from code, then this function returns non-nil when the message at point is a matched message. However it does nothing at all to present that information to the user when it called interactively. It is therefore safe to conclude that nobody is using this as a command.
2021-01-15emacs: use string-empty-pJonas Bernoulli
2021-01-15emacs: make subr-x available in all librariesJonas Bernoulli
Like `cl-lib' and `pcase', which are already available in all libraries, `subr-x' also provided many useful functions that we would like to use. Making `subr-x' available in every library from the get-go means that we can use the functions it defines without having to double check every single time, whether the feature is already available in the current library.
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 comment improvementsJonas Bernoulli
2021-01-15emacs: various cosmetic improvementsJonas Bernoulli
2021-01-13emacs: notmuch-crypto-status-button-type: fix potential bugJonas Bernoulli
The "help-echo" can potentially contain an unintended %-spec so we have to make sure it would not be treated as such.
2021-01-13emacs: notmuch-mua.el: move all options into "Options" sectionJonas Bernoulli
This is how we do it in other libraries.
2021-01-13emacs: notmuch-mua-prompt-for-sender: don't force Ido on usersJonas Bernoulli
We shouldn't force `ido-completion-read' on users who do not otherwise use Ido. Unfortunately simply turning on `ido-mode' does not change every `completing-read' into a `ido-completing-read', instead it only changes file and buffer completion. I do realize that existing Ido users will initially dislike this change, but I would like to encourage them to see this as an opportunity to learn about Fido. Unlike `ido-mode', build-in `fido-mode' confirms to the standard completion API, so turning it on causes every `completing-read' to use the Fido completion mechanism and which is similar to the Ido mechanism: > An enhanced `icomplete-mode' that emulates `ido-mode'. This global > minor mode makes minibuffer completion behave more like `ido-mode' > than regular `icomplete-mode'."
2021-01-13emacs: notmuch-wash.el: require diff-mode at beginning of codeJonas Bernoulli
That's what we usually do. Also do not declare variable `diff-file-header-re' because it is defined in `diff-mode.el', which we always require.
2021-01-13emacs: notmuch-message-apply-queued-tag-changes: cosmeticsJonas Bernoulli
2021-01-13emacs: define notmuch-message-queued-tag-changes as buffer-localJonas Bernoulli
Also improve the doc-string.
2021-01-13emacs: silence compiler wrt notmuch-show-insert-part-text/plainJonas Bernoulli
`notmuch-show-insert-part-text/plain' calls `notmuch-show-insert-text/plain-hook' with two arguments MSG and DEPTH. Currently all hook functions ignore MSG but third-party functions may not. One hook function uses DEPTH.
2021-01-13emacs: notmuch-wash-region-to-button: remove unused MSG argumentJonas Bernoulli
2021-01-13emacs: inline notmuch-sexp-eof into only callerJonas Bernoulli
This function had a few issues. - Neither its name nor the old comment before it is called made it clear what it does. - It took one argument but didn't do anything with it. - It's doc-string made a few claims, which are untrue and generally focused on details instead of that its purpose is.
2021-01-13emacs: notmuch-tag--get-formats: silence byte-compilerJonas Bernoulli
`format-alist' is a global variable and the byte-compiler is unhappy when a lexical function argument shadows a global (dynamic) binding.
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: avoid killing process buffer when process is still aliveJonas Bernoulli
In practice this probably does not make a difference or we would have heard about it many times, but better be safe than sorry. Process sentinels are called not only when the process has finished but also on other state changes.
2021-01-13emacs: avoid passing around some redundant informationJonas Bernoulli
When running "notmuch" we use its full path but when displaying the command to the user we show just its name for readability reasons. Avoid passing around both representations because it is very easy to get the name from the path. Notmuch itself uses the involved functions just for "notmuch" but there might be extensions that use them for other executable so we forgo other potential simplifications.