summaryrefslogtreecommitdiff
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
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.
-rw-r--r--helm-find.el16
-rw-r--r--helm-locate.el27
2 files changed, 19 insertions, 24 deletions
diff --git a/helm-find.el b/helm-find.el
index 15d2b85f..9c1ab0ca 100644
--- a/helm-find.el
+++ b/helm-find.el
@@ -123,19 +123,9 @@ separator."
(helm-process-deferred-sentinel-hook
process event (helm-default-directory))
(if (string= event "finished\n")
- (with-helm-window
- (setq mode-line-format
- '(" " mode-line-buffer-identification " "
- (:eval (format "L%s" (helm-candidate-number-at-point))) " "
- (:eval (propertize
- (format "[Find process finished - (%s results)]"
- (max (1- (count-lines
- (point-min) (point-max)))
- 0))
- 'face 'helm-locate-finish))))
- (force-mode-line-update))
- (helm-log "Error: Find %s"
- (replace-regexp-in-string "\n" "" event))))))))
+ (helm-locate-update-mode-line "Find")
+ (helm-log "Error: Find %s"
+ (replace-regexp-in-string "\n" "" event))))))))
(defun helm-find-1 (dir)
(let ((default-directory (file-name-as-directory dir)))
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))))))))))