]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: hello: allow deleting individual searches in the history
authorServilio Afre Puentes <servilio@gmail.com>
Fri, 7 Jun 2013 20:57:46 +0000 (16:57 -0400)
committerDavid Bremner <bremner@debian.org>
Sat, 8 Jun 2013 23:37:46 +0000 (20:37 -0300)
This commit adds an extra button at the end of the search entries that
allows deleting that individual search from the history. A short
confirmation («y» or «n») is made before taking action.

emacs/notmuch-hello.el

index 1ad1beafdc8ff5f40084887a9be489b7c2b262db..147c08cc2079c41c5bdc72da2366db8af65f3041 100644 (file)
@@ -286,6 +286,15 @@ afterwards.")
     (message "Saved '%s' as '%s'." search name)
     (notmuch-hello-update)))
 
     (message "Saved '%s' as '%s'." search name)
     (notmuch-hello-update)))
 
+(defun notmuch-hello-delete-search-from-history (widget)
+  (interactive)
+  (let ((search (widget-value
+                (symbol-value
+                 (widget-get widget :notmuch-saved-search-widget)))))
+    (setq notmuch-search-history (delete search
+                                        notmuch-search-history))
+    (notmuch-hello-update)))
+
 (defun notmuch-hello-longest-label (searches-alist)
   (or (loop for elem in searches-alist
            maximize (length (car elem)))
 (defun notmuch-hello-longest-label (searches-alist)
   (or (loop for elem in searches-alist
            maximize (length (car elem)))
@@ -624,7 +633,12 @@ Complete list of currently available key bindings:
                                                ;; `[save]' button. 6
                                                ;; for the `[save]'
                                                ;; button.
                                                ;; `[save]' button. 6
                                                ;; for the `[save]'
                                                ;; button.
-                                               1 6))
+                                               1 6
+                                               ;; 1 for the space
+                                               ;; before the `[del]'
+                                               ;; button. 5 for the
+                                               ;; `[del]' button.
+                                               1 5))
                                  :action (lambda (widget &rest ignore)
                                            (notmuch-hello-search (widget-value widget)))
                                  search))
                                  :action (lambda (widget &rest ignore)
                                            (notmuch-hello-search (widget-value widget)))
                                  search))
@@ -633,7 +647,14 @@ Complete list of currently available key bindings:
                             :notify (lambda (widget &rest ignore)
                                       (notmuch-hello-add-saved-search widget))
                             :notmuch-saved-search-widget widget-symbol
                             :notify (lambda (widget &rest ignore)
                                       (notmuch-hello-add-saved-search widget))
                             :notmuch-saved-search-widget widget-symbol
-                            "save"))
+                            "save")
+             (widget-insert " ")
+             (widget-create 'push-button
+                            :notify (lambda (widget &rest ignore)
+                                      (when (y-or-n-p "Are you sure you want to delete this search? ")
+                                        (notmuch-hello-delete-search-from-history widget)))
+                            :notmuch-saved-search-widget widget-symbol
+                            "del"))
            (widget-insert "\n"))
       (indent-rigidly start (point) notmuch-hello-indent))
     nil))
            (widget-insert "\n"))
       (indent-rigidly start (point) notmuch-hello-indent))
     nil))