From: Austin Clements Date: Tue, 12 Nov 2013 18:47:36 +0000 (+1900) Subject: Re: [PATCH] emacs: help: bugfix X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3b1637179cb673bc632f033f282f20f754ff8c02;p=notmuch-archives.git Re: [PATCH] emacs: help: bugfix --- diff --git a/76/9d0a723267f76b652f23a02cd4222eacb905b9 b/76/9d0a723267f76b652f23a02cd4222eacb905b9 new file mode 100644 index 000000000..5d0fb78b1 --- /dev/null +++ b/76/9d0a723267f76b652f23a02cd4222eacb905b9 @@ -0,0 +1,154 @@ +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 21471431FDA + for ; Tue, 12 Nov 2013 10:47:48 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 DZKuwQO-pI7G for ; + Tue, 12 Nov 2013 10:47:40 -0800 (PST) +Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu + [18.9.25.15]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B8B3D431FD7 + for ; Tue, 12 Nov 2013 10:47:40 -0800 (PST) +X-AuditID: 1209190f-b7fb86d000000c36-a4-528277cb4b1f +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id E5.D1.03126.BC772825; Tue, 12 Nov 2013 13:47:39 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id rACIlc23022817; + Tue, 12 Nov 2013 13:47:39 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id rACIla9U013398 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Tue, 12 Nov 2013 13:47:37 -0500 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1VgIzw-0005jL-7h; Tue, 12 Nov 2013 13:47:36 -0500 +From: Austin Clements +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs: help: bugfix +In-Reply-To: <1384076682-16872-1-git-send-email-markwalters1009@gmail.com> +References: <1383932419-12533-1-git-send-email-markwalters1009@gmail.com> + <1384076682-16872-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.16+154~g96c0ce2 (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Tue, 12 Nov 2013 13:47:36 -0500 +Message-ID: <87ppq54fuf.fsf@awakening.csail.mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsUixCmqrXu6vCnIYN9KK4vVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZZx81chU8EGiYv4v1wbGJ8JdjJwcEgImEgs/ + f2CEsMUkLtxbz9bFyMUhJDCbSWLOzbPsEM5GRol5R99DOaeZJM6tWswM4SxhlNhy9g8rSD+b + gIbEtv3LwWaJCLhKPP32mRnEFgaKH9l6lAnE5hTwknhyew4rRHM7o8SqA4/YQBKiAvES0xbu + BGrg4GARUJVYeEYMJMwLdN/PCc3sELagxMmZT1hAbGYBLYkb/14yTWAUmIUkNQtJagEj0ypG + 2ZTcKt3cxMyc4tRk3eLkxLy81CJdE73czBK91JTSTYzggJTk38H47aDSIUYBDkYlHt4HkU1B + QqyJZcWVuYcYJTmYlER5VYuBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR43WKAcrwpiZVVqUX5 + MClpDhYlcd6bHPZBQgLpiSWp2ampBalFMFkZDg4lCV52kKGCRanpqRVpmTklCGkmDk6Q4TxA + w5VAaniLCxJzizPTIfKnGBWlxHkvFQElBEASGaV5cL2whPGKURzoFWHevyBVPMBkA9f9Cmgw + E9DgJXcbQQaXJCKkpBoYLZZNTtv95pSVNLvoHc6LKrm7Tbo3zZT4FfmWa4uX9s/sWRNVT7E7 + //S3vKo0rT1ALnnp0UnCAksSph0xcJRdO8G2pf504Y4aBheJczpOzzcaaWs+a4uftP6ErI33 + mpZHl0x/fYng4nwhKejOx6Wn1TadaeG6Deu/PfVLrr91VGzpvWNxbuUtSizFGYmGWsxFxYkA + 5/rlTfMCAAA= +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: Tue, 12 Nov 2013 18:47:48 -0000 + +On Sun, 10 Nov 2013, Mark Walters wrote: +> Hi +> +> David found a bug in the this remap/help series. He has a global +> keybinding of "C-c s" for notmuch-search and this causes help in +> tree-mode to hang. +> +> I have mostly diagnosed this: the problem comes that all the construct +> help routines are inside a string-match/replace-match pair. Somewhere +> in these routines the match-data is being stomped on (but I have to +> admit I am not sure where). +> +> In any case putting the construct help routines inside a +> save-match-data seems to fix it. +> +> This version is a bit ugly: I am not sure of the best way to deal with +> the save-match-data macro. (I think it is best to have it round +> everything that happens between finding the match and replacing the +> match to avoid anything similar in future). +> +> This applies on top of the parent series. +> +> Any comments gratefully received! +> +> Best wishes +> +> Mark +> +> --- +> emacs/notmuch-lib.el | 17 ++++++++++------- +> 1 files changed, 10 insertions(+), 7 deletions(-) +> +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index 7b8acb3..e98e073 100644 +> --- a/emacs/notmuch-lib.el +> +++ b/emacs/notmuch-lib.el +> @@ -305,13 +305,16 @@ prefix argument. PREFIX and TAIL are used internally." +> (defun notmuch-substitute-command-keys (doc) +> "Like `substitute-command-keys' but with documentation, not function names." +> (let ((beg 0)) +> - (while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg) +> - (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 keymap)) +> - (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist)) +> - (desc (mapconcat #'identity desc-list "\n"))) +> + (while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg) ;; matches \{not-space} +> + (let ((desc +> + (save-match-data +> + (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 keymap)) +> + (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist)) +> + (desc (mapconcat #'identity desc-list "\n"))) +> + desc)))) + +Oof, what an annoying place to lose the match data. My one suggestion +would be to put (mapconcat #'identity desc-list "\n") as the body of the +inner let, rather than binding `desc' and then immediately evaluating to +`desc'. That would remove some redundancy, and it's already clear from +the outer let that the result of the mapconcat is named `desc'. + +> (setq doc (replace-match desc 1 1 doc))) +> (setq beg (match-end 0))) +> doc)) +> -- +> 1.7.9.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch