From ad22c71b1226c944641036c2282bbaa18d3daa63 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 8 Nov 2013 17:40:12 +0000 Subject: [PATCH] [PATCH v3 0/7] emacs: help: remap keybindings --- b0/83d52c3144d328049ea29d4c791dc834af3ac5 | 159 ++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 b0/83d52c3144d328049ea29d4c791dc834af3ac5 diff --git a/b0/83d52c3144d328049ea29d4c791dc834af3ac5 b/b0/83d52c3144d328049ea29d4c791dc834af3ac5 new file mode 100644 index 000000000..64b6cd4ed --- /dev/null +++ b/b0/83d52c3144d328049ea29d4c791dc834af3ac5 @@ -0,0 +1,159 @@ +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 09232429E39 + for ; Fri, 8 Nov 2013 09:40:40 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.7 +X-Spam-Level: ** +X-Spam-Status: No, score=2.7 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, + FREEMAIL_REPLY=2.499, 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 d7fTxdfY68Ww for ; + Fri, 8 Nov 2013 09:40:34 -0800 (PST) +Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com + [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 23B93431FDE for ; Fri, 8 Nov 2013 09:40:28 -0800 + (PST) +Received: by mail-wg0-f47.google.com with SMTP id c11so2276874wgh.14 + for ; Fri, 08 Nov 2013 09:40:25 -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=1moXW+By+9yTflAVMIyRQPcFePHEFWoqOhhDXYUo9Ek=; + b=059QzF9J1KjmFpWRrHfdtT9whjZnR7l7LacWLBykYppltVCIODzFiCsp34W6V9baxD + Df1/KchxlOqTPfnrZmkgt8j1buQQGud+H56uJpf1nTkT0Y8skewiwPfIlIyaQU5gMCci + RxUlj0KOQZmxofmUk66yv3BDs4I+OsTGZD79GSZ+kFKFjUwAy7+pxgdcOMXH4ZDzrI3/ + 0W5bcM8n4t7tqNaa9YLZrJPP+B353EVQMzFtrps+5MVRLx2NZiVJD19oVuN650XyeR2h + pJqa5+0cGpDWCg7JPMMS7YAXomiQpVlPZI71Ihhi+0VwEO25MZeQj6J4h30wy3WV1I7K + G/Aw== +X-Received: by 10.180.94.38 with SMTP id cz6mr3255559wib.27.1383932423260; + Fri, 08 Nov 2013 09:40:23 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id td6sm7508300wic.10.2013.11.08.09.40.22 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Fri, 08 Nov 2013 09:40:22 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v3 0/7] emacs: help: remap keybindings +Date: Fri, 8 Nov 2013 17:40:12 +0000 +Message-Id: <1383932419-12533-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: Fri, 08 Nov 2013 17:40:40 -0000 + +This is version 3 of the series. v2 is at +id:1383870096-14627-1-git-send-email-markwalters1009@gmail.com + +The changes are in response to Austin's review of v2. I have not +changed notmuch-describe-key. + +The other change is to add a base-keymap to look up the remapped +commands in (since notmuch-substitute-command-keys could refer to +something other than the current keymap). Currently this never happens +but this makes the code more robust. + +The final patch of the series is (probably) just for testing +purposes. It lets you call notmuch-help and specify which mode you +want to display help for. This means you can call it without having +the mode as current-mode and hence test the base-keymap code. + +Finally the diff from v2 below (with the testing patch omitted) is below. + +Best wishes + +Mark + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index ef616d5..4b3a86e 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in TAIL." + tail))) + tail) + +-(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail) ++(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail) + ;; Remappings are represented as a binding whose first "event" is + ;; 'remap. Hence, if the keymap has any remappings, it will have a + ;; binding whose "key" is 'remap, and whose "binding" is itself a +@@ -272,11 +272,11 @@ It does not prepend if ACTUAL-KEY is already listed in TAIL." + (mapc + (lambda (actual-key) + (setq tail (notmuch-describe-key actual-key binding prefix ua-keys tail))) +- (where-is-internal command))) ++ (where-is-internal command base-keymap))) + remap-keymap) + tail) + +-(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail) ++(defun notmuch-describe-keymap (keymap ua-keys base-keymap &optional prefix tail) + "Return a list of cons cells, each describing one binding in KEYMAP. + + Each cons cell consists of a string giving a human-readable +@@ -291,13 +291,12 @@ prefix argument. PREFIX and TAIL are used internally." + (lambda (key binding) + (cond ((mouse-event-p key) nil) + ((keymapp binding) +- (if (eq key 'remap) +- (setq tail ++ (setq tail ++ (if (eq key 'remap) + (notmuch-describe-remaps +- binding ua-keys prefix tail)) +- (setq tail ++ binding ua-keys base-keymap prefix tail) + (notmuch-describe-keymap +- binding ua-keys (notmuch-prefix-key-description key) tail)))) ++ binding ua-keys base-keymap (notmuch-prefix-key-description key) tail)))) + (binding + (setq tail (notmuch-describe-key (vector key) binding prefix ua-keys tail))))) + keymap) +@@ -310,7 +309,7 @@ prefix argument. PREFIX and TAIL are used internally." + (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1))) + (keymap (symbol-value (intern keymap-name))) + (ua-keys (where-is-internal 'universal-argument keymap t)) +- (desc-alist (notmuch-describe-keymap keymap ua-keys)) ++ (desc-alist (notmuch-describe-keymap keymap ua-keys keymap)) + (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist)) + (desc (mapconcat #'identity desc-list "\n"))) + (setq doc (replace-match desc 1 1 doc))) + + + +Mark Walters (7): + emacs: help: check for nil key binding + emacs: help: remove duplicate bindings + emacs: help: split out notmuch-describe-key as a function + emacs: help: add base-keymap + emacs: help: add a special function to deal with remaps + emacs: tree: use remap for the over-ridden global bindings + emacs: help: base-keymap-test-help + + emacs/notmuch-lib.el | 79 ++++++++++++++++++++++++++++++++++-------------- + emacs/notmuch-tree.el | 8 ++-- + 2 files changed, 60 insertions(+), 27 deletions(-) + + + + +-- +1.7.9.1 + -- 2.26.2