mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
emacs: sanitize dedicated widget action/notify functions
These functions are used as action/notify functions. That dictates the appropriate function signatures but even though these functions are not used for anything else they use incompatible signatures, forcing the callers to use lambda expressions to deal with these incompatibilities. Fix that by adjusting the function signatures to the needs of the only intended callers. Two of these functions were defined as commands but because the interactive form did not return the mandatory arguments, we know that nobody (successfully) used these as commands. In one case we move the location of a y-or-n-p prompt.
This commit is contained in:
parent
5b19e6e1b4
commit
d7b83385af
1 changed files with 18 additions and 27 deletions
|
@ -385,18 +385,16 @@ supported for \"Customized queries section\" items."
|
||||||
(format "%s%03d" notmuch-hello-thousands-separator elem))
|
(format "%s%03d" notmuch-hello-thousands-separator elem))
|
||||||
(cdr result)))))
|
(cdr result)))))
|
||||||
|
|
||||||
(defun notmuch-hello-search (&optional search)
|
(defun notmuch-hello-search (widget &rest _event)
|
||||||
(unless (null search)
|
(let ((search (widget-value widget)))
|
||||||
|
(when search
|
||||||
(setq search (string-trim search))
|
(setq search (string-trim search))
|
||||||
(let ((history-delete-duplicates t))
|
(let ((history-delete-duplicates t))
|
||||||
(add-to-history 'notmuch-search-history search)))
|
(add-to-history 'notmuch-search-history search)))
|
||||||
(notmuch-search search notmuch-search-oldest-first))
|
(notmuch-search search notmuch-search-oldest-first)))
|
||||||
|
|
||||||
(defun notmuch-hello-add-saved-search (widget)
|
(defun notmuch-hello-add-saved-search (widget &rest _event)
|
||||||
(interactive)
|
(let ((search (widget-value (widget-get widget :parent)))
|
||||||
(let ((search (widget-value
|
|
||||||
(symbol-value
|
|
||||||
(widget-get widget :notmuch-saved-search-widget))))
|
|
||||||
(name (completing-read "Name for saved search: "
|
(name (completing-read "Name for saved search: "
|
||||||
notmuch-saved-searches)))
|
notmuch-saved-searches)))
|
||||||
;; If an existing saved search with this name exists, remove it.
|
;; If an existing saved search with this name exists, remove it.
|
||||||
|
@ -412,13 +410,11 @@ supported for \"Customized queries section\" items."
|
||||||
(message "Saved '%s' as '%s'." search name)
|
(message "Saved '%s' as '%s'." search name)
|
||||||
(notmuch-hello-update)))
|
(notmuch-hello-update)))
|
||||||
|
|
||||||
(defun notmuch-hello-delete-search-from-history (widget)
|
(defun notmuch-hello-delete-search-from-history (widget &rest _event)
|
||||||
(interactive)
|
(when (y-or-n-p "Are you sure you want to delete this search? ")
|
||||||
(let ((search (widget-value
|
(let ((search (widget-value (widget-get widget :parent))))
|
||||||
(symbol-value
|
(setq notmuch-search-history
|
||||||
(widget-get widget :notmuch-saved-search-widget)))))
|
(delete search notmuch-search-history)))
|
||||||
(setq notmuch-search-history (delete search
|
|
||||||
notmuch-search-history))
|
|
||||||
(notmuch-hello-update)))
|
(notmuch-hello-update)))
|
||||||
|
|
||||||
(defun notmuch-hello-longest-label (searches-alist)
|
(defun notmuch-hello-longest-label (searches-alist)
|
||||||
|
@ -768,8 +764,7 @@ Complete list of currently available key bindings:
|
||||||
;; search boxes.
|
;; search boxes.
|
||||||
:size (max 8 (- (window-width) notmuch-hello-indent
|
:size (max 8 (- (window-width) notmuch-hello-indent
|
||||||
(length "Search: ")))
|
(length "Search: ")))
|
||||||
:action (lambda (widget &rest ignore)
|
:action #'notmuch-hello-search)
|
||||||
(notmuch-hello-search (widget-value widget))))
|
|
||||||
;; Add an invisible dot to make `widget-end-of-line' ignore
|
;; Add an invisible dot to make `widget-end-of-line' ignore
|
||||||
;; trailing spaces in the search widget field. A dot is used
|
;; trailing spaces in the search widget field. A dot is used
|
||||||
;; instead of a space to make `show-trailing-whitespace'
|
;; instead of a space to make `show-trailing-whitespace'
|
||||||
|
@ -816,20 +811,16 @@ Complete list of currently available key bindings:
|
||||||
;; button. 5 for the
|
;; button. 5 for the
|
||||||
;; `[del]' button.
|
;; `[del]' button.
|
||||||
1 5))
|
1 5))
|
||||||
:action (lambda (widget &rest ignore)
|
:action #'notmuch-hello-search
|
||||||
(notmuch-hello-search (widget-value widget)))
|
|
||||||
search))
|
search))
|
||||||
(widget-insert " ")
|
(widget-insert " ")
|
||||||
(widget-create 'push-button
|
(widget-create 'push-button
|
||||||
:notify (lambda (widget &rest ignore)
|
:notify #'notmuch-hello-add-saved-search
|
||||||
(notmuch-hello-add-saved-search widget))
|
|
||||||
:notmuch-saved-search-widget widget-symbol
|
:notmuch-saved-search-widget widget-symbol
|
||||||
"save")
|
"save")
|
||||||
(widget-insert " ")
|
(widget-insert " ")
|
||||||
(widget-create 'push-button
|
(widget-create 'push-button
|
||||||
:notify (lambda (widget &rest ignore)
|
:notify #'notmuch-hello-delete-search-from-history
|
||||||
(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
|
:notmuch-saved-search-widget widget-symbol
|
||||||
"del"))
|
"del"))
|
||||||
(widget-insert "\n"))
|
(widget-insert "\n"))
|
||||||
|
|
Loading…
Reference in a new issue