aboutsummaryrefslogtreecommitdiff
path: root/emacs/notmuch-address.el
AgeCommit message (Collapse)Author
2023-10-06emacs/address: rewrite docstring for n-a-selection-functionDavid Bremner
The previous version essentially repeated the source code, and generated a compiler warning.
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-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-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: 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: various comment 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.
2020-12-06emacs: remove unused notmuch-address-locate-commandJonas Bernoulli
We stopped using it in [1: 0e671478]. 1: 0e671478c6f37018973392f049979da5e1a8ff99 emacs: replace use of notmuch-address-message-insinuate
2020-12-06emacs: misc doc-string improvementsJonas Bernoulli
2020-12-06emacs: always use elisp quoting style in doc-stringsJonas Bernoulli
Emacs doc-strings use neither markdown nor lisp symbol quoting.
2020-08-09emacs: Remove notmuch-setq-localJonas Bernoulli
Just use setq-local, which existed since Emacs 24.3.
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: Use 'when' instead of 'if' when there is no ELSE partJonas Bernoulli
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'.
2020-08-09emacs: Only set one variable per setq formJonas Bernoulli
It's a bit weird to avoid having to write the "(setq ... )" more than once, just because we can. In a language that uses '=' for the same purpose we also happily use that once per assignment. While there are no benefit to using just one 'setq' there are some drawbacks. It is not always clear on first what is a key and what a value and as a result it is easy to make a mistake. Also it becomes harder to comment out just one assignment.
2020-08-09emacs: Fix indentationJonas Bernoulli
2020-08-09emacs: Remove excess empty linesJonas Bernoulli
Most people who write lots of lisp tend to only sparsely use empty "separator" lines within forms. In lisp they feel unnecessary and since most files stick to this convention we get a bit confused when there are extra empty lines. It feels like the s-expressions are falling into pieces. All of this is especially true between a function's doc-string and body because the doc-string is colored differently, which visually already separates it quite sufficiently from the code that follows.
2020-08-09emacs: Shorten long linesJonas Bernoulli
2020-06-06emacs docstrings: consistent indentation, newlines, periodsTomi Ollila
Fixed emacs docstrings to be consistent. No functional change. - removed some (accidental) indentation - removed some trailing newlines - added trailing periods where missing (some exclusions)
2017-09-12emacs/address: use member instead of memq to check for pairDavid Bremner
Quoting from the elisp reference: For other types (e.g., lists, vectors, strings), two arguments with the same contents or elements are not necessarily ‘eq’ to each other. Thanks to "Attic Hermit" for the fix.
2017-07-18emacs: convert remaining format-versions from 3 to 4David Bremner
This is needed for consistent beheviour between notmuch built against gmime-2.6 and gmime-3.0 w.r.t. error reporting.
2017-07-04emacs: convert to use format-version 3David Bremner
Keeping the emacs interface running old format-versions makes it impossible to test new format-versions or deprecate old ones.
2017-02-23emacs: fully add the notmuch-address customize groupMark Walters
We now have several customizable options for address completion. There is a customize group notmuch-address but it only contains one of these options. Add all the others, and make it part of the notmuch customize group.
2017-01-27emacs: address: save hashMark Walters
This allows the user to save the address hash so that it is much faster for the first completion after a restart. This defaults to off as there are privacy implications to saving this information. The code tries hard to avoid overwriting the wrong file. It also notes if changes have been made to any of the relevant user settings, so that the user does not get surprising results (i.e., outdated options being used). Finally it stores some version information so that is easy for us to update the format of the save file.
2017-01-27emacs: address: move address-full-harvest-finished to a functionMark Walters
This makes the code access notmuch-address-full-harvest-finished via a helper function, notmuch-address--harvest-ready. Later we will use this to check whether we can load the harvest instead of regenerating it.
2016-11-17Merge branch 'release'David Bremner
Updates for 0.23.2
2016-11-16emacs: add compatibility functions for emacs 23Mark Walters
Some of the recent changes to the emacs code have used functions introduced in emacs 24. The functions used are read-char-choice and setq-local. This changeset adds a file notmuch-compat.el which contains compatibility functions so that it should work on emacs 23. Note, since these functions are taken almost unchanged from the emacs source they are copyright the Free Software Foundation, and the header in the file reflects that.
2016-11-13emacs: rename notmuch-address-completion-hook to notmuch-address-post-completion-functionsDavid Bremner
Apparently it is a (not completely adhered to) emacs convention [1] that only hooks that don't take arguments end in 'hook' [1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Hooks.html
2016-11-04emacs: add notmuch-address-post-completion-hookDavid Bremner
This hook can be used to update the message based on the results of address completion. For example using message-templ or gnus-alias to set the From address based on the To address just completed. The post-completion command is added to the notmuch-company backend to ensure that the hook is also called company completion is started without going through notmuch-address-expand-name. See the docstring of `company-backends' for more information.
2016-10-09emacs: include first match in address completionMark Walters
The current code for address completion takes the list of possible completions (whether generated internally or externally), makes the first match the initial value for the completion, and puts all the others (but not the first match) into the possible completions. This has the nice effect that the <down> key takes you immediately to the next completion (whereas if the first match were included in the possible completions it would take you to the first match again). However, it has two side effects. First, once you have completed to the full match you find it says and try completing again you get told "no match" not "sole completion". Secondly, if you delete some of the text and try completing you don't get the first match as an option. This tries to get round most of these problems by including the full list of possible completions, but with the first match moved to the very end of the list.
2016-09-04emacs: address: allow internal completion on an individual basisMark Walters
This commit makes two changes. The first allows the user to override an external completion method with the internal notmuch address based completion for an individual buffer. Secondly, if the user has company-mode enabled then it sets up company mode (based on internal completion) but disables the automatic timeout completion -- the user can still activate it in when desired with standard company commands such as company-complete.
2016-09-04emacs: address completion, allow sender/recipient and filtersMark Walters
This commit lets the user customize the address completion. It makes two changes. The first change controls whether to build the address completion list based on messages you have sent or you have received (the latter is much faster). The second change add a possible filter query to limit the messages used -- for example, setting this to date:1y.. would limit the address completions to addresses used in the last year. This speeds up the address harvest and may also make the search less cluttered as old addresses may well no longer be valid.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-05-19emacs: add function to resend message to new recipientsTomi Ollila
The new function notmuch-show-message-resend re-sends message to new recipients using #'message-resend. Recipients are read from minibuffer as a comma-separated string (with some keyboard support including tab completion). Final confirmation before sending is asked.
2016-04-16emacs: Fix packagingChunyang Xu
Refer to (info "(elisp) Library Headers") for package conventions.
2015-10-27Emacs: Add address completion based on company-modeMichal Sojka
When company-mode is available (Emacs >= 24), address completion candidates are shown in a nice popup box. This is triggered either by pressing TAB or by waiting a while during typing an address. The completion is based entirely on the asynchronous address harvesting from notmuch-address.el so the GUI is theoretically not blocked for long time. The completion works similarly as the TAB-initiated completion from notmuch-address.el, i.e. quick harvest based on user input is executed first and only after full harvesting is finished, in-memory cached data is used. [Improved by David Bremner]
2015-10-27Emacs: Add address completion mechanism implemented in elispMichal Sojka
Currently, notmuch has an address completion mechanism that requires external command to provide completion candidates. This commit adds a completion mechanism inspired by https://github.com/tjim/nevermore, which is implemented in Emacs lisp only. The preexisting address completion mechanism, activated by pressing TAB on To/Cc lines, is extended to use the new mechanism when notmuch-address-command to 'internal, which is the new default. The core of the new mechanism is the function notmuch-address-harvest, which collects the completion candidates from the notmuch database and stores them in notmuch-address-completions variable. The address harvesting can run either synchronously (same as with the previous mechanism) or asynchronously. When the user presses TAB for the first time, synchronous harvesting limited to user entered text is performed. If the entered text is reasonably long, this operation is relatively fast. Then, asynchronous harvesting over the full database is triggered. This operation may take long time (minutes on rotating disk). After it finishes, no harvesting is normally performed again and subsequent completion requests use the harvested data cached in memory. Completion cache is updated after 24 hours. Note that this commit restores (different) completion functionality for users when the user used external command named "notmuch-addresses", i.e. the old default. The result will be that the user will use the new mechanism instead of this command. I believe that many users may not even recognize this because the new mechanism works the same as http://commonmeasure.org/~jkr/git/notmuch_addresses.git and perhaps also as other commands suggested at http://notmuchmail.org/emacstips/#address_completion. [This feature was significantly improved by David Bremner and Mark Walters]
2015-10-27emacs: replace use of notmuch-address-message-insinuateDavid Bremner
This allows e.g. Gnus users to load this file without changing message-mode behaviour. This will disable completion for those that did not customize the variable but relied on the existence of a file named "notmuch-addresses" in their path. In the next commit the default behaviour will change to use a "workalike" internal completion mechanism.
2015-01-18Emacs: Display a message when generating address completion candidatesMichal Sojka
The TAB-initiated address completion generates completion candidates synchronously, blocking the UI. Since this can take long time, it is better to let the use know what's happening.
2013-05-13emacs/notmuch-address.el: add notmuch-address-selection-functionTomi Ollila
Added a customizable variable notmuch-address-selection-function and the function with the same name to provide a way for user to change the function called to do address selection. By default the functionality is exactly the same as it has been so far; completing-read is called with the same parameters as before. Setting equivalent lambda expression in place of using notmuch-address-selection-function function is done as follows: (setq notmuch-address-selection-function (lambda (prompt collection initial-input) (completing-read prompt collection nil nil initial-input))) For example drop-in replacement with ido-completing-read can be done easily as an one alternative to the default.
2013-04-06Revert "emacs: functions to import sender or recipient into BBDB"David Bremner
This reverts commit 238bf4cb09423cac4efa968e70184daad39e2846. This commit was causing a build failure. Bad me for not checking before pushing.
2013-04-06emacs: functions to import sender or recipient into BBDBDaniel Bergey
From a show buffer, notmuch-bbdb/snarf-from imports the sender into bbdb. notmuch-bbdb/snarf-to imports all recipients. Newly imported contacts are reported in the minibuffer / Messages buffer. Both functions use the BBDB parser to recognize email address formats.
2012-01-21emacs: globally replace non-branching "(if (not ..." with "(unless ..."Pieter Praet
Less code, same results, without sacrificing readability.
2012-01-19emacs: logically group def{custom,face}sPieter Praet
To allow for expansion whilst keeping everything tidy and organized, move all defcustom/defface variables to the following subgroups, defined in notmuch-lib.el: - Hello - Search - Show - Send - Crypto - Hooks - External Commands - Appearance As an added benefit, defcustom keyword args are now consistently ordered as they appear @ defcustom's docstring (OCD much?). Proper defgroup docstrings and various other improvements by courtesy of Austin Clements.
2011-12-22emacs: Don't prompt the user to choose from zero matching addresses.David Edmondson
If the address matching function generates no matches, don't prompt the user to choose between them (!). Instead, generate a message to report that there were no matches.