unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: stash bugfix
@ 2012-12-02 10:11 Mark Walters
  2012-12-02 11:04 ` Tomi Ollila
  2012-12-03  1:34 ` Austin Clements
  0 siblings, 2 replies; 8+ messages in thread
From: Mark Walters @ 2012-12-02 10:11 UTC (permalink / raw)
  To: notmuch

Currently an attempt to stash a non-existent field (eg cc when not
present) throws an error. Catch this case and give the user a warning
message.

---
While messing around with notmuch-pick key bindings I found the
following bug. The easiest way I have found to trigger it is cc
(stash-cc) in show mode on a message with no cc header.

Best wishes

Mark

 emacs/notmuch-lib.el |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 1d0ec17..c7d8e02 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -183,8 +183,11 @@ user-friendly queries."
 
 (defun notmuch-common-do-stash (text)
   "Common function to stash text in kill ring, and display in minibuffer."
-  (kill-new text)
-  (message "Stashed: %s" text))
+  (if text
+      (progn
+	(kill-new text)
+	(message "Stashed: %s" text))
+    (message "Warning: Nothing to stash!")))
 
 ;;
 
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] emacs: stash bugfix
  2012-12-02 10:11 [PATCH] emacs: stash bugfix Mark Walters
@ 2012-12-02 11:04 ` Tomi Ollila
  2012-12-03  1:34 ` Austin Clements
  1 sibling, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2012-12-02 11:04 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Sun, Dec 02 2012, Mark Walters <markwalters1009@gmail.com> wrote:

> Currently an attempt to stash a non-existent field (eg cc when not
> present) throws an error. Catch this case and give the user a warning
> message.
>
> ---

LGTM.

Tomi


> While messing around with notmuch-pick key bindings I found the
> following bug. The easiest way I have found to trigger it is cc
> (stash-cc) in show mode on a message with no cc header.
>
> Best wishes
>
> Mark
>
>  emacs/notmuch-lib.el |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 1d0ec17..c7d8e02 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -183,8 +183,11 @@ user-friendly queries."
>  
>  (defun notmuch-common-do-stash (text)
>    "Common function to stash text in kill ring, and display in minibuffer."
> -  (kill-new text)
> -  (message "Stashed: %s" text))
> +  (if text
> +      (progn
> +	(kill-new text)
> +	(message "Stashed: %s" text))
> +    (message "Warning: Nothing to stash!")))
>  
>  ;;
>  
> -- 
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] emacs: stash bugfix
  2012-12-02 10:11 [PATCH] emacs: stash bugfix Mark Walters
  2012-12-02 11:04 ` Tomi Ollila
@ 2012-12-03  1:34 ` Austin Clements
  2012-12-03  9:27   ` Mark Walters
  1 sibling, 1 reply; 8+ messages in thread
From: Austin Clements @ 2012-12-03  1:34 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Quoth Mark Walters on Dec 02 at 10:11 am:
> Currently an attempt to stash a non-existent field (eg cc when not
> present) throws an error. Catch this case and give the user a warning
> message.
> 
> ---
> While messing around with notmuch-pick key bindings I found the
> following bug. The easiest way I have found to trigger it is cc
> (stash-cc) in show mode on a message with no cc header.
> 
> Best wishes
> 
> Mark
> 
>  emacs/notmuch-lib.el |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 1d0ec17..c7d8e02 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -183,8 +183,11 @@ user-friendly queries."
>  
>  (defun notmuch-common-do-stash (text)
>    "Common function to stash text in kill ring, and display in minibuffer."
> -  (kill-new text)
> -  (message "Stashed: %s" text))
> +  (if text
> +      (progn
> +	(kill-new text)
> +	(message "Stashed: %s" text))
> +    (message "Warning: Nothing to stash!")))

Without the unnecessary "Warning:" bit of the message, LGTM.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] emacs: stash bugfix
  2012-12-03  1:34 ` Austin Clements
@ 2012-12-03  9:27   ` Mark Walters
  2012-12-03 15:20     ` Austin Clements
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Walters @ 2012-12-03  9:27 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch


On Mon, 03 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:
> Quoth Mark Walters on Dec 02 at 10:11 am:
>> Currently an attempt to stash a non-existent field (eg cc when not
>> present) throws an error. Catch this case and give the user a warning
>> message.
>> 
>> ---
>> While messing around with notmuch-pick key bindings I found the
>> following bug. The easiest way I have found to trigger it is cc
>> (stash-cc) in show mode on a message with no cc header.
>> 
>> Best wishes
>> 
>> Mark
>> 
>>  emacs/notmuch-lib.el |    7 +++++--
>>  1 files changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
>> index 1d0ec17..c7d8e02 100644
>> --- a/emacs/notmuch-lib.el
>> +++ b/emacs/notmuch-lib.el
>> @@ -183,8 +183,11 @@ user-friendly queries."
>>  
>>  (defun notmuch-common-do-stash (text)
>>    "Common function to stash text in kill ring, and display in minibuffer."
>> -  (kill-new text)
>> -  (message "Stashed: %s" text))
>> +  (if text
>> +      (progn
>> +	(kill-new text)
>> +	(message "Stashed: %s" text))
>> +    (message "Warning: Nothing to stash!")))
>
> Without the unnecessary "Warning:" bit of the message, LGTM.

I am obviously happy to remove the "warning": however do you think
stashing a non-existent thing should empty the kill-ring? I am a little
worried about someone stashing something, not noticing the "nothing to
stash" and then pasting some random thing somewhere (eg something
private into irc).

Best wishes

Mark

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] emacs: stash bugfix
  2012-12-03  9:27   ` Mark Walters
@ 2012-12-03 15:20     ` Austin Clements
  2012-12-05 12:20       ` [PATCH v2] " Mark Walters
  0 siblings, 1 reply; 8+ messages in thread
From: Austin Clements @ 2012-12-03 15:20 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Quoth Mark Walters on Dec 03 at  9:27 am:
> 
> On Mon, 03 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:
> > Quoth Mark Walters on Dec 02 at 10:11 am:
> >> Currently an attempt to stash a non-existent field (eg cc when not
> >> present) throws an error. Catch this case and give the user a warning
> >> message.
> >> 
> >> ---
> >> While messing around with notmuch-pick key bindings I found the
> >> following bug. The easiest way I have found to trigger it is cc
> >> (stash-cc) in show mode on a message with no cc header.
> >> 
> >> Best wishes
> >> 
> >> Mark
> >> 
> >>  emacs/notmuch-lib.el |    7 +++++--
> >>  1 files changed, 5 insertions(+), 2 deletions(-)
> >> 
> >> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> >> index 1d0ec17..c7d8e02 100644
> >> --- a/emacs/notmuch-lib.el
> >> +++ b/emacs/notmuch-lib.el
> >> @@ -183,8 +183,11 @@ user-friendly queries."
> >>  
> >>  (defun notmuch-common-do-stash (text)
> >>    "Common function to stash text in kill ring, and display in minibuffer."
> >> -  (kill-new text)
> >> -  (message "Stashed: %s" text))
> >> +  (if text
> >> +      (progn
> >> +	(kill-new text)
> >> +	(message "Stashed: %s" text))
> >> +    (message "Warning: Nothing to stash!")))
> >
> > Without the unnecessary "Warning:" bit of the message, LGTM.
> 
> I am obviously happy to remove the "warning": however do you think
> stashing a non-existent thing should empty the kill-ring? I am a little
> worried about someone stashing something, not noticing the "nothing to
> stash" and then pasting some random thing somewhere (eg something
> private into irc).

Mm, interesting.  I don't think you want to empty the kill-ring
because there may be useful things earlier in it.  You could clear out
the window system selection directly, but that's probably flaky and
doesn't help if you're copying around within Emacs.  What about
(kill-new "")?  Then the function would always put something on the
kill-ring (and clipboard/selection/whatever) but it would be harmless
if there was nothing to stash.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] emacs: stash bugfix
  2012-12-03 15:20     ` Austin Clements
@ 2012-12-05 12:20       ` Mark Walters
  2012-12-05 16:01         ` Austin Clements
  2012-12-06 21:25         ` David Bremner
  0 siblings, 2 replies; 8+ messages in thread
From: Mark Walters @ 2012-12-05 12:20 UTC (permalink / raw)
  To: notmuch

Currently an attempt to stash a non-existent field (eg cc when not
present) throws an error. Catch this case and give the user a warning
message.
---

This fixes the comment and stashes an empty string in the
case there is nothing to stash (both suggested by Austin).


 emacs/notmuch-lib.el |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 1d0ec17..5c44867 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -183,8 +183,14 @@ user-friendly queries."
 
 (defun notmuch-common-do-stash (text)
   "Common function to stash text in kill ring, and display in minibuffer."
-  (kill-new text)
-  (message "Stashed: %s" text))
+  (if text
+      (progn
+	(kill-new text)
+	(message "Stashed: %s" text))
+    ;; There is nothing to stash so stash an empty string so the user
+    ;; doesn't accidentally paste something else somewhere.
+    (kill-new "")
+    (message "Nothing to stash!")))
 
 ;;
 
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] emacs: stash bugfix
  2012-12-05 12:20       ` [PATCH v2] " Mark Walters
@ 2012-12-05 16:01         ` Austin Clements
  2012-12-06 21:25         ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: Austin Clements @ 2012-12-05 16:01 UTC (permalink / raw)
  To: Mark Walters, notmuch

LGTM.

On Wed, 05 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> Currently an attempt to stash a non-existent field (eg cc when not
> present) throws an error. Catch this case and give the user a warning
> message.
> ---
>
> This fixes the comment and stashes an empty string in the
> case there is nothing to stash (both suggested by Austin).
>
>
>  emacs/notmuch-lib.el |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 1d0ec17..5c44867 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -183,8 +183,14 @@ user-friendly queries."
>  
>  (defun notmuch-common-do-stash (text)
>    "Common function to stash text in kill ring, and display in minibuffer."
> -  (kill-new text)
> -  (message "Stashed: %s" text))
> +  (if text
> +      (progn
> +	(kill-new text)
> +	(message "Stashed: %s" text))
> +    ;; There is nothing to stash so stash an empty string so the user
> +    ;; doesn't accidentally paste something else somewhere.
> +    (kill-new "")
> +    (message "Nothing to stash!")))
>  
>  ;;
>  
> -- 
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] emacs: stash bugfix
  2012-12-05 12:20       ` [PATCH v2] " Mark Walters
  2012-12-05 16:01         ` Austin Clements
@ 2012-12-06 21:25         ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2012-12-06 21:25 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> Currently an attempt to stash a non-existent field (eg cc when not
> present) throws an error. Catch this case and give the user a warning
> message.

pushed,

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-06 21:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-02 10:11 [PATCH] emacs: stash bugfix Mark Walters
2012-12-02 11:04 ` Tomi Ollila
2012-12-03  1:34 ` Austin Clements
2012-12-03  9:27   ` Mark Walters
2012-12-03 15:20     ` Austin Clements
2012-12-05 12:20       ` [PATCH v2] " Mark Walters
2012-12-05 16:01         ` Austin Clements
2012-12-06 21:25         ` David Bremner

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).