Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 25 / d3246bda50785cc63ad660fe07364c739bf5f8
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id EBB15431FAF\r
6         for <notmuch@notmuchmail.org>; Mon,  7 Jan 2013 13:07:53 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id ZPKN8Vq8ZXE3 for <notmuch@notmuchmail.org>;\r
18         Mon,  7 Jan 2013 13:07:53 -0800 (PST)\r
19 Received: from mail-we0-f169.google.com (mail-we0-f169.google.com\r
20         [74.125.82.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 16C8B431FAE\r
23         for <notmuch@notmuchmail.org>; Mon,  7 Jan 2013 13:07:52 -0800 (PST)\r
24 Received: by mail-we0-f169.google.com with SMTP id t49so10749696wey.0\r
25         for <notmuch@notmuchmail.org>; Mon, 07 Jan 2013 13:07:51 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
28         :references; bh=MU+UfucF2Eb5RQAEcssOyEUqlKpovFtQgmZgC1Jin0s=;\r
29         b=BfGBZrIy15xiruJ/fEClF06hQp7trCQhtwxzqfQZBDWueFKj6Sb+pCUmvjLKVRajqY\r
30         2LHHhBG0K/NTcK1Y0uFEU2VmUXgJTZ1WOnjbF5VjixSJPLqRDXidywrlFb8F2YRDecYK\r
31         tmRTr6x7OMYjStRiLdNsvdxZORaC9sKjkl+I8DDE/FY8Fcb/ewHedHfFhg+SMFWmZaxv\r
32         EAViikgZ0lDx1Ud9sua5tVDCU449cnjZjxS9ImV5mdxNkL+TcaF++x+3HkYL6+G8a75d\r
33         XK6l19GYSxXp30KxQ0JFurowCQrJfGNJBLczQwMO3PvcwBr9wAhjbC2KdzVj+FNWkTtx\r
34         Ld0A==\r
35 X-Received: by 10.194.77.13 with SMTP id o13mr98163019wjw.58.1357592871846;\r
36         Mon, 07 Jan 2013 13:07:51 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id dm3sm13815777wib.9.2013.01.07.13.07.50\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Mon, 07 Jan 2013 13:07:50 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2] emacs: show: make buttons select window\r
44 Date: Mon,  7 Jan 2013 21:07:20 +0000\r
45 Message-Id: <1357592840-31155-1-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <20130107202221.GL17581@mit.edu>\r
48 References: <20130107202221.GL17581@mit.edu>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Mon, 07 Jan 2013 21:07:54 -0000\r
62 \r
63 Emacs has two button type objects: widgets (as used for saved searches\r
64 in notmuch-hello) and buttons as used by parts/citations and id links\r
65 in notmuch-show. These two behave subtly differently when clicked with\r
66 the mouse: widgets select the window clicked before running the\r
67 action, buttons do not.\r
68 \r
69 This patch makes all of these behave the same: clicking always selects\r
70 the clicked window. It does this by defining a notmuch-button-type\r
71 supertype that the other notmuch buttons can inherit from. This\r
72 supertype binds the mouse-action to select the window and then\r
73 activate the button.\r
74 ---\r
75 \r
76 This versions fixes most of the comments raised by Austin's review.\r
77 The one change I didn't make was changing :supertype to 'supertype. In\r
78 principle I agree with Austin but the : form is used for inheritance\r
79 for other notmuch buttons in wash and crypto.\r
80 \r
81 Best wishes\r
82 \r
83 Mark\r
84 \r
85 \r
86 \r
87 \r
88  emacs/notmuch-crypto.el |    5 ++++-\r
89  emacs/notmuch-lib.el    |   15 +++++++++++++++\r
90  emacs/notmuch-show.el   |    4 +++-\r
91  emacs/notmuch-wash.el   |    3 ++-\r
92  4 files changed, 24 insertions(+), 3 deletions(-)\r
93 \r
94 diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el\r
95 index 83e5d37..5233824 100644\r
96 --- a/emacs/notmuch-crypto.el\r
97 +++ b/emacs/notmuch-crypto.el\r
98 @@ -19,6 +19,8 @@\r
99  ;;\r
100  ;; Authors: Jameson Rollins <jrollins@finestructure.net>\r
101  \r
102 +(require 'notmuch-lib)\r
103 +\r
104  (defcustom notmuch-crypto-process-mime nil\r
105    "Should cryptographic MIME parts be processed?\r
106  \r
107 @@ -76,7 +78,8 @@ mode."\r
108  (define-button-type 'notmuch-crypto-status-button-type\r
109    'action (lambda (button) (message (button-get button 'help-echo)))\r
110    'follow-link t\r
111 -  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")\r
112 +  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."\r
113 +  :supertype 'notmuch-button-type)\r
114  \r
115  (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)\r
116    (let* ((status (plist-get sigstatus :status))\r
117 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
118 index 0407f8a..6836192 100644\r
119 --- a/emacs/notmuch-lib.el\r
120 +++ b/emacs/notmuch-lib.el\r
121 @@ -97,6 +97,21 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
122    :group 'notmuch-search\r
123    :group 'notmuch-show)\r
124  \r
125 +;; By default clicking on a button does not select the window\r
126 +;; containing the button (as opposed to clicking on a widget which\r
127 +;; does). This means that the button action is then executed in the\r
128 +;; current selected window which can cause problems if the button\r
129 +;; changes the buffer (e.g., id: links) or moves point.\r
130 +;;\r
131 +;; This provides a button type which overrides mouse-action so that\r
132 +;; the button's window is selected before the action is run. Other\r
133 +;; notmuch buttons can get the same behaviour by inheriting from this\r
134 +;; button type.\r
135 +(define-button-type 'notmuch-button-type\r
136 +  'mouse-action (lambda (button)\r
137 +                 (select-window (posn-window (event-start last-input-event)))\r
138 +                 (button-activate button)))\r
139 +\r
140  (defun notmuch-version ()\r
141    "Return a string with the notmuch version number."\r
142    (let ((long-string\r
143 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
144 index 5751d98..059194d 100644\r
145 --- a/emacs/notmuch-show.el\r
146 +++ b/emacs/notmuch-show.el\r
147 @@ -469,7 +469,8 @@ message at DEPTH in the current thread."\r
148    'action 'notmuch-show-part-button-default\r
149    'keymap 'notmuch-show-part-button-map\r
150    'follow-link t\r
151 -  'face 'message-mml)\r
152 +  'face 'message-mml\r
153 +  :supertype 'notmuch-button-type)\r
154  \r
155  (defvar notmuch-show-part-button-map\r
156    (let ((map (make-sparse-keymap)))\r
157 @@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search."\r
158         ;; Remove the overlay created by goto-address-mode\r
159         (remove-overlays (first link) (second link) 'goto-address t)\r
160         (make-text-button (first link) (second link)\r
161 +                         :type 'notmuch-button-type\r
162                           'action `(lambda (arg)\r
163                                      (notmuch-show ,(third link)))\r
164                           'follow-link t\r
165 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
166 index d6db4fa..826b6f4 100644\r
167 --- a/emacs/notmuch-wash.el\r
168 +++ b/emacs/notmuch-wash.el\r
169 @@ -115,7 +115,8 @@ lower).")\r
170  (define-button-type 'notmuch-wash-button-invisibility-toggle-type\r
171    'action 'notmuch-wash-toggle-invisible-action\r
172    'follow-link t\r
173 -  'face 'font-lock-comment-face)\r
174 +  'face 'font-lock-comment-face\r
175 +  :supertype 'notmuch-button-type)\r
176  \r
177  (define-button-type 'notmuch-wash-button-citation-toggle-type\r
178    'help-echo "mouse-1, RET: Show citation"\r
179 -- \r
180 1.7.9.1\r
181 \r