+(defun howm-iigrep (completion-p action)
+ (howm-with-iigrep (howm-iigrep-command-for-pattern completion-p)
+ howm-iigrep-show-what action
+ (if completion-p
+ (howm-completing-read-keyword)
+ (read-from-minibuffer "Search all (grep): "))))
+
+(defmacro howm-with-iigrep (command-for-pattern show-what action &rest body)
+ (declare (indent 3))
+ `(let ((*iigrep-post-sentinel* (howm-iigrep-post-sentinel ,action))
+ (howm-view-summary-name "*howmS(preview)*")
+ (howm-view-contents-name "*howmC(preview)*")
+ (howm-history-limit 0)
+ (*howm-show-item-filename* nil)
+ (howm-message-time nil))
+ (unwind-protect
+ (iigrep-with-grep ,command-for-pattern ,show-what
+ ,@body)
+ (mapc (lambda (b) (and (get-buffer b) (kill-buffer b)))
+ (list howm-view-summary-name howm-view-contents-name)))))
+
+(defmacro howm-iigrep-command-for-pattern (&optional fixed-p converter)
+ ;; use macro due to dynamic binding. Sigh...
+ `(and howm-view-use-grep
+ (lambda (str)
+ (let* ((pattern (funcall (or ,converter #'identity) str))
+ (trio (howm-real-grep-single-command
+ pattern (list howm-directory) ,fixed-p))
+ (com (car trio))
+ (args (cl-second trio))
+ (fs (cl-third trio)))
+ (append (list com) (cons "-I" args) fs)))))
+
+(defmacro howm-iigrep-post-sentinel (action)
+ ;; use macro due to dynamic binding. Sigh...
+ `(lambda (hits pattern)
+ (when (<= hits howm-iigrep-preview-items)
+ (save-selected-window
+ (funcall ,action pattern)))))
+