[PATCH 1/1] emacs: Take more care when hiding regions with buttons.
Dmitry Kurochkin
dmitry.kurochkin at gmail.com
Wed Jan 25 07:10:35 PST 2012
On Wed, 25 Jan 2012 15:05:08 +0000, David Edmondson <dme at dme.org> wrote:
> If the region to be hidden with a button by
> `notmuch-wash-region-to-button' starts at the beginning of the buffer,
> the invisible region will include the inserted button. This is
> unfortunate, as it means that it is not possible to see the button to
> be pressed.
>
> Make a little space at the start of the buffer before inserting the
> button to avoid this, not forgetting to remove the inserted space upon
> completion.
> ---
>
> This is a hack, but I couldn't see another way around it. Can anyone
> find a better solution?
>
I think it would be much easier to understand the problem and probably
suggest a solution if there is a test :)
Regards,
Dmitry
> emacs/notmuch-wash.el | 57 ++++++++++++++++++++++++++++++++----------------
> 1 files changed, 38 insertions(+), 19 deletions(-)
>
> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> index 5c1e830..4afd3b3 100644
> --- a/emacs/notmuch-wash.el
> +++ b/emacs/notmuch-wash.el
> @@ -147,25 +147,44 @@ insert before the button, probably for indentation."
> ;; symbols because of the way the button code works. Note that
> ;; replacing intern-soft with make-symbol will cause this to fail,
> ;; since the newly created symbol has no plist.
> -
> - (let ((overlay (make-overlay beg end))
> - (message-invis-spec (plist-get msg :message-invis-spec))
> - (invis-spec (make-symbol (concat "notmuch-" type "-region")))
> - (button-type (intern-soft (concat "notmuch-wash-button-"
> - type "-toggle-type"))))
> - (add-to-invisibility-spec invis-spec)
> - (overlay-put overlay 'invisible (list invis-spec message-invis-spec))
> - (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show)
> - (overlay-put overlay 'priority 10)
> - (overlay-put overlay 'type type)
> - (goto-char (1+ end))
> - (save-excursion
> - (goto-char (1- beg))
> - (insert prefix)
> - (insert-button (notmuch-wash-button-label overlay)
> - 'invisibility-spec invis-spec
> - 'overlay overlay
> - :type button-type))))
> + (save-excursion
> + ;; If the beginning of the region to be converted to a button is the
> + ;; beginning of the buffer we must move forward a little to avoid
> + ;; creating an overlay that will hide the button intended to be used
> + ;; to reveal the hidden region.
> + (let (scene-of-crime)
> + (when (eq beg (point-min))
> + (goto-char (point-min))
> + (insert "\n")
> + (setq scene-of-crime (point-min)
> + beg (point)))
> +
> + ;; This uses some slightly tricky conversions between strings and
> + ;; symbols because of the way the button code works. Note that
> + ;; replacing intern-soft with make-symbol will cause this to fail,
> + ;; since the newly created symbol has no plist.
> +
> + (let ((overlay (make-overlay beg end))
> + (message-invis-spec (plist-get msg :message-invis-spec))
> + (invis-spec (make-symbol (concat "notmuch-" type "-region")))
> + (button-type (intern-soft (concat "notmuch-wash-button-"
> + type "-toggle-type"))))
> + (add-to-invisibility-spec invis-spec)
> + (overlay-put overlay 'invisible (list invis-spec message-invis-spec))
> + (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show)
> + (overlay-put overlay 'priority 10)
> + (overlay-put overlay 'type type)
> +
> + (goto-char (1- beg))
> + (insert prefix)
> + (insert-button (notmuch-wash-button-label overlay)
> + 'invisibility-spec invis-spec
> + 'overlay overlay
> + :type button-type))
> +
> + (when scene-of-crime
> + (goto-char scene-of-crime)
> + (delete-char 1)))))
>
> (defun notmuch-wash-excerpt-citations (msg depth)
> "Excerpt citations and up to one signature."
> --
> 1.7.8.3
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list