From f4a132cb1bef4839e18f9c58d3640829b7998acb Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Thu, 14 Nov 2013 09:49:46 +0000 Subject: [PATCH] [PATCH] emacs: add '?' to some prefix keymaps to describe its bindings --- 46/4b15b25293c29e96a1f0b4d3c0a45485d5c7c3 | 160 ++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 46/4b15b25293c29e96a1f0b4d3c0a45485d5c7c3 diff --git a/46/4b15b25293c29e96a1f0b4d3c0a45485d5c7c3 b/46/4b15b25293c29e96a1f0b4d3c0a45485d5c7c3 new file mode 100644 index 000000000..0e45dd1f0 --- /dev/null +++ b/46/4b15b25293c29e96a1f0b4d3c0a45485d5c7c3 @@ -0,0 +1,160 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1F02D431FC4 + for ; Thu, 14 Nov 2013 02:21:30 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 2H0qBRyZEEts for ; + Thu, 14 Nov 2013 02:21:20 -0800 (PST) +Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com + [74.125.82.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 666E5431FAE for ; Thu, 14 Nov 2013 02:21:20 -0800 + (PST) +Received: by mail-wg0-f46.google.com with SMTP id x12so1641073wgg.13 + for ; Thu, 14 Nov 2013 02:21:17 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id; + bh=nD2Uy2sOysb4jb+5AfLYvM+VkWx7i4BpQGc02u76mLM=; + b=gNaNF550oEsdErRiv66FY0w4fhldxGYYIv0/hEIVkrdrOJhbGS6XZP/eZDRgLPGnj3 + UWCDlT/6EHjfDOKCEnPdyXXncfM0eH0O0QiyVrglWESCT7w9BT/40oCVmXuGniSuFY8d + Jt45mkkOM/Wi0dZ7zeSYGE0jfd0S9+7F1Ai8hkT+cSAMglqQFUSRl0tzk8WN4vxWYpZX + ILTDyBBmObW9aSBWs33b94XlGHaVLKEQtz5XB8UluaFcFbPQFKpFFo5CifCpi7EKsSDb + GiBlGw0xlvvWb5tN4agoPtOppiEYqd+NA125MGDD5rQldGLvRSAihOg0TBTY3Wezx3kc + iTaw== +X-Received: by 10.180.39.140 with SMTP id p12mr1483981wik.12.1384422590582; + Thu, 14 Nov 2013 01:49:50 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id hv5sm63991736wib.2.2013.11.14.01.49.49 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Thu, 14 Nov 2013 01:49:50 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: add '?' to some prefix keymaps to describe its + bindings +Date: Thu, 14 Nov 2013 09:49:46 +0000 +Message-Id: <1384422586-21806-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Thu, 14 Nov 2013 10:21:30 -0000 + +Added function notmuch-subkeymap-help to describe keybindings of a +subkeymap (eg after . or c in notmuch-search and notmuch-show). +--- +This a reimplementation of Tomi's patch at +id:1377346540-7094-1-git-send-email-tomi.ollila@iki.fi but the help +screen shows docstrings rather than function names. + +Best wishes + +Mark + + + + + + emacs/notmuch-lib.el | 25 ++++++++++++++++++++++++- + emacs/notmuch-show.el | 2 ++ + emacs/notmuch.el | 1 + + 3 files changed, 27 insertions(+), 1 deletions(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 49fe644..2be409b 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -231,7 +231,8 @@ depending on the value of `notmuch-poll-script'." + "Given a prefix key code, return a human-readable string representation. + + This is basically just `format-kbd-macro' but we also convert ESC to M-." +- (let ((desc (format-kbd-macro (vector key)))) ++ (let* ((key-vector (if (vectorp key) key (vector key))) ++ (desc (format-kbd-macro key-vector))) + (if (string= desc "ESC") + "M-" + (concat desc " ")))) +@@ -337,6 +338,28 @@ of its command symbol." + (set-buffer-modified-p nil) + (view-buffer (current-buffer) 'kill-buffer-if-not-modified)))) + ++(defun notmuch-subkeymap-help () ++ "Show help for a subkeymap." ++ (interactive) ++ (let* ((key (this-command-keys-vector)) ++ (prefix (make-vector (1- (length key)) nil)) ++ (i 0)) ++ (while (< i (length prefix)) ++ (aset prefix i (aref key i)) ++ (setq i (1+ i))) ++ ++ (let* ((subkeymap (key-binding prefix)) ++ (ua-keys (where-is-internal 'universal-argument nil t)) ++ (prefix-string (notmuch-prefix-key-description prefix)) ++ (desc-alist (notmuch-describe-keymap subkeymap ua-keys subkeymap prefix-string)) ++ (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist)) ++ (desc (mapconcat #'identity desc-list "\n"))) ++ (with-help-window (help-buffer) ++ (with-current-buffer standard-output ++ (insert "\nPress 'q' to quit this window.\n\n") ++ (insert desc))) ++ (pop-to-buffer (help-buffer))))) ++ + (defvar notmuch-buffer-refresh-function nil + "Function to call to refresh the current buffer.") + (make-variable-buffer-local 'notmuch-buffer-refresh-function) +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index f00273a..45dca8b 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1232,6 +1232,7 @@ reset based on the original query." + (define-key map "t" 'notmuch-show-stash-to) + (define-key map "l" 'notmuch-show-stash-mlarchive-link) + (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) ++ (define-key map "?" 'notmuch-subkeymap-help) + map) + "Submap for stash commands") + (fset 'notmuch-show-stash-map notmuch-show-stash-map) +@@ -1242,6 +1243,7 @@ reset based on the original query." + (define-key map "v" 'notmuch-show-view-part) + (define-key map "o" 'notmuch-show-interactively-view-part) + (define-key map "|" 'notmuch-show-pipe-part) ++ (define-key map "?" 'notmuch-subkeymap-help) + map) + "Submap for part commands") + (fset 'notmuch-show-part-map notmuch-show-part-map) +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index c9bc2f2..0471750 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -165,6 +165,7 @@ To enter a line break in customize, press \\[quoted-insert] C-j." + (defvar notmuch-search-stash-map + (let ((map (make-sparse-keymap))) + (define-key map "i" 'notmuch-search-stash-thread-id) ++ (define-key map "?" 'notmuch-subkeymap-help) + map) + "Submap for stash commands") + (fset 'notmuch-search-stash-map notmuch-search-stash-map) +-- +1.7.9.1 + -- 2.26.2