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 DFE00431FC3 for ; Mon, 23 Nov 2009 23:45:22 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 WlQzG8XU5rFM for ; Mon, 23 Nov 2009 23:45:22 -0800 (PST) Received: from mail-gx0-f225.google.com (mail-gx0-f225.google.com [209.85.217.225]) by olra.theworths.org (Postfix) with ESMTP id 70F79431FC0 for ; Mon, 23 Nov 2009 23:45:22 -0800 (PST) Received: by gxk25 with SMTP id 25so5944187gxk.0 for ; Mon, 23 Nov 2009 23:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=qRfrCGP55+BJ1M1Sx581PzEMIxdwfn+dqhSOrNP4Ixw=; b=ZAmfXFEoBuek50laFlZ1iR724VUc4HRuyhjDVSMZKwfUArGC9N+keyF44Z7mPIMz55 gq3k9KNP2+V33ZZojFDRSRcqczxD0pQNrGtwdzOIT0HyxSVbIkd38i9mOtBgcE0msRTd QAOYuLxnyXlUjoRQusGpDAbJn7SJhZR84a7n4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=slhXuxTbkhxh1e6oZlwzed52Dl97FY09IF40TcKJKlyEyMO54hBNEuotm7ZMBjOPz4 QbH7AhGu7TE71HzCg1+zKkmFUZK2TPfcwjd6kFEow68LvrdTNncreiTnLWk0fnRd6Ko7 S6ESoMxr2T2kdHmQyyWjGnAvld4rQrxAnIMww= Received: by 10.150.3.14 with SMTP id 14mr5802306ybc.228.1259048722072; Mon, 23 Nov 2009 23:45:22 -0800 (PST) Received: from fortitudo (70-36-144-85.dsl.dynamic.sonic.net [70.36.144.85]) by mx.google.com with ESMTPS id 13sm2537484gxk.13.2009.11.23.23.45.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 23 Nov 2009 23:45:21 -0800 (PST) Received: from alexbl (uid 1001) (envelope-from alexbl@fortitudo) id 7059 by fortitudo (DragonFly Mail Agent) Mon, 23 Nov 2009 23:45:25 -0800 From: Alexander Botero-Lowry To: notmuch@notmuchmail.org Date: Mon, 23 Nov 2009 23:45:05 -0800 Message-Id: <1259048707-3062-3-git-send-email-alex.boterolowry@gmail.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1259048707-3062-2-git-send-email-alex.boterolowry@gmail.com> References: <1259048707-3062-1-git-send-email-alex.boterolowry@gmail.com> <1259048707-3062-2-git-send-email-alex.boterolowry@gmail.com> Subject: [notmuch] [PATCH 3/5] make a nice function for generating invisibility toggle buttons X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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, 24 Nov 2009 07:45:23 -0000 I realized I was replicating this code over and over again, so this way if I change my mind about something I only have to do it on one place. --- notmuch.el | 45 ++++++++++++++++----------------------------- 1 files changed, 16 insertions(+), 29 deletions(-) diff --git a/notmuch.el b/notmuch.el index ed1f7cb..23a07cc 100644 --- a/notmuch.el +++ b/notmuch.el @@ -497,6 +497,13 @@ which this thread was originally shown." (force-window-update) (redisplay t)) +(defun notmuch-configure-invisibility-button (btn invis-spec help-msg) + (button-put btn 'invisibility-spec invis-spec) + (button-put btn 'action 'notmuch-toggle-invisible-action) + (button-put btn 'follow-link t) + (button-put btn 'help-echo (concat "mouse-1, RET: " help-msg)) +) + (defun notmuch-show-markup-citations-region (beg end depth) (goto-char beg) (beginning-of-line) @@ -512,22 +519,13 @@ which this thread was originally shown." (invis-spec (make-symbol "notmuch-citation-region"))) (add-to-invisibility-spec invis-spec) (overlay-put overlay 'invisible invis-spec) - (let ( - (p (point)) + (let ((p (point)) (cite-button-text (concat "[" (number-to-string (count-lines beg-sub (point))) - "-line citation.]")) - ) + "-line citation.]"))) (goto-char (- beg-sub 1)) (insert (concat "\n" indent)) - (let ((cite-button (insert-button cite-button-text))) - (button-put cite-button 'invisibility-spec invis-spec) - (button-put cite-button 'action 'notmuch-toggle-invisible-action) - (button-put cite-button 'follow-link t) - (button-put cite-button 'help-echo - "mouse-1, RET: Show citation") - - ) + (notmuch-configure-invisibility-button (insert-button cite-button-text) invis-spec "Show citation") (insert "\n") (goto-char (+ (length cite-button-text) p)) )))) @@ -543,16 +541,9 @@ which this thread was originally shown." (goto-char (- beg-sub 1)) (insert (concat "\n" indent)) - (let ((sig-button (insert-button - (concat "[" (number-to-string sig-lines) - "-line signature.]")))) - (button-put sig-button 'invisibility-spec invis-spec) - (button-put sig-button 'action - 'notmuch-toggle-invisible-action) - (button-put sig-button 'follow-link t) - (button-put sig-button 'help-echo - "mouse-1, RET: Show signature") - ) + (notmuch-configure-invisibility-button + (insert-button (concat "[" (number-to-string sig-lines) + "-line signature.]")) invis-spec "Show signature") (insert "\n") (goto-char end)))))) (forward-line)))) @@ -623,13 +614,9 @@ which this thread was originally shown." 'invisible invis-spec) (goto-char beg) (forward-line) - (let ((header-button (make-button (line-beginning-position) (line-end-position)))) - (button-put header-button 'invisibility-spec (cons invis-spec t)) - (button-put header-button 'action 'notmuch-toggle-invisible-action) - (button-put header-button 'follow-link t) - (button-put header-button 'help-echo - "mouse-1, RET: Show headers") - )) + (notmuch-configure-invisibility-button + (make-button (line-beginning-position) (line-end-position)) + (cons invis-spec t) "Show headers")) (goto-char end) (insert "\n") (set-marker beg nil) -- 1.6.5.2