From: Mark Walters Date: Tue, 12 Nov 2013 20:10:54 +0000 (+0000) Subject: [PATCH v4 2/7] emacs: help: save-match-data X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e0bd1bd794e92cba81db1f3a4b6d9579f43d16b6;p=notmuch-archives.git [PATCH v4 2/7] emacs: help: save-match-data --- diff --git a/2a/726ef641a9901e1124a9bbc941d02538317243 b/2a/726ef641a9901e1124a9bbc941d02538317243 new file mode 100644 index 000000000..53fd3ae7a --- /dev/null +++ b/2a/726ef641a9901e1124a9bbc941d02538317243 @@ -0,0 +1,98 @@ +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 E6F1A431FD7 + for ; Tue, 12 Nov 2013 13:09:21 -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 iOdVf57jraqu for ; + Tue, 12 Nov 2013 13:09:14 -0800 (PST) +Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com + [74.125.82.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 3AB81431FCF for ; Tue, 12 Nov 2013 13:09:14 -0800 + (PST) +Received: by mail-wg0-f49.google.com with SMTP id x13so2605807wgg.4 + for ; Tue, 12 Nov 2013 13:09:13 -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:in-reply-to:references; + bh=+NeEEIgUeu4WjHSxL8tkh5julgWpcSqKo+LYSv+rm84=; + b=qLmUfddh8ee9LkL/fqo3cGE5YuJOGDb7f+guTy7OxPtsV6ZxulYzMfvXj+3nWPF4iv + 3v08/Pu8AKCxj/fyQH4aIl4yKqILY161zhmQn/GaG4P0vySnw+D5qlXDBGEjnwKJIye3 + ljZXVnamFGs6km40KC+3Oh4KF/lGsLEDVhjBr86cSxs9q65d/qa0Nu5fIHqTpGJ/fYAg + MbiHeJuNFJOSWJtEZPuYyrneW543SWKR8G0ZZ+laxmi7TTLdBKmKx3EtRt1fCEMOq5ah + MJGrN3lT3nxbpN1xuUuf6z8MrIA5wa1CXvgB9Q2wVW5MWjC7NKaX4UhKHP/9j+Pr0Vak + O2eg== +X-Received: by 10.180.20.13 with SMTP id j13mr17563452wie.8.1384287068405; + Tue, 12 Nov 2013 12:11:08 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id + c10sm48157218wie.11.2013.11.12.12.11.07 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 12 Nov 2013 12:11:08 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v4 2/7] emacs: help: save-match-data +Date: Tue, 12 Nov 2013 20:10:54 +0000 +Message-Id: <1384287059-3525-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1384287059-3525-1-git-send-email-markwalters1009@gmail.com> +References: <1384287059-3525-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: Tue, 12 Nov 2013 21:09:22 -0000 + +The routines that construct the help page in notmuch-lib rely on +match-data being preserved across some fairly complicated code. This +is currently valid but will not be when this series is finished. Thus +place everything between the string-match and replace-match inside a +save-match-data. +--- + emacs/notmuch-lib.el | 12 +++++++----- + 1 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 5e734b3..6abc4ea 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -274,11 +274,13 @@ prefix argument. PREFIX and TAIL are used internally." + "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-list (notmuch-describe-keymap keymap ua-keys)) +- (desc (mapconcat #'identity desc-list "\n"))) ++ (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-list (notmuch-describe-keymap keymap ua-keys))) ++ (mapconcat #'identity desc-list "\n"))))) + (setq doc (replace-match desc 1 1 doc))) + (setq beg (match-end 0))) + doc)) +-- +1.7.9.1 +