From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A55F46DE012F for ; Sun, 28 Aug 2016 11:41:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.532 X-Spam-Level: X-Spam-Status: No, score=-0.532 tagged_above=-999 required=5 tests=[AWL=-0.062, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cHcsIjEW4lde for ; Sun, 28 Aug 2016 11:41:25 -0700 (PDT) Received: from mail-qt0-f195.google.com (mail-qt0-f195.google.com [209.85.216.195]) by arlo.cworth.org (Postfix) with ESMTPS id 5FBE36DE00EB for ; Sun, 28 Aug 2016 11:41:25 -0700 (PDT) Received: by mail-qt0-f195.google.com with SMTP id c52so4488576qte.1 for ; Sun, 28 Aug 2016 11:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=bIBgh1LxG1a8cl9/JzXDDr9u4Xdx4j5nhKGowb748I0=; b=CwBzuS+cgnqjqatvmnlyN2e9ou5QP1ghKeApVPZYZVxUSxvqEKegNk6YcgvUqa/wvM ZhK7z0dQzLIPNZkUxs9X0eHNUNNviqIIGXrBg1Qi0uwujXvgCzPdd7OAlHy9MRoA4nw6 hEPKQOfspJjAWujE0Fdqj626fu93O5XjZx/S8JNHd1NuvFhsBQTyYHlyt8oJWiBQ4sL2 0FaPqCmM1WY1sYOc1w28+2GEiG1nZD2uHcc+6+6/5Cn2jMaSZp/omVEAIfCceTot43jw z1hsugCT2yxqPPZW2fU4ktSXMovYOoV+QBXBGG/tomleO9xZ+QLTfF0D+GPlOjrGtmpv UbZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=bIBgh1LxG1a8cl9/JzXDDr9u4Xdx4j5nhKGowb748I0=; b=eBg8VpsKUVwun3OlfEQwAQr/dPaVWSEnXmkg+ZjDyMqtKDokhEz0ZwNvjzsk8KuTCJ abbM/ULeJoEsdUe53ltNXQ+zve0rNQVBjDq6m9gaQn5IoyYIqAK1frnpeewSVI1bb1Mk Ql0tkjeW6Ny+kQSWnEC5211M289XoUXDjMcxBhaq4xM2QeCPf8/6f4JqXaeXXfyFio/Y FX/Cvh5TQb4jUQX9iQWxnGaRn0EfWax7fnur68Kesk1VPdRiyDKSGeZTmfxVl/erNkOU B/P442Ttqp73zbUvKFCChMVX6spu4YUZcWUl/fCjF9rTgAts0CR/uBpQhsBBNv2Yu7lr y7iQ== X-Gm-Message-State: AE9vXwNE5RiJZOKxz2z7zJjVO9j10DWgCZgMQobfxHCIAaceip1EDALtzHv6KpOe66F84A== X-Received: by 10.200.35.108 with SMTP id b41mr14717056qtb.142.1472409683960; Sun, 28 Aug 2016 11:41:23 -0700 (PDT) Received: from localhost (c-24-218-80-235.hsd1.ma.comcast.net. [24.218.80.235]) by smtp.gmail.com with ESMTPSA id 21sm13134643qkg.43.2016.08.28.11.41.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Aug 2016 11:41:23 -0700 (PDT) Sender: - From: Steven Allen To: notmuch@notmuchmail.org Subject: [PATCH] emacs: use define-derived-mode for defining modes. Date: Sun, 28 Aug 2016 14:41:22 -0400 Message-Id: <20160828184122.26002-1-steven@stebalien.com> X-Mailer: git-send-email 2.9.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2016 18:41:26 -0000 This sets up and runs all the correct hooks and reduces some redundancy. --- 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