Commit graph

993 commits

Author SHA1 Message Date
Jonas Bernoulli
3f16dd7611 emacs: notmuch-wash.el: require diff-mode at beginning of code
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-13 07:23:11 -04:00
Jonas Bernoulli
b4deb33a66 emacs: notmuch-message-apply-queued-tag-changes: cosmetics 2021-01-13 07:23:11 -04:00
Jonas Bernoulli
117501d5ce emacs: define notmuch-message-queued-tag-changes as buffer-local
Also improve the doc-string.
2021-01-13 07:21:32 -04:00
Jonas Bernoulli
d8075ce50b emacs: silence compiler wrt notmuch-show-insert-part-text/plain
`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-13 07:21:22 -04:00
Jonas Bernoulli
5475eb5151 emacs: notmuch-wash-region-to-button: remove unused MSG argument 2021-01-13 07:19:30 -04:00
Jonas Bernoulli
93c95802a4 emacs: inline notmuch-sexp-eof into only caller
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-13 07:17:25 -04:00
Jonas Bernoulli
9be8c6802f emacs: notmuch-tag--get-formats: silence byte-compiler
`format-alist' is a global variable and the byte-compiler is unhappy
when a lexical function argument shadows a global (dynamic) binding.
2021-01-13 07:16:38 -04:00
Jonas Bernoulli
0067a43ea2 emacs: deal with unused lexical arguments and variables
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-13 07:16:23 -04:00
Jonas Bernoulli
fc4cda07a9 emacs: use lexical-bindings in all libraries
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-13 07:16:04 -04:00
Jonas Bernoulli
2ca941163d emacs: make headings outline-minor-mode compatible
`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-13 07:10:27 -04:00
Jonas Bernoulli
adc123e4fd emacs: avoid killing process buffer when process is still alive
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-13 07:08:13 -04:00
Jonas Bernoulli
904ffbc925 emacs: avoid passing around some redundant information
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.
2021-01-13 07:07:59 -04:00
Jonas Bernoulli
778950872d emacs: notmuch-start-notmuch: avoid storing process buffer twice
The buffer of the error process is accessible using `process-buffer'.
We still have to store the error-buffer in the non-error process
because for that process `process-buffer' obviously returns its own
buffer.
2021-01-13 07:07:47 -04:00
Jonas Bernoulli
db0fd8e782 emacs: notmuch-start-notmuch-sentinel: assert buffer is alive 2021-01-13 07:06:16 -04:00
Jonas Bernoulli
d57ce9ca71 emacs: notmuch-start-notmuch-error-sentinel: assert buffer is alive 2021-01-13 06:57:41 -04:00
Jonas Bernoulli
0afb3f8b21 emacs: notmuch-start-notmuch: remove backward compatibility code
We no longer support Emacs releases before version 25.1.

Also adjust the sentinels which only had to deal with
an error file when using an older Emacs release was used.
2021-01-13 06:57:31 -04:00
Jonas Bernoulli
d931758a15 emacs: define new notmuch-search-item widget type
This is complex enough to warrant a dedicated widget type,
which will make future improvements less messy to implement.
2021-01-13 06:57:14 -04:00
Jonas Bernoulli
d7b83385af emacs: sanitize dedicated widget action/notify functions
These functions are used as action/notify functions.  That dictates
the appropriate function signatures but even though these functions
are not used for anything else they use incompatible signatures,
forcing the callers to use lambda expressions to deal with these
incompatibilities.

Fix that by adjusting the function signatures to the needs of the
only intended callers.

Two of these functions were defined as commands but because the
interactive form did not return the mandatory arguments, we know
that nobody (successfully) used these as commands.

In one case we move the location of a y-or-n-p prompt.
2021-01-13 06:56:50 -04:00
Jonas Bernoulli
5b19e6e1b4 emacs: use setq instead of set
Commonly `set' is only used if there is no way around it;
i.e. when the variable cannot be known until runtime.
2021-01-13 06:56:40 -04:00
Jonas Bernoulli
0251cab3ab Revert "emacs: notmuch-search: avoid wiping out buffer-local variables"
This reverts commit f9fbd1ee3b.

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-25 14:32:56 -04:00
Jonas Bernoulli
adfded9ed0 emacs: avoid binding unnamed commands in keymaps
One should never bind unnamed commands in keymaps because doing that
makes it needlessly hard for users to change these bindings.

Replace such anonymous bindings with named commands that are generated
using macros and some boilerplate. Using macros is better than using a
simple loop because that makes it possible for `find-function' to find
the definitions. Eat your boilerplate--it forms character.

Admittedly this approach is quite ugly and it might be better to teach
the original commands to support different buffers directly instead of
requiring wrapper commands to do just that.

Never-the-less as a short-term solution this is better than what we
had before.
2020-12-06 16:23:38 -04:00
Jonas Bernoulli
54492ddf23 emacs: do not quote self-quoting t 2020-12-06 16:23:11 -04:00
Jonas Bernoulli
b4ee80dcbd emacs: use setq-local
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-06 16:22:33 -04:00
Jonas Bernoulli
9fadab4e63 emacs: use defvar-local
It is available since Emacs 24.3 and we require at least Emacs 25.
2020-12-06 16:22:18 -04:00
Jonas Bernoulli
dff7f06711 emacs: inline notmuch-split-content-type
This trivial helper function actually made things slightly
*less* readable by adding an unnecessary indirection.
2020-12-06 16:22:07 -04:00
Jonas Bernoulli
4f57e01843 emacs: inline notmuch-documentation-first-line
Inline a simplified version of `notmuch-documentation-first-line'
into its only caller.  The new code snippet differs from the
removed function in that it returns nil instead of the empty string
for symbols that have no function documentation.  That value is
ultimately used as an argument to `concat', which treats nil like
the empty string.  So we can do the logical thing without changing
the behavior.
2020-12-06 16:21:51 -04:00
Jonas Bernoulli
6db692302d emacs: remove unnecessary notmuch-tree-button-activate
Since [1: f8bdba37] no key is bound to this command and it is
redundant because the behavior of `push-command' is identical
when called as a command.

1: f8bdba37d3
   emacs: tree: remove binding for pressing button in message pane
2020-12-06 16:21:15 -04:00
Jonas Bernoulli
e7b90eedad emacs: remove unused notmuch-address-locate-command
We stopped using it in [1: 0e671478].

1: 0e671478c6
   emacs: replace use of notmuch-address-message-insinuate
2020-12-06 16:21:07 -04:00
Jonas Bernoulli
ac8a117a84 emacs: remove unnecessary notmuch-remove-if-not
We could just have switched to using `cl-remove-if-not' instead,
but the two uses of the *remove-if-not function are pretty strange
to begin with so we refactor to not use any such function at all.
2020-12-06 16:20:57 -04:00
Jonas Bernoulli
1fbae387e3 emacs: remove deprecated notmuch-folder command
It has been deprecated for a decade and it's time to let go.
2020-12-06 16:20:44 -04:00
Jonas Bernoulli
53a4eb4780 emacs: misc doc-string improvements 2020-12-06 16:20:28 -04:00
Jonas Bernoulli
d6cacef832 emacs: always use elisp quoting style in doc-strings
Emacs doc-strings use neither markdown nor lisp symbol quoting.
2020-12-06 16:20:16 -04:00
Jonas Bernoulli
3cdf105e0f emacs: place complete first sentence on first doc-string line 2020-12-06 16:20:02 -04:00
Jonas Bernoulli
a7ba52eb94 emacs: place only first sentence on first doc-string line 2020-12-06 16:19:36 -04:00
Jonas Bernoulli
27b448f381 emacs: shorten/replace first sentence of a few doc-strings
The first sentence should fit on the first line.  It is okay if
the first sentence/line does not contain all the information that
the rest of the doc-string covers.
2020-12-06 16:19:23 -04:00
Jonas Bernoulli
471f161850 emacs: define notmuch-hello-url as a constant 2020-12-06 16:18:50 -04:00
Jonas Bernoulli
dfd99c7fba emacs: sanitize function that displays version
Previously it was defined in "notmuch-hello.el" and its name contained
"hello" solely because it replaced an anonymous function that was
mistakenly only bound in `notmuch-hello-mode-map'.  But it makes more
sense to bind it in all notmuch modes and even if we did not change
that aspect it still would make no sense to have "hello" in its name.
2020-12-06 16:18:34 -04:00
Jonas Bernoulli
ff80122972 emacs: more cleanup since dropping support for Emacs 24
Notmuch requires at least version 25 of Emacs now.

Adjust comments that previously referenced version 24 specifically,
even though they also apply to later releases. Remove documentation
and code that no longer applies.

- `mm-shr' no longer references `gnus-inhibit-images'.
2020-12-06 16:18:20 -04:00
Jonas Bernoulli
1acaaa093c emacs: remove kludge for Emacs 23 from notmuch-mua-mail
Notmuch requires at least Emacs version 25.

The `return-action' argument was added prior to Emacs 24.1
in 25ca2e61403f97b5a023164f2924d5f8aca2492a.
2020-12-06 16:17:52 -04:00
Jonas Bernoulli
f061ae5b42 emacs: fix old bug in notmuch-mua-mail
This fixes a regression introduced in [1: 7e20d264].  If the argument
RETURN-ACTION was non-nil then we should pass along the value of that
argument.  Instead we passed along the constant symbol `return-action'.

1: 7e20d26480
   emacs: Fix mail composition under Emacs 23
2020-12-06 16:17:36 -04:00
Jonas Bernoulli
8d701cdc99 emacs: remove redundant notmuch-hello-trim
Use `string-trim', which exists since Emacs 24.4.
2020-12-06 16:17:24 -04:00
Jonas Bernoulli
05a436f730 emacs: don't fset keymaps
These keymaps are never invoked as commands
so the function definitions serve no purpose.
2020-11-11 20:13:26 -04:00
Jonas Bernoulli
b9f328b75d emacs: add doc-string to notmuch-tree-mode-map 2020-11-11 20:13:16 -04:00
Jonas Bernoulli
0496668ad5 emacs: define notmuch-message-mode-map explicitly
Key bindings should not be defined at the top-level but inside
a `defvar' form.  Doing it at the top-level makes it harder to
reliably customize key bindings.
2020-11-11 20:13:00 -04:00
Jonas Bernoulli
bad0549da4 emacs: silence byte-compiler 2020-11-11 20:12:48 -04:00
Tomi Ollila
bdb6956afd emacs docs: rstdoc.el: consistent single quote conversions
With text-quoting-style 'grave keeps "'" and "`" quotes unaltered
for further processing done by this code (regardless of locale...).
The tools that read the reStructuredText markup generated can do
their styling instead.

Added temporary conversions of ' and ` to \001 and \002 so that
's and `s outside of `...' and `...` are converted separately
('s restored back to ' and `s converted to \`).

Both `...' and `...` are finally "converted" to `...` (not ``...``).
https://docutils.sourceforge.io/docs/user/rst/quickref.html documents
that as `interpreted text`:

 "The rendering and meaning of interpreted text is domain- or
  application-dependent. It can be used for things like index
  entries or explicit descriptive markup (like program identifiers)."

Which looks pretty much right.
2020-10-21 06:55:39 -03:00
Tim Quelch
45193bab16 emacs: Remove notmuch-mua-message-send-hook
Currently `message-send-hook` functions are being called twice: In
notmuch send common when `notmuch-mua-send-hook` functions are
run (which by default includes `notmuch-mua-message-send-hook`) and in
`message-send` itself.

Because `message-send-hook` functions are run in `message-send` itself,
we don't need also need to run them before we delegate to `message-send`

Calling `notmuch-mua-message-send-hook` resulted in functions in
`message-send-hook` to be called twice. This causes bugs in
non-idempotent hook functions.
2020-09-19 06:49:17 -03:00
Teemu Likonen
3512e2bc83 Emacs: Fix notmuch-message-summary-face definition
Emacs face definition forms are either

    ((DISPLAY . PLIST)
     (DISPLAY . PLIST))

or

    ((DISPLAY PLIST)   ;For backward compatibility.
     (DISPLAY PLIST))

Commit a2388bc56e (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-22 09:23:26 -03:00
Sean Whitton
88ae4f0251 emacs: Use pop-to-buffer-same-window rather than switch-to-buffer
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-22 09:11:06 -03:00
William Casarin
bcfd8575e5 emacs/tree: add notmuch-tree-archive-thread-then-next
Now that notmuch-tree-next-thread acts more like its notmuch-show
counterpart, let's update the binding to move to the next thread after
archiving.

Signed-off-by: William Casarin <jb55@jb55.com>
2020-08-16 10:42:27 -03:00