summaryrefslogtreecommitdiff
path: root/helm-locate.el
diff options
context:
space:
mode:
authorUros Perisic <uros.m.perisic@gmail.com>2019-10-08 12:39:03 +0800
committerUros Perisic <uros.m.perisic@gmail.com>2019-10-08 12:39:03 +0800
commitab6c9aa98557de3315fdc03b2c75ae3ee47b8764 (patch)
tree1a8565f2d1620191b44494c97f3c8aa845fc1ad4 /helm-locate.el
parent6e8fa9c7cfdbcf5807f46c49717a5615fa88e9ed (diff)
Extract mode-line updating functionality.
It makes the code more readable and maintainable. It also makes it possible to disable the mode-line updates with `advice-add` should a user choose to.
Diffstat (limited to 'helm-locate.el')
-rw-r--r--helm-locate.el27
1 files changed, 16 insertions, 11 deletions
diff --git a/helm-locate.el b/helm-locate.el
index 53790a7a..c90263e5 100644
--- a/helm-locate.el
+++ b/helm-locate.el
@@ -262,6 +262,21 @@ See also `helm-locate'."
:default default
:history 'helm-file-name-history)))
+(defun helm-locate-update-mode-line (process-name)
+ "Update mode-line with PROCESS-NAME status information."
+ (with-helm-window
+ (setq mode-line-format
+ '(" " mode-line-buffer-identification " "
+ (:eval (format "L%s" (helm-candidate-number-at-point))) " "
+ (:eval (propertize
+ (format "[%s process finished - (%s results)]"
+ (max (1- (count-lines
+ (point-min) (point-max)))
+ 0)
+ process-name)
+ 'face 'helm-locate-finish))))
+ (force-mode-line-update)))
+
(defun helm-locate-init ()
"Initialize async locate process for `helm-source-locate'."
(let* ((locate-is-es (string-match "\\`es" helm-locate-command))
@@ -309,17 +324,7 @@ See also `helm-locate'."
(when (and helm-locate-fuzzy-match
(not (string-match-p "\\s-" helm-pattern)))
(helm-redisplay-buffer))
- (with-helm-window
- (setq mode-line-format
- '(" " mode-line-buffer-identification " "
- (:eval (format "L%s" (helm-candidate-number-at-point))) " "
- (:eval (propertize
- (format "[Locate process finished - (%s results)]"
- (max (1- (count-lines
- (point-min) (point-max)))
- 0))
- 'face 'helm-locate-finish))))
- (force-mode-line-update)))
+ (helm-locate-update-mode-line "Locate"))
(t
(helm-log "Error: Locate %s"
(replace-regexp-in-string "\n" "" event))))))))))