From c37a53f43447bd2580697ac939e352a0a94a5798 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 26 Oct 2013 22:04:38 +0100 Subject: [PATCH] [PATCH 3/4] emacs: help: remap support --- 2c/c6d73e5ffb9ce68ff1e5a85d8a9a732ee1bf9a | 124 ++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 2c/c6d73e5ffb9ce68ff1e5a85d8a9a732ee1bf9a diff --git a/2c/c6d73e5ffb9ce68ff1e5a85d8a9a732ee1bf9a b/2c/c6d73e5ffb9ce68ff1e5a85d8a9a732ee1bf9a new file mode 100644 index 000000000..20612aca1 --- /dev/null +++ b/2c/c6d73e5ffb9ce68ff1e5a85d8a9a732ee1bf9a @@ -0,0 +1,124 @@ +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 0AC34429E47 + for ; Sat, 26 Oct 2013 14:04:59 -0700 (PDT) +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 2Ueqlnf5q7DZ for ; + Sat, 26 Oct 2013 14:04:54 -0700 (PDT) +Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com + [209.85.212.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 5034E429E4B + for ; Sat, 26 Oct 2013 14:04:49 -0700 (PDT) +Received: by mail-wi0-f182.google.com with SMTP id ez12so2482775wid.3 + for ; Sat, 26 Oct 2013 14:04:48 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=nPY1vstdys9cQ2wFwQ6SmXBiVMe7Zc1+BfN5Iy4s74g=; + b=po3xijRtHzVECOgYTIWH8DRadD+4vX+ovjMj4i/czFofP2AJdrqbEmXzOc0bCMhP+8 + FAbpvA2rK3/fwWwH70SejE0uvjmSqQY1W6FjjNTk/v4SBqGHk5+xZjeBR4jcQyYz+fb5 + WRMX1laObTWKfgq9716Gyig3M3/HFWdYJVuJSnoOMPNDq1jzgW5ZYp/bJ3njq7uzcy2Z + yPU69dzg02O6yGyu46RenbEbuWe5oGXwoYcv4vGXXfrwYfCCnGsxjEjzXyLQeAldttCp + eew84FsGbWi3wfyV3INr6BDEmCVSxPpqBn9QryvnVWvW2YwEkykD+4d44HVB/+K3PtQq + jzqA== +X-Received: by 10.194.239.40 with SMTP id vp8mr12583449wjc.45.1382821488193; + Sat, 26 Oct 2013 14:04:48 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id + ey4sm19610558wic.11.2013.10.26.14.04.47 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 26 Oct 2013 14:04:47 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 3/4] emacs: help: remap support +Date: Sat, 26 Oct 2013 22:04:38 +0100 +Message-Id: <1382821479-23384-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1382821479-23384-1-git-send-email-markwalters1009@gmail.com> +References: <1382821479-23384-1-git-send-email-markwalters1009@gmail.com> +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: Sat, 26 Oct 2013 21:04:59 -0000 + +If a user or mode uses remap to rebind a keybinding then it appears in +the help as a line New function docstring. Special +case these remapping lines so that we print the actual binding. +--- + emacs/notmuch.el | 21 ++++++++++++++------- + 1 files changed, 14 insertions(+), 7 deletions(-) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index b9db9ba..c354b05 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -140,7 +140,7 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-." + "M-" + (concat desc " ")))) + +-(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail) ++(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail remap) + "Return a list of cons cells, each describing one binding in KEYMAP. + + Each cons cell consists of a string giving a human-readable +@@ -150,16 +150,23 @@ documentation is extracted. + + UA-KEYS should be a key sequence bound to `universal-argument'. + It will be used to describe bindings of commands that support a +-prefix argument. PREFIX and TAIL are used internally." ++prefix argument. PREFIX, TAIL and REMAP are used internally." + (map-keymap + (lambda (key binding) + (cond ((mouse-event-p key) nil) + ((keymapp binding) +- (setq tail +- (notmuch-describe-keymap +- binding ua-keys (notmuch-prefix-key-description key) tail))) ++ (if (equal key 'remap) ++ (setq tail ++ (notmuch-describe-keymap ++ binding ua-keys prefix tail t)) ++ (setq tail ++ (notmuch-describe-keymap ++ binding ua-keys (notmuch-prefix-key-description key) tail)))) + (t +- (let ((key-string (concat prefix (format-kbd-macro (vector key))))) ++ (let* ((actual-key (if remap ++ (where-is-internal key nil t) ++ (vector key))) ++ (key-string (concat prefix (format-kbd-macro actual-key)))) + ;; We don't include documentation if the key-binding is + ;; over-ridden. Note, over-riding a binding + ;; automatically hides the prefixed version too. +@@ -168,7 +175,7 @@ prefix argument. PREFIX and TAIL are used internally." + (get binding 'notmuch-prefix-doc)) + ;; Documentation for prefixed command + (let ((ua-desc (key-description ua-keys))) +- (push (cons (concat ua-desc " " prefix (format-kbd-macro (vector key))) ++ (push (cons (concat ua-desc " " prefix (format-kbd-macro actual-key)) + (get binding 'notmuch-prefix-doc)) + tail))) + ;; Documentation for command +-- +1.7.9.1 + -- 2.26.2