diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2021-01-10 15:00:46 +0100 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-01-13 07:10:27 -0400 |
| commit | 2ca941163da06aed564dab1990fb333fd7457ec2 (patch) | |
| tree | 00ed761cee896d322e9ba501f12582b34a007316 /emacs/notmuch-draft.el | |
| parent | adc123e4fd6384fba0165ebddc99d4323f6bee73 (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-draft.el')
| -rw-r--r-- | emacs/notmuch-draft.el | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el index f928be87..9ce9e736 100644 --- a/emacs/notmuch-draft.el +++ b/emacs/notmuch-draft.el @@ -31,6 +31,8 @@ (declare-function notmuch-show-get-message-id "notmuch-show" (&optional bare)) (declare-function notmuch-message-mode "notmuch-mua") +;;; Options + (defgroup notmuch-draft nil "Saving and editing drafts in Notmuch." :group 'notmuch) @@ -85,6 +87,8 @@ like they are intended to be sent encrypted :group 'notmuch-draft :group 'notmuch-crypto) +;;; Internal + (defvar notmuch-draft-encryption-tag-regex "<#\\(part encrypt\\|secure.*mode=.*encrypt>\\)" "Regular expression matching mml tags indicating encryption of part or message.") @@ -169,6 +173,8 @@ Really save and index an unencrypted copy? ") ;; but notmuch doesn't want that form, so remove them. (concat "draft-" (substring (message-make-message-id) 1 -1))) +;;; Commands + (defun notmuch-draft-save () "Save the current draft message in the notmuch database. @@ -226,6 +232,7 @@ applied to newly inserted messages)." (defun notmuch-draft-resume (id) "Resume editing of message with id ID." + ;; Used by command `notmuch-show-resume-message'. (let* ((tags (process-lines notmuch-command "search" "--output=tags" "--exclude=false" id)) (draft (equal tags (notmuch-update-tags tags notmuch-draft-tags)))) @@ -265,10 +272,10 @@ applied to newly inserted messages)." ;; message is resaved or sent. (setq notmuch-draft-id (and draft id))))) +;;; _ (add-hook 'message-send-hook 'notmuch-draft--mark-deleted) - (provide 'notmuch-draft) ;;; notmuch-draft.el ends here |
