aboutsummaryrefslogtreecommitdiff
path: root/emacs/notmuch.el
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2021-01-10 15:00:46 +0100
committerDavid Bremner <david@tethera.net>2021-01-13 07:10:27 -0400
commit2ca941163da06aed564dab1990fb333fd7457ec2 (patch)
tree00ed761cee896d322e9ba501f12582b34a007316 /emacs/notmuch.el
parentadc123e4fd6384fba0165ebddc99d4323f6bee73 (diff)
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.
Diffstat (limited to 'emacs/notmuch.el')
-rw-r--r--emacs/notmuch.el32
1 files changed, 31 insertions, 1 deletions
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index bba4ca03..6a09dd38 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -80,6 +80,8 @@
(require 'notmuch-message)
(require 'notmuch-parser)
+;;; Options
+
(defcustom notmuch-search-result-format
`(("date" . "%12s ")
("count" . "%-7s ")
@@ -115,6 +117,8 @@ there will be called at other points of notmuch execution."
(defvar notmuch-query-history nil
"Variable to store minibuffer history for notmuch queries.")
+;;; Mime Utilities
+
(defun notmuch-foreach-mime-part (function mm-handle)
(cond ((stringp (car mm-handle))
(dolist (part (cdr mm-handle))
@@ -151,6 +155,8 @@ there will be called at other points of notmuch execution."
(mm-save-part p))))
mm-handle))
+;;; Integrations
+
(require 'hl-line)
(defun notmuch-hl-line-mode ()
@@ -158,6 +164,8 @@ there will be called at other points of notmuch execution."
(when hl-line-overlay
(overlay-put hl-line-overlay 'priority 1))))
+;;; Options
+
(defcustom notmuch-search-hook '(notmuch-hl-line-mode)
"List of functions to call when notmuch displays the search results."
:type 'hook
@@ -165,6 +173,8 @@ there will be called at other points of notmuch execution."
:group 'notmuch-search
:group 'notmuch-hooks)
+;;; Keymap
+
(defvar notmuch-search-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-common-keymap)
@@ -195,6 +205,8 @@ there will be called at other points of notmuch execution."
map)
"Keymap for \"notmuch search\" buffers.")
+;;; Stashing
+
(defvar notmuch-search-stash-map
(let ((map (make-sparse-keymap)))
(define-key map "i" 'notmuch-search-stash-thread-id)
@@ -214,12 +226,16 @@ there will be called at other points of notmuch execution."
(interactive)
(notmuch-common-do-stash (notmuch-search-get-query)))
+;;; Variables
+
(defvar notmuch-search-query-string)
(defvar notmuch-search-target-thread)
(defvar notmuch-search-target-line)
(defvar notmuch-search-disjunctive-regexp "\\<[oO][rR]\\>")
+;;; Movement
+
(defun notmuch-search-scroll-up ()
"Move forward through search results by one window's worth."
(interactive)
@@ -271,6 +287,8 @@ there will be called at other points of notmuch execution."
(interactive)
(goto-char (point-min)))
+;;; Faces
+
(defface notmuch-message-summary-face
`((((class color) (background light))
,@(and (>= emacs-major-version 27) '(:extend t))
@@ -356,6 +374,8 @@ This face is the default value for the \"unread\" tag in
:group 'notmuch-search
:group 'notmuch-faces)
+;;; Mode
+
(define-derived-mode notmuch-search-mode fundamental-mode "notmuch-search"
"Major mode displaying results of a notmuch search.
@@ -400,6 +420,8 @@ Complete list of currently available key bindings:
(setq imenu-extract-index-name-function
#'notmuch-search-imenu-extract-index-name-function))
+;;; Search Results
+
(defun notmuch-search-get-result (&optional pos)
"Return the result object for the thread at POS (or point).
@@ -558,6 +580,8 @@ thread."
(let ((message-id (notmuch-search-find-thread-id)))
(notmuch-mua-new-reply message-id prompt-for-sender nil)))
+;;; Tags
+
(defun notmuch-search-set-tags (tags &optional pos)
(let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags)))
(notmuch-search-update-result new-result pos)))
@@ -639,6 +663,8 @@ This function advances the next thread when finished."
(when (eq beg end)
(notmuch-search-next-thread)))
+;;; Search Results
+
(defun notmuch-search-update-result (result &optional pos)
"Replace the result object of the thread at POS (or point) by
RESULT and redraw it.
@@ -881,6 +907,8 @@ sets the :orig-tag property."
(notmuch-sexp-parse-partial-list 'notmuch-search-append-result
results-buf)))))
+;;; Commands (and some helper functions used by them)
+
(defun notmuch-search-tag-all (tag-changes)
"Add/remove tags from all messages in current search buffer.
@@ -1132,7 +1160,7 @@ notmuch buffers exist, run `notmuch'."
(pop-to-buffer-same-window first))
(notmuch))))
-;;;; Imenu Support
+;;; Imenu Support
(defun notmuch-search-imenu-prev-index-position-function ()
"Move point to previous message in notmuch-search buffer.
@@ -1149,6 +1177,8 @@ beginning of the line."
(author (notmuch-search-find-authors)))
(format "%s (%s)" subject author)))
+;;; _
+
(setq mail-user-agent 'notmuch-user-agent)
(provide 'notmuch)