]> code.delx.au - gnu-emacs-elpa/blobdiff - counsel.el
Add timing information to async commands
[gnu-emacs-elpa] / counsel.el
index a2ac55c62513a0138b39b6d1f3c801f9e18086fd..b5506a070b097753761b524e9d7af48d9894f7c0 100644 (file)
   "Store the time when a new process was started.
 Or the time of the last minibuffer update.")
 
+(defvar counsel--async-start nil
+  "Store the time when a new process was started.
+Or the time of the last minibuffer update.")
+
+(defvar counsel--async-duration nil
+  "Store the time in seconds between starting a process and
+  receiving all candidates.")
+
 (defvar counsel--async-exit-code-plist nil
   "Associates exit codes with reasons.")
 
@@ -108,7 +116,8 @@ Or the time of the last minibuffer update.")
                 counsel--process
                 counsel--process
                 cmd))
-    (setq counsel--async-time (current-time))
+    (setq counsel--async-start
+          (setq counsel--async-time (current-time)))
     (set-process-sentinel proc (or process-sentinel #'counsel--async-sentinel))
     (set-process-filter proc (or process-filter #'counsel--async-filter))))
 
@@ -132,6 +141,8 @@ Or the time of the last minibuffer update.")
            (ivy--set-candidates
             (ivy--sort-maybe
              cands))
+           (setq counsel--async-duration
+                 (time-to-seconds (time-since counsel--async-start)))
            (let ((re (funcall ivy--regex-function ivy-text)))
              (unless (stringp re)
                (setq re (caar re)))
@@ -1872,6 +1883,9 @@ An extra action allows to switch to the process buffer."
 ;;** `counsel-expression-history'
 ;;;###autoload
 (defun counsel-expression-history ()
+  "Select an element of `read-expression-history'.
+And insert it into the minibuffer. Useful during
+`eval-expression'"
   (interactive)
   (let ((enable-recursive-minibuffers t))
     (ivy-read "Expr: " (delete-dups read-expression-history)