unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH 4/4 v2] emacs: Take more care when hiding regions with buttons.
Date: Wed, 25 Jan 2012 21:53:54 +0400	[thread overview]
Message-ID: <87ipjzhdn1.fsf@gmail.com> (raw)
In-Reply-To: <1327506328-22126-5-git-send-email-dme@dme.org>

On Wed, 25 Jan 2012 15:45:28 +0000, David Edmondson <dme@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.
> 
> Mark the relevant test as no longer broken.
> ---

I will try to find some time to play with the test and look for
alternative solutions.

Regards,
  Dmitry

>  emacs/notmuch-wash.el                 |   57 ++++++++++++++++++++++-----------
>  test/emacs-original-message-hiding.sh |    1 -
>  2 files changed, 38 insertions(+), 20 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."
> diff --git a/test/emacs-original-message-hiding.sh b/test/emacs-original-message-hiding.sh
> index 01cf98d..038ef4f 100755
> --- a/test/emacs-original-message-hiding.sh
> +++ b/test/emacs-original-message-hiding.sh
> @@ -13,7 +13,6 @@ add_message \
>      '[body]="-----Original Message-----
>  Text here.
>  "'
> -test_subtest_known_broken
>  test_emacs_expect_t \
>      '(load "emacs-original-message-hiding.el") (notmuch-test-original-message-hiding)'
>  
> -- 
> 1.7.8.3
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2012-01-25 17:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25 15:05 [PATCH 1/1] emacs: Take more care when hiding regions with buttons David Edmondson
2012-01-25 15:10 ` Dmitry Kurochkin
2012-01-25 15:18   ` David Edmondson
2012-01-25 15:45 ` [PATCH 0/4 v2] " David Edmondson
2012-01-25 15:45   ` [PATCH 1/4 v2] test: `visible-buffer-substring' should not return text properties David Edmondson
2012-01-25 17:35     ` Dmitry Kurochkin
2012-01-25 15:45   ` [PATCH 2/4 v2] test: `notmuch-test-run' should protect against buffer switching David Edmondson
2012-01-25 17:36     ` Dmitry Kurochkin
2012-01-25 15:45   ` [PATCH 3/4 v2] test: Add test for Original Message hiding at point-min David Edmondson
2012-01-25 17:53     ` Dmitry Kurochkin
2012-01-26  7:22       ` David Edmondson
2012-01-25 15:45   ` [PATCH 4/4 v2] emacs: Take more care when hiding regions with buttons David Edmondson
2012-01-25 17:53     ` Dmitry Kurochkin [this message]
2012-01-26  7:19 ` [PATCH 0/4 v3] " David Edmondson
2012-01-26  7:19   ` [PATCH 1/4 v3] test: `visible-buffer-substring' should not return text properties David Edmondson
2012-01-26  7:19   ` [PATCH 2/4 v3] test: `notmuch-test-run' should protect against buffer switching David Edmondson
2012-01-26  7:19   ` [PATCH 3/4 v3] test: Add test for Original Message hiding at point-min David Edmondson
2012-01-26  7:19   ` [PATCH 4/4 v3] emacs: Take more care when hiding regions with buttons David Edmondson
2012-01-26 12:40   ` [PATCH 0/4 v3] " David Bremner
2012-01-30 12:27   ` Dmitry Kurochkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ipjzhdn1.fsf@gmail.com \
    --to=dmitry.kurochkin@gmail.com \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).