aboutsummaryrefslogtreecommitdiff
path: root/emacs/notmuch-wash.el
AgeCommit message (Collapse)Author
2023-10-06emacs: update quoting in docstringsDavid Bremner
The complicated looking escapes are needed to avoid compile time warnings. (info "(elisp) Text Quoting Style") for details.
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: 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: 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-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: 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)
2018-10-21emacs: require notmuch-lib from notmuch-wash.elDavid Bremner
This is needed so that notmuch-wash.el is loadable by itself; in particular for the docstring processing.
2016-09-12emacs: wash: make word-wrap bound message widthMark Walters
Previously if notmuch-wash-wrap-lines-length was set then all messages would be wrapped at this value (or window-width if that is smaller). This was done regardless of the message's depth in a thread -- for example, if the n.w.w.l.l is 80 and the messages depth is 20 (so indented 20 by default) the messages text only got 60 characters of space. This commit changes that so a message always gets the full n.w.w.l.l of width regardless of its indentation (unless that goes over window-width of course).
2016-08-09emacs: wash: word-wrap bugfixMark Walters
Previously notmuch-wash made the width of the text (approximately) the window-width minus the depth in thread. This is correct for the default indentation of 1 per message depth, but is incorrect for any other setting of notmuch-show-indent-messages-width. As notmuch-show-indent-messages-width is customisable, and notmuch-tree sets it to zero to avoid indenting messages in the message pane, this bug can show up in real use. Two of the tests had to be updated: when notmuch-show-indent-messages-width is 0, then the new (correct) word wrapping happens later, when notmuch-show-indent-messages-width is 4, then the new word wrapping happens sooner.
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-04-16emacs: Fix packagingChunyang Xu
Refer to (info "(elisp) Library Headers") for package conventions.
2015-01-11emacs: Washing should use more `defcustom'.David Edmondson
More of the washing variables should be available through the standard customisation interface.
2015-01-11emacs: More flexible washed faces.David Edmondson
The faces used when washing messages should be notmuch specific and inherit from the underlying emacs face rather than using it directly. This allows the washed face to be modified without requiring the modification of the underlying face.
2013-05-31emacs: Retain text properties when toggling buttonsAustin Clements
Previously, we lost any text properties applied to part buttons or wash buttons when they were toggled because `insert' directly copies the text properties of the string being inserted. Fix this by capturing the properties applied to the button beforehand and re-applying them after inserting the new text.
2013-05-20emacs: show: handle inline patch fake parts at top levelMark Walters
The inline patch fake part handler also modifies the content-type so handle this in notmuch-show-insert-bodypart too.
2013-04-30emacs: fixed (declare-function ...) definitionsTomi Ollila
Some (declare-function ...) definitions were drifted away from the actual (defun ...)'s. To find the drifts and to verify changes the following command line was used: $ emacs --batch -L emacs --eval '(check-declare-directory "emacs")'
2013-02-18emacs: show: make buttons select windowMark Walters
Emacs has two button type objects: widgets (as used for saved searches in notmuch-hello) and buttons as used by parts/citations and id links in notmuch-show. These two behave subtly differently when clicked with the mouse: widgets select the window clicked before running the action, buttons do not. This patch makes all of these behave the same: clicking always selects the clicked window. It does this by defining a notmuch-button-type supertype that the other notmuch buttons can inherit from. This supertype binds the mouse-action to select the window and then activate the button.
2012-12-21emacs: Eliminate buffer invisibility specs from show and washAustin Clements
Previously, all visibility in show buffers for headers, message bodies, and washed text was specified by generating one or more symbols for each region and creating overlays with their 'invisible property set to carefully crafted combinations of these symbols. Visibility was controlled not by modifying the overlays directly, but by adding and removing the generated symbols from a gigantic buffer invisibilty spec. This has myriad negative consequences. It's slow because Emacs' display engine has to traverse the buffer invisibility list for every overlay and, since every overlay has its own symbol, this makes rendering O(N^2) in the number of overlays. It composes poorly because symbol-type 'invisible properties are taken from the highest priority overlay over a given character (which is often ambiguous!), rather than being gathered from all overlays over a character. As a result, we have to include symbols related to message hiding in the wash code lest the wash overlays un-hide parts of hidden messages. It also requires various workarounds for isearch to properly open overlays, to set up buffer-invisibility-spec for remove-from-invisibility-spec to work right, and to explicitly refresh the display after updating the buffer invisibility spec. None of this is necessary. This patch converts show and wash to use simple boolean 'invisible properties and to not use the buffer invisibility spec. Rather than adding and removing generated symbols from the invisibility spec, the code now directly toggles the 'invisible property of the appropriate overlay. This speeds up rendering because the display engine only has to check the boolean values of the overlays over a character. It composes nicely because text will be invisible if *any* overlay over it has 'invisible t, which means we can overlap invisibility overlays with abandon. We no longer need any of the workarounds mentioned above. And it fixes a minor bug for free: now, when isearch opens a washed region, the button text will update to say "Click/Enter to hide" rather than remaining unchanged.
2012-06-29emacs: Add configurable wrapping width for notmuch-wash-wrap-long-linesDaniel Schoepe
This introduces a variable to control after how many characters a line is wrapped by notmuch-wash-wrap-long-lines (still wrapping at the window width if it is lower).
2012-02-04emacs: fix `notmuch-wash-region-to-button' to work at beginning of bufferDmitry Kurochkin
`Notmuch-wash-region-to-button' is the function that creates hidden regions with buttons for signatures, citations and original messages. Before the change, it did not work correctly if the to-be-hidden region started at the beginning of a message: the visibility toggle button was hidden as well. The patch fixes this. There are two parts in the fix: * Use `insert-before-markers' instead of `insert' for creating the button, so that it does not get added to the hidden overlay. * Stop using PREFIX argument for adding a newline before the button. The newline should not be added before a button at the beginning of buffer. The corresponding test is fixed now.
2012-02-01emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."Pieter Praet
Less code, same results, without sacrificing readability.
2011-12-28emacs: create patch filename from subject for inline patch fake partsJani Nikula
Use the mail subject line for creating a descriptive filename for the wash generated inline patch fake parts. The names are similar to the ones created by 'git format-patch'. If the user has notmuch-wash-convert-inline-patch-to-part hook enabled in notmuch-show-insert-text/plain-hook, this will change the old default filename of "inline patch" in fake parts: [ inline patch: inline patch (as text/x-diff) ] into, for example: [ 0002-emacs-create-patch-filename-from-subject-for-inline.patch: inline patch (as text/x-diff) ] which is typically the same filename the sender had if he was using 'git format-patch' and 'git send-email'. Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-28emacs: add inline patch fake parts through a special handlerJani Nikula
Add wash generated inline patch fake parts through a special "inline-patch-fake-part" handler to distinguish them from real MIME parts. The fake parts are described as "inline patch (as text/x-diff)". Signed-off-by: Jani Nikula <jani@nikula.org>
2011-06-23fix sum moar typos [user-visible documentation in code]Pieter Praet
Various typo fixes in documentation within the code that can be made available to the user, (emacs function help strings, "notmuch help" output, notmuch man page, etc.). Signed-off-by: Pieter Praet <pieter@praet.org> Edited-by: Carl Worth <cworth@cworth.org> Restricted to just documentation and fixed fix of "comman" to "common" rather than "command".
2011-06-15Set higher priority for headers and hidden citation overlays.Dmitry Kurochkin
Before the patch, message, headers and hidden citation overlays had zero priority. All these overlay have `invisible' property. Emacs documentation says that we should not make assumptions about which overlay will prevail when they have the same priority [1]. It happens to work as we need, but we should not rely on undocumented behavior. [1] http://www.gnu.org/s/emacs/manual/html_node/elisp/Overlay-Properties.html
2011-06-15Fix hiding a message while some citations are shown in notmuch-show view.Dmitry Kurochkin
Before the change, message and citation invisibility overlays conflicted: if some citation is made visible and then the whole message is hidden, that citation remained visible. This happened because the citation's overlay has an invisible property which takes priority over the message overlay. The message invisibility spec does not affect citation visibility, it is determined solely by the citation overlay invisibility spec. Hence, if citation is made visible, it is not hidden by message invisibility spec. The patch changes citation overlay invisibility property to be a list which contains both the citation and the message invisibility specs. This makes the citation invisible if either of them is added to the `buffer-invisibility-spec'. Note that all citation visibility states are "restored" when the message hidden and shown again.
2011-06-15Pass message to the `notmuch-show-insert-text/plain-hook' hook.Dmitry Kurochkin
Before the change, the `notmuch-show-insert-text/plain-hook' was given only the `depth' argument. The patch adds another one - the message. Currently, the new message argument is not used by any on the hooks. But it will be used later to get access to message invisibility specs when wash buttons are inserted.
2011-06-15Workaround for Emacs bug #8721.Dmitry Kurochkin
The emacs bug is that isearch cannot search through invisible text when the 'invisible' property is a list. The patch adds `notmuch-isearch-range-invisible' function which is the same as `isearch-range-invisible' but with fixed Emacs bug #8721. Advice added for `isearch-range-invisible' which calls `notmuch-isearch-range-invisible' instead of the original `isearch-range-invisible' when in `notmuch-show-mode'.
2011-06-10notmuch.el: hide original message in top posted replies.David Bremner
This code treats top posted copies essentially like signatures, except that it doesn't sanity check their length, since neither do their senders. New user-visible variables: notmuch-wash-button-original-hidden-format notmuch-wash-button-original-visible-format Rebased-by: Carl Worth <cworth@cworth.org>
2011-06-01emacs: Use "message-cited-text" instead of "message-cited-text-face"Pieter Praet
(describe-face 'message-cited-text-face) > message-cited-text-face is an alias for the face `message-cited-text'. > This face is obsolete since 22.1; use `message-cited-text' instead. Signed-off-by: Pieter Praet <pieter@praet.org> Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-05-24Carefully manage save/restore of point in `notmuch-wash-toggle-invisible-action'.Dmitry Kurochkin
Before the change, save-excursion was used to save the point. But the marker saved by save-excursion was inside a region that was deleted, so that approach is unreliable, (leading to point jumping to a new position past the button). This patch instead saves point in an integer variable, and when restoring, carefully avoids moving point past the button, (in case the new button label is shorter than the old button label).
2011-05-24Use different labels for wash buttons when text is visible or hidden.Dmitry Kurochkin
Before the change, citation and signature wash buttons used the same label in both visible and hidden states. Sometimes it is very convenient when you can determine if the text is hidden or shown without reading the context and/or clicking the button. The patch makes it easy to see if the text is shown or hidden by explicitly saying what the button does (shows or hides the text).
2010-12-07emacs: Remove over-eager regular expressions from notmuch-wash-tidy-citations.David Edmondson
The removed expressions, which were used to ensure that citations were both preceded and followed by a blank line, were poorly implemented and caused a regexp stack overflow on messages more than a few thousand lines long.
2010-11-11emacs: Correctly count the number of lines in a signature.David Edmondson
2010-06-03emacs: More functionality for `notmuch-wash-tidy-citations'.David Edmondson
Add: - Insert a blank line before a citation if there isn't one, - Insert a blank line after a citation if there isn't one.
2010-04-27emacs: Add missing parenthesis that was breaking the build.Carl Worth
Someday I'll stop pushing patches without at least compile-testing them. *sigh*
2010-04-27emacs/notmuch-wash.el: Add `notmuch-wash-convert-inline-patch-to-part'.David Edmondson
Detect inline patches and convert them to fake attachments, in order that `diff-mode' highlighting can be applied to the patch. This can be enabled by customising `notmuch-show-insert-text/plain-hook'.
2010-04-26emacs: Add more functions to clean up text/plain partsDavid Edmondson
Add: - notmuch-wash-wrap-long-lines: Wrap lines longer than the width of the current window whilst maintaining any citation prefix. - notmuch-wash-tidy-citations: Tidy up citations by: - compress repeated otherwise blank citation lines, - remove otherwise blank citation lines at the head and tail of a citation, - notmuch-wash-elide-blank-lines: Compress repeated blank lines and remove leading and trailing blank lines. None of these is enabled by default - add them to `notmuch-show-insert-text/plain-hook' to use. Reviewed-by: Carl Worth <cworth@cworth.org>: I previously committed a stale version of this patch.
2010-04-26Revert "emacs: Add more functions to clean up text/plain parts"Carl Worth
This reverts commit 97570954cb583cacac35b0235cbe449a07630ae3.
2010-04-24emacs: Add more functions to clean up text/plain partsDavid Edmondson
Add: - notmuch-wash-wrap-long-lines: Wrap lines longer than the width of the current window whilst maintaining any citation prefix. - notmuch-wash-tidy-citations: Tidy up citations by: - compress repeated otherwise blank citation lines, - remove otherwise blank citation lines at the head and tail of a citation and remove blank lines between attribution statements and the citation, - notmuch-wash-compress-blanks: Compress repeated blank lines and remove leading and trailing blank lines. Enable `notmuch-wash-tidy-citations' and `notmuch-wash-compress-blanks' by default by adding them to `notmuch-show-insert-text/plain-hook'. `notmuch-wash-wrap-long-lines' is not enabled by default. If `notmuch-wash-wrap-long-lines' is enabled, word wrapping of the buffer leads to an unappealing display of text, so provide a function to disable it and add it to the list of `notmuch-show-mode' hook functions.
2010-04-24emacs: Fix i-search to open up invisible citations as necessaryDavid Edmondson
Add an `isearch-open-invisible' property to the overlays used to hide citations and signatures, together with an appropriate function to leave the invisible text visible should that be required.
2010-04-21emacs: Move body markup to a separate fileDavid Edmondson
Move the citation and signature markup for text/plain parts to a new file (notmuch-wash.el) and call it using a hook mechanism rather than directly.