unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* "empty" tag  
@ 2010-11-19  7:24 Sebastian Spaeth
  2010-11-19  8:22 ` [PATCH] emacs: Avoid attempts to add invalid tags David Edmondson
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Spaeth @ 2010-11-19  7:24 UTC (permalink / raw)
  To: Notmuch developer list

Just some observation with respect to the mysterious "empty" tag. In
notmuch-show, if I press +<RET>, you can see the tag line changing, so
it has been adding something (a newline?). You can remove it again with
-<RET>.

IMHO we should protect against adding this from the emacs UI. I
sometimes press accidentally +, and want to get out of the dialog by
pressing return (rather than c-g).

Sebastian

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

* [PATCH] emacs: Avoid attempts to add invalid tags.
  2010-11-19  7:24 "empty" tag Sebastian Spaeth
@ 2010-11-19  8:22 ` David Edmondson
  0 siblings, 0 replies; 2+ messages in thread
From: David Edmondson @ 2010-11-19  8:22 UTC (permalink / raw)
  To: notmuch

Add a (probably incomplete) function to validate a tag specified by
the user. Use the function to avoid adding invalid tags.
---
 emacs/notmuch.el |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3d82f0d..b003cd6 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -72,12 +72,19 @@ For example:
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch)
 
+(defun notmuch-valid-tag (tag)
+  (not (string= "" tag)))
+
 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
-  (let ((tag-list
-	 (with-output-to-string
-	   (with-current-buffer standard-output
-	     (apply 'call-process notmuch-command nil t nil "search-tags" search-terms)))))
-    (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))
+  (let* ((tag-list
+	  (with-output-to-string
+	    (with-current-buffer standard-output
+	      (apply 'call-process notmuch-command nil t nil "search-tags" search-terms))))
+	 (tag (completing-read prompt (split-string tag-list "\n+" t)
+			       nil nil nil)))
+    (if (notmuch-valid-tag tag)
+	tag
+      (error "Invalid tag"))))
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
-- 
1.7.2.3

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

end of thread, other threads:[~2010-11-19  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19  7:24 "empty" tag Sebastian Spaeth
2010-11-19  8:22 ` [PATCH] emacs: Avoid attempts to add invalid tags David Edmondson

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