Helm mode-line segments + hide helm source header better

This commit is contained in:
Henrik Lissner 2015-12-12 16:08:21 -05:00
parent 206bddf4c3
commit 8652505d8e
2 changed files with 40 additions and 5 deletions

View file

@ -51,10 +51,11 @@
"C-u" 'helm-delete-minibuffer-contents))
;;; Helm hacks
(defvar narf-helm-header-fg (face-attribute 'helm-source-header :foreground) "docstring")
(defun narf*helm-hide-source-header-maybe ()
(if (<= (length helm-sources) 1)
(set-face-attribute 'helm-source-header nil :height 0.1)
(set-face-attribute 'helm-source-header nil :height 1.0)))
(set-face-attribute 'helm-source-header nil :height 0.1 :foreground "#111111")
(set-face-attribute 'helm-source-header nil :height 1.0 :foreground narf-helm-header-fg)))
(defun narf*helm-hide-modeline (source &optional force)
(setq mode-line-format nil)
@ -67,7 +68,7 @@
plist)
;; Shrink source headers if there is only one source
(add-hook 'helm-before-initialize-hook 'narf*helm-hide-source-header-maybe)
(add-hook 'helm-after-initialize-hook 'narf*helm-hide-source-header-maybe)
;; A simpler prompt: see `helm-global-prompt'
(advice-add 'helm :filter-args 'narf*helm-replace-prompt)
;; Hide mode-line in helm windows

View file

@ -22,7 +22,7 @@
hl-line-sticky-flag nil ; only highlight in one window
jit-lock-defer-time nil
jit-lock-stealth-time 1
jit-lock-stealth-time 0.5
idle-update-delay 1
split-width-threshold nil ; favor horizontal splits
@ -491,7 +491,41 @@ Supports both Emacs and Evil cursor conventions."
(global :when active)
("%l/%c" *buffer-position)
*hud
)))
))
(spaceline-define-segment helm-id
"Number of helm candidates."
(buffer-name)
:when (bound-and-true-p helm-alive-p)
:tight t)
(spaceline-define-segment helm-number
"Number of helm candidates."
(format "%d/%s (%s total)"
(helm-candidate-number-at-point)
(helm-get-candidate-number t)
(helm-get-candidate-number))
:when (bound-and-true-p helm-alive-p))
(spaceline-define-segment helm-help
"Helm keybindings help."
(-interleave
(mapcar (lambda (s)
(propertize (substitute-command-keys s) 'face 'bold))
'("\\<helm-map>\\[helm-help]"
"\\<helm-map>\\[helm-select-action]"
"\\<helm-map>\\[helm-maybe-exit-minibuffer]/F1/F2..."))
'("(help)" "(actions)" "(action)"))
:when (bound-and-true-p helm-alive-p))
(defun narf|helm-mode-line (source &optional force)
"Set up a custom helm modeline."
(setq spaceline--helm-current-source source
mode-line-format '("%e" (:eval (spaceline--prepare
'(helm-number helm-id)
'(helm-help)))))
(when force (force-mode-line-update)))
(advice-add 'helm-display-mode-line :after 'narf|helm-mode-line))
(provide 'core-ui)
;;; core-ui.el ends here