[PATCH] emacs: use define-derived-mode for defining modes.
Tomi Ollila
tomi.ollila at iki.fi
Thu Sep 1 07:57:07 PDT 2016
On Sun, Aug 28 2016, Steven Allen <steven at stebalien.com> wrote:
> This sets up and runs all the correct hooks and reduces some redundancy.
I don't why this would work or not, but I put this into my build
configuration so let's see...
Tomi
> ---
> emacs/notmuch-hello.el | 8 +-------
> emacs/notmuch-show.el | 7 +------
> emacs/notmuch-tree.el | 7 +------
> emacs/notmuch.el | 7 +------
> 4 files changed, 4 insertions(+), 25 deletions(-)
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 75ccf57..d582bff 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -671,7 +671,7 @@ with `notmuch-hello-query-counts'."
> "Keymap for \"notmuch hello\" buffers.")
> (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
>
> -(defun notmuch-hello-mode ()
> +(define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello"
> "Major mode for convenient notmuch navigation. This is your entry portal into notmuch.
>
> Saved searches are \"bookmarks\" for arbitrary queries. Hit RET
> @@ -702,13 +702,7 @@ The screen may be customized via `\\[customize]'.
> Complete list of currently available key bindings:
>
> \\{notmuch-hello-mode-map}"
> - (interactive)
> - (kill-all-local-variables)
> (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
> - (use-local-map notmuch-hello-mode-map)
> - (setq major-mode 'notmuch-hello-mode
> - mode-name "notmuch-hello")
> - (run-mode-hooks 'notmuch-hello-mode-hook)
> ;;(setq buffer-read-only t)
> )
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 6d3149b..eb6877e 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1454,7 +1454,7 @@ reset based on the original query."
> "Keymap for \"notmuch show\" buffers.")
> (fset 'notmuch-show-mode-map notmuch-show-mode-map)
>
> -(defun notmuch-show-mode ()
> +(define-derived-mode notmuch-show-mode fundamental-mode "notmuch-show"
> "Major mode for viewing a thread with notmuch.
>
> This buffer contains the results of the \"notmuch show\" command
> @@ -1482,12 +1482,7 @@ You can add or remove arbitrary tags from the current message with
> All currently available key bindings:
>
> \\{notmuch-show-mode-map}"
> - (interactive)
> - (kill-all-local-variables)
> (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
> - (use-local-map notmuch-show-mode-map)
> - (setq major-mode 'notmuch-show-mode
> - mode-name "notmuch-show")
> (setq buffer-read-only t
> truncate-lines t))
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 5231319..d864e6d 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -803,7 +803,7 @@ This function inserts a collection of several complete threads as
> passed to it by notmuch-tree-process-filter."
> (mapc 'notmuch-tree-insert-forest-thread forest))
>
> -(defun notmuch-tree-mode ()
> +(define-derived-mode notmuch-tree-mode fundamental-mode "notmuch-tree"
> "Major mode displaying messages (as opposed to threads) of of a notmuch search.
>
> This buffer contains the results of a \"notmuch tree\" of your
> @@ -817,12 +817,7 @@ Complete list of currently available key bindings:
>
> \\{notmuch-tree-mode-map}"
>
> - (interactive)
> - (kill-all-local-variables)
> (setq notmuch-buffer-refresh-function #'notmuch-tree-refresh-view)
> - (use-local-map notmuch-tree-mode-map)
> - (setq major-mode 'notmuch-tree-mode
> - mode-name "notmuch-tree")
> (hl-line-mode 1)
> (setq buffer-read-only t
> truncate-lines t))
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 43d56f7..ecf7198 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -331,7 +331,7 @@ This face is the default value for the \"unread\" tag in
> :group 'notmuch-search
> :group 'notmuch-faces)
>
> -(defun notmuch-search-mode ()
> +(define-derived-mode notmuch-search-mode fundamental-mode "notmuch-search"
> "Major mode displaying results of a notmuch search.
>
> This buffer contains the results of a \"notmuch search\" of your
> @@ -361,8 +361,6 @@ new, global search.
> Complete list of currently available key bindings:
>
> \\{notmuch-search-mode-map}"
> - (interactive)
> - (kill-all-local-variables)
> (make-local-variable 'notmuch-search-query-string)
> (make-local-variable 'notmuch-search-oldest-first)
> (make-local-variable 'notmuch-search-target-thread)
> @@ -370,10 +368,7 @@ Complete list of currently available key bindings:
> (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
> (set (make-local-variable 'scroll-preserve-screen-position) t)
> (add-to-invisibility-spec (cons 'ellipsis t))
> - (use-local-map notmuch-search-mode-map)
> (setq truncate-lines t)
> - (setq major-mode 'notmuch-search-mode
> - mode-name "notmuch-search")
> (setq buffer-read-only t))
>
> (defun notmuch-search-get-result (&optional pos)
> --
> 2.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list