Commit graph

50 commits

Author SHA1 Message Date
Jonas Bernoulli
16b2db0986 emacs: various cosmetic improvements 2021-01-15 06:38:00 -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
54492ddf23 emacs: do not quote self-quoting t 2020-12-06 16:23:11 -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
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
df3fab18fe emacs: Increase consistency of library headers 2020-08-09 21:14:36 -03:00
Jonas Bernoulli
dfb1b8eb89 emacs: Use 'and' instead of 'when' when the return value matters
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-09 20:51:16 -03:00
Jonas Bernoulli
caaa108760 emacs: Fix indentation 2020-08-09 20:48:09 -03:00
Jonas Bernoulli
6fb7d35069 emacs: Remove excess empty lines
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-09 20:47:52 -03:00
Jonas Bernoulli
a4617f29ce emacs: Shorten long lines 2020-08-09 19:48:36 -03:00
Tomi Ollila
ed40579ad3 emacs docstrings: consistent indentation, newlines, periods
Fixed emacs docstrings to be consistent. No functional change.

- removed some (accidental) indentation
- removed some trailing newlines
- added trailing periods where missing (some exclusions)
2020-06-06 07:55:58 -03:00
Jonas Bernoulli
11ac932a45 emacs: Use cl-lib' instead of deprecated cl'
Starting with Emacs 27 the old `cl' implementation is finally
considered obsolete.  Previously its use was strongly discouraged
at run-time but one was still allowed to use it at compile-time.

For the most part the transition is very simple and boils down to
adding the "cl-" prefix to some symbols.  A few replacements do not
follow that simple pattern; e.g. `first' is replaced with `car',
even though the alias `cl-first' exists, because the latter is not
idiomatic emacs-lisp.

In a few cases we start using `pcase-let' or `pcase-lambda' instead
of renaming e.g. `first' to `car'.  That way we can remind the reader
of the meaning of the various parts of the data that is being
deconstructed.

An obsolete `lexical-let' and a `lexical-let*' are replaced with their
regular variants `let' and `let*' even though we do not at the same
time enable `lexical-binding' for that file.  That is the right thing
to do because it does not actually make a difference in those cases
whether lexical bindings are used or not, and because this should be
enabled in a separate commit.

We need to explicitly depend on the `cl-lib' package because Emacs
24.1 and 24.2 lack that library.  When using these releases we end
up using the backport from GNU Elpa.

We need to explicitly require the `pcase' library because
`pcase-dolist' was not autoloaded until Emacs 25.1.
2020-04-27 07:36:10 -03:00
Daniel Kahn Gillmor
f079e7b9c3 emacs: drop use of message-default-charset
Apparently, message-default-charset is deprecated, which causes the
following warning messages during the build:

  In notmuch-maildir-setup-message-for-saving:
  emacs/notmuch-maildir-fcc.el:172:31:Warning: ‘message-default-charset’ is an
      obsolete variable (as of 26.1); The default charset comes from the
      language environment

In discussion with emacs upstream over on
https://debbugs.gnu.org/35370, it appears that we can just drop this
entirely and things should still work with emacs 25.
2019-05-07 06:35:44 -03:00
Piotr Trojanek
c9deb32933 remove extra space in Emacs prompt
Trivial: fix extra space in the "Insert failed" Emacs prompt message.
2017-06-25 09:57:48 -03:00
Jani Nikula
524372de10 emacs: use (system-name) instead of system-name
Fix the deprecation warning:

In notmuch-maildir-fcc-make-uniq-maildir-id:
emacs/notmuch-maildir-fcc.el:279:53:Warning: ‘system-name’ is an obsolete
    variable (as of 25.1); use (system-name) instead

I've used (system-name) since at least 2011, so it must have been
around quite a while.
2017-02-26 07:37:01 -04:00
Mark Walters
a3e712fa86 emacs: add compatibility functions for emacs 23
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-16 21:42:34 -04:00
Keith Amidon
4bf3bb31dd Expand docstrings about fcc using notmuch-insert
This commit expands docstrings for notmuch-fcc-dirs and
notmuch-maildir-fcc-with-notmuch-insert to describe how quoted strings
are processed and make the ability to configure sent folders containing
whitespace more discoverable.
2016-10-22 12:28:13 -03:00
Mark Walters
0b138c2686 emacs: fcc: say we are doing Fcc
Since doing the Fcc with notmuch insert could be slow (if the indexing
takes some time) add a message saying we are doing it.
2016-09-30 07:13:54 -03:00
Mark Walters
4266e76eed emacs: document notmuch-fcc-dirs
This updates the docstring for the variable notmuch-fcc-dirs to match
the new insert code.
2016-09-29 08:07:38 -03:00
Mark Walters
fce8146a8b emacs: maildir: add the actual insert code
With all the preparation it is now simple to add the actual insert
code. Since insert can fail for many reasons we let the user decide
interactively deal with it.

We modify test-lib.el to set file fcc, so that all the old tests and
emacs_fcc_message from test-lib.sh still work
2016-09-04 08:23:14 -03:00
Mark Walters
cf59859b20 Modify our local copy of message-do-fcc
Since we also need to use this code for the draft handling we split
message-do-fcc into convenient sub-chunks (functions or macros as
appropriate).
2016-09-04 08:23:04 -03:00
Mark Walters
aa1e8352de emacs: simplify our local copy of message-do-fcc
message-do-fcc has lots of functionality we don't need, so remove it.
2016-09-04 08:22:56 -03:00
Mark Walters
967bbc0792 emacs: maildir import message-do-fcc
We will need our own local copy of message-do-fcc so this commit just
copies the code straight from message.el so that it is easier to see
our local changes coming in the next commit.
2016-09-04 08:22:48 -03:00
Mark Walters
37859d1fcb emacs: maildir-fcc: prepare for use of notmuch insert
We move some code around in preparation for the use of notmuch
insert. In particular, we move the check for a valid maildir for the
fcc to when the message is sent rather than when the fcc header is
inserted. The main motivation is consistency with the insert version
(coming later) where we cannot check the validity until send.

We allow the user some chance to correct the header; the choice here
is intended to be consistent with the insert version to come.
2016-09-04 08:22:39 -03:00
Chunyang Xu
0cf457b73b emacs: Fix packaging
Refer to (info "(elisp) Library Headers") for package conventions.
2016-04-16 08:24:42 -03:00
David Bremner
d0553ad524 emacs: make modifications to message Fcc vars buffer-local
Previously we globally modified these variables, which tended to cause
problems for people using message-mode, but not notmuch-mua-mail, to
send mail.

User visible changes:

- Calling notmuch-fcc-header-setup is no longer optional. OTOH, it
  seems to do the right thing if notmuch-fcc-dirs is set to nil.

- The Fcc header is visible during message composition

- The name in the mode line is changed, and no longer matches exactly
  the menu label.

- Previously notmuch-mua-send-and-exit was never called.  Either we
  misunderstood define-mail-user-agent, or it had a bug.  So there was
  no difference if the user called message-send-and-exit directly. Now
  there will be.

- User bindings to C-c C-c and C-c C-s in message-mode-map are
  overridden. The user can override them in notmuch-message-mode-map,
  but then they're on their own for Fcc handling.
2015-08-07 21:18:59 +02:00
Jesse Rosenthal
d094153a26 emacs: derive correct timestamp in FCC unique name
Previously, the timestamp at the beginning of the FCC unique maildir
name was derived incorrectly, thanks to an integer overflow. This
changes the derivation of timestamp to use a float, and so will get
the number correct at least until 2038. (It is still formatted with
"%d" so it will show up as an integer.) Should we need to change it in
the next 26 years to take the unix millenium into account, it will be
invisible to users.

This change is mostly a question of consistency, since the unique name
is arbitrary anyway. But since most people use timestamps, and that was
the original intention here as well, we might as well.

Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>
2012-06-22 07:39:21 -03:00
Pieter Praet
643ce61c1b emacs: logically group def{custom,face}s
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.
2012-01-19 09:27:02 -04:00
Aaron Ecay
e3260d0253 Don't quote lambda forms
This generates byte-compiler warnings on (at least) current trunk
versions of Emacs.  The quote is not necessary; lambda forms are
self-quoting.
2011-12-21 07:27:38 -04:00
Pieter Praet
607a73010a fix sum moar typos [error messages]
Various typo fixes in error messages within the source code.

Signed-off-by: Pieter Praet <pieter@praet.org>

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just error messages.
2011-06-23 15:59:03 -07:00
Dmitry Kurochkin
ce08571428 Fix wrong-type-argument lisp error in `notmuch-fcc-header-setup'
This error occurs when `notmuch-fcc-dirs' is set to a list.  The error
was in the `notmuch-fcc-dirs' format check which was changed in an
incompatible way from 0.4 to 0.5.

The fix was extracted from a bigger patch series by David
Edmondson id:"1290682750-30283-2-git-send-email-dme@dme.org".

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-06-23 15:19:06 -07:00
Dmitry Kurochkin
a0f09b4942 Use message-field-value instead of message-fetch-field in FCC header setup.
For message-fetch-field the buffer is expected to be narrowed to
just the header of the message.  That is not the case when
notmuch-fcc-header-setup is run, hence a wrong header value may be
returned.  E.g. when forwarding an
email, (message-fetch-field "From") returns the From header value
of the forwarded email.

Message-field-value is the same as message-fetch-field, only
narrows the buffer to the headers first.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-06-03 12:30:55 -07:00
David Edmondson
cafd46ca13 emacs: Use truenames for Fcc paths.
Appease the test suite by using the true name for the Fcc directory
path, otherwise a value for `notmuch-database-path' which includes
symbolic links causes test suite failures.
2010-12-07 13:47:59 -08:00
David Edmondson
ea1c2bb5c5 emacs: Improve the definition and use of `notmuch-fcc-dirs'.
Re-work the declaration and definition of `notmuch-fcc-dirs'. The
variable now allows three types of values:

- nil: no Fcc header is added,

- a string: the value of `notmuch-fcc-dirs' is the name of the
  folder to use,

- a list: the folder is chosen based on the From address of the
  current message using a list of regular expressions and
  corresponding folders:

     ((\"Sebastian@SSpaeth.de\" . \"privat\")
      (\"spaetz@sspaeth.de\" . \"OUTBOX.OSS\")
      (\".*\" . \"defaultinbox\"))

  If none of the regular expressions match the From address, no
  Fcc header will be added.
2010-11-11 17:16:28 -08:00
Rob Browning
b67c3ed609 Move notmuch-fcc-header-setup to message-header-setup-hook.
Call notmuch-fcc-header-setup from message-header-setup-hook rather
than message-send-hook.  This allows you to see what's going to
happen, and to make manual adjustments if desired.  Gnus does
something similar.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2010-10-27 17:36:02 -07:00
Carl Worth
a3883a7e17 emacs: Enable FCC (to a directory named "sent") by default.
Now that the FCC code is fixed to use the notmuch database path, we can
actually enable this by default, which should be highly useful for all
new users of notmuch.
2010-10-27 17:02:44 -07:00
Carl Worth
8b6f3e3f45 emacs: Change FCC to be relative to notmuch mail store, not message-directory
Otherwise, FCC is too hard to use, (user must set it and also set message-
directory variable to match notmuch mail datbase path). As a rule, I'd like
for users of notmuch to not be required to muck around with non-notmuch
mail settings in emacs.

The above is only really possible now thanks to the recent addition of the
"notmuch config get" command which allows emacs to query the currently
configured notmuch database path.

This also now allows an absolute-path FCC to be set if desired.
2010-10-27 16:27:43 -07:00
Sebastian Spaeth
fc73737ff5 Easier way to define a fcc directory
In the common case that a user only has one FCC (save outgoing mail in
the Mail directory, it is now possible to simply configure a string
such as "Sent" in the notmuch-fcc-dirs variable. More complex options,
depending on a users email address, are possible and described in the
variable customization help text.

The whole function notmuch-fcc-header-setup has been cleaned up a
little while working on that.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-06-03 16:50:46 -07:00
Jesse Rosenthal
80a9078716 emacs: Remove conditional from notmuch-fcc-initialization.
The fcc code would only initialize if notmuch-fcc-dirs was set. This was
a problem if you reset the variable, or added the variable later during
initialization. Now we always add the fcc hook, but it doesn't do
anything unless notmuch-fcc-dirs are set.
2010-04-27 09:42:40 -07:00
Carl Worth
173a195da9 emacs: Delete some trailing whitespace.
That managed to sneak in with some recent improvements to the Fcc code.
2010-04-26 23:09:08 -07:00
Jesse Rosenthal
24a7a10af2 emacs: Ensure that message-directory for Fcc has a trailing slash
Use `file-name-as-directory' to ensure that message-directory has a
trailing slash so it can be combined with the notmuch-fcc-dirs
correctly.
2010-04-26 23:06:54 -07:00
Jesse Rosenthal
07c8eb1db6 emacs: add prompt to create maildir for fcc if it does not exist.
If the user specifies a maildir that does not exist, prompt the user to
see whether a maildir should be created. This will fail, with the
relevant explanation, if the location is not writable, or if a file
already exists in that location. If the location is a dir, but not a
maildir, this will add /tmp/cur/new to it.
2010-04-26 23:06:50 -07:00
Jesse Rosenthal
9b85872ed4 emacs: fcc should fail at the right time if it doesn't point to a maildir
Throw an error after the maildir is generated but before the message
is sent. This change allows the user to edit the maildir if it fails,
so that it will point to a correct place.

Note that this changes the previous behavior which always overwrote
the existing Fcc line. Now, an Fcc line is only auto-generated if
there isn't one already there.

The ideal change would be to prompt to create a maildir. This should
enable a place for doing that in a future patch.
2010-04-26 23:06:36 -07:00
Carl Worth
2b49f4631c emacs: Fix to generate error if fcc directory is not a maildir
Previously this was just a message that was almost impossible for the
user to see. Now, the user gets to see the error message, and is
presented with a buffer that actually contains the Fcc header of
interest.
2010-04-26 14:56:46 -07:00
Sebastian Spaeth
4b34effca5 Integrate notmuch-fcc mechansim
I have gone wild and added a defcustom "notmuch-fcc-dirs".
Depending on the value of that variable we will not do any
maildir fcc at all (nil, the default), or it is of the format
(("defaultsentbox")
 ("full name <email@address>" . "Work/sentbox")
 ("full name2 <email2@address2>" . "Work2/sentbox"))

The outbox name will be concatenated with the message mode
variable "message-directory" which is "~/Mail/" by default.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-26 12:00:13 -07:00
Sebastian Spaeth
c000c4b394 notmuch-maildir-fcc: elisp syntax fixes
1)use insert-buffer-substring

Rather than the insert-buffer. Emacs complains that it is for interactive use
and not for use within elisp. So use insert-buffer-substring which does the
same thing when not handed any 'begin' 'end' parameters.

2)replace caddr with (car (cdr (cdr)))

The former requires 'cl to be loaded and during make install emacs complained
about not knowing it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-26 11:58:43 -07:00
Sebastian Spaeth
36245db69d Integrate notmuch-maildir-fcc into notmuch
Require notmuch-maildir-fcc and also install it.
Rename all jkr/* functions to notmuch-maildir-fcc-*

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-26 11:58:34 -07:00
Jesse Rosenthal
1775893720 Add elisp file for FCC to maildir solution
File grabbed from http://jkr.acm.jhu.edu/jkr-maildir.el
but not integrated yet.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-26 11:54:15 -07:00