Commit graph

981 commits

Author SHA1 Message Date
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
William Casarin
874f14ec2b emacs/tree: enable moving to next thread in search results
This introduces a new function called
notmuch-tree-next-thread-from-search which is analogous to
notmuch-show-next-thread. It will switch to the next or previous
thread from the parent search results.

We rename notmuch-tree-{prev,next}-thread to a more descriptive
notmuch-tree-{prev,next}-thread-in-tree to reflect the fact that it
only moves to the next thread in the current tree.

notmuch-tree-next-thread now switches to the next thread in the
current tree first, but if there are none, it looks for the next tree
in the search results.

This makes notmuch-tree feel more like notmuch-show when using the
M-Enter, M-n and M-p bindings.

Signed-off-by: William Casarin <jb55@jb55.com>
2020-08-16 10:42:17 -03:00
William Casarin
189175ecd6 emacs/tree: introduce notmuch-tree-parent-buffer variable
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-16 10:42:02 -03:00
Teemu Likonen
adb90b9bb6 Emacs: Indent first header line only when indentation is turned on
Previously in message-show mode message's first header line (From
header) was always indented, even if user had turned thread
indentation off with "<" (notmuch-show-toggle-thread-indentation)
command.

This change modifies notmuch-show-insert-headerline function so that
it doesn't indent the first header line if notmuch-show-indent-content
variable is nil.

This change also modifies tests so that they expect this new output
format:
test/emacs-show.expected-output/notmuch-show-indent-thread-content-off
2020-08-15 09:16:34 -03:00
Jonas Bernoulli
6336c26d23 emacs: Use new advice mechanism do advice mm-shr
Also because we now only support Emacs >= 25,
we can remove the check for Emacs >= 24.
2020-08-09 21:17:39 -03:00
Jonas Bernoulli
96baa22318 emacs: Drop old advices that were only need for Emacs 23 2020-08-09 21:16:12 -03:00
Jonas Bernoulli
08b26f449d emacs: Remove notmuch-read-char-choice
Just use `read-char-choice', which existed since Emacs 24.1.
2020-08-09 21:15:54 -03:00
Jonas Bernoulli
2156517d90 emacs: Remove notmuch-setq-local
Just use setq-local, which existed since Emacs 24.3.
2020-08-09 21:15:27 -03:00
Jonas Bernoulli
9946380e47 emacs: Use cl-incf where appropriate
It's shorter.  That's it pretty much.
2020-08-09 21:15:27 -03:00
Jonas Bernoulli
42781f1821 NEWS: At least Emacs 25.1 is required now
Some backward incompatible changes follow in the next few commits
and going forward contributors don't have to worry about Emacs 24
at all anymore.
2020-08-09 21:14:36 -03:00
Jonas Bernoulli
a1b757c1ca emacs: Add end-of-file line to libraries that lack it 2020-08-09 21:14:36 -03:00
Jonas Bernoulli
254d0f9515 emacs: Provide 'rstdoc' feature at end of file
Features should nearly always be provided at the very end of their
libraries.  This feature isn't one of the rare exceptions.
2020-08-09 21:14:36 -03:00
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00