helm: unified :config blocks in init-helm
This commit is contained in:
parent
6747e9a9f6
commit
9f7914fa04
|
@ -36,58 +36,6 @@
|
|||
(use-package helm
|
||||
:defer 1
|
||||
:commands (spacemacs/helm-find-files)
|
||||
:config
|
||||
(progn
|
||||
(when (and dotspacemacs-helm-resize
|
||||
(or (eq dotspacemacs-helm-position 'bottom)
|
||||
(eq dotspacemacs-helm-position 'top)))
|
||||
(setq helm-autoresize-min-height 10)
|
||||
(helm-autoresize-mode 1))
|
||||
|
||||
;; from https://www.reddit.com/r/emacs/comments/2z7nbv/lean_helm_window/
|
||||
(defvar helm-source-header-default-background
|
||||
(face-attribute 'helm-source-header :background))
|
||||
(defvar helm-source-header-default-foreground
|
||||
(face-attribute 'helm-source-header :foreground))
|
||||
(defvar helm-source-header-default-box
|
||||
(face-attribute 'helm-source-header :box))
|
||||
(defvar helm-source-header-default-height
|
||||
(face-attribute 'helm-source-header :height) )
|
||||
|
||||
(defun helm-toggle-header-line ()
|
||||
"Hide the `helm' header is there is only one source."
|
||||
(when dotspacemacs-helm-no-header
|
||||
(if (> (length helm-sources) 1)
|
||||
(set-face-attribute
|
||||
'helm-source-header
|
||||
nil
|
||||
:foreground helm-source-header-default-foreground
|
||||
:background helm-source-header-default-background
|
||||
:box helm-source-header-default-box
|
||||
:height helm-source-header-default-height)
|
||||
(set-face-attribute
|
||||
'helm-source-header
|
||||
nil
|
||||
:foreground (face-attribute 'helm-selection :background)
|
||||
:background (face-attribute 'helm-selection :background)
|
||||
:box nil
|
||||
:height 0.1))))
|
||||
(add-hook 'helm-before-initialize-hook 'helm-toggle-header-line)
|
||||
|
||||
(defun spacemacs/helm-find-files (arg)
|
||||
"Custom spacemacs implementation for calling helm-find-files-1.
|
||||
|
||||
Removes the automatic guessing of the initial value based on thing at point. "
|
||||
(interactive "P")
|
||||
(let* ((hist (and arg helm-ff-history (helm-find-files-history)))
|
||||
(default-input hist )
|
||||
(input (cond ((and (eq major-mode 'dired-mode) default-input)
|
||||
(file-name-directory default-input))
|
||||
((and (not (string= default-input ""))
|
||||
default-input))
|
||||
(t (expand-file-name (helm-current-directory))))))
|
||||
(set-text-properties 0 (length input) nil input)
|
||||
(helm-find-files-1 input ))))
|
||||
:init
|
||||
(progn
|
||||
(setq helm-prevent-escaping-from-minibuffer t
|
||||
|
@ -339,6 +287,57 @@ Removes the automatic guessing of the initial value based on thing at point. "
|
|||
(progn
|
||||
(helm-mode +1)
|
||||
|
||||
(when (and dotspacemacs-helm-resize
|
||||
(or (eq dotspacemacs-helm-position 'bottom)
|
||||
(eq dotspacemacs-helm-position 'top)))
|
||||
(setq helm-autoresize-min-height 10)
|
||||
(helm-autoresize-mode 1))
|
||||
|
||||
;; from https://www.reddit.com/r/emacs/comments/2z7nbv/lean_helm_window/
|
||||
(defvar helm-source-header-default-background
|
||||
(face-attribute 'helm-source-header :background))
|
||||
(defvar helm-source-header-default-foreground
|
||||
(face-attribute 'helm-source-header :foreground))
|
||||
(defvar helm-source-header-default-box
|
||||
(face-attribute 'helm-source-header :box))
|
||||
(defvar helm-source-header-default-height
|
||||
(face-attribute 'helm-source-header :height) )
|
||||
|
||||
(defun helm-toggle-header-line ()
|
||||
"Hide the `helm' header is there is only one source."
|
||||
(when dotspacemacs-helm-no-header
|
||||
(if (> (length helm-sources) 1)
|
||||
(set-face-attribute
|
||||
'helm-source-header
|
||||
nil
|
||||
:foreground helm-source-header-default-foreground
|
||||
:background helm-source-header-default-background
|
||||
:box helm-source-header-default-box
|
||||
:height helm-source-header-default-height)
|
||||
(set-face-attribute
|
||||
'helm-source-header
|
||||
nil
|
||||
:foreground (face-attribute 'helm-selection :background)
|
||||
:background (face-attribute 'helm-selection :background)
|
||||
:box nil
|
||||
:height 0.1))))
|
||||
(add-hook 'helm-before-initialize-hook 'helm-toggle-header-line)
|
||||
|
||||
(defun spacemacs/helm-find-files (arg)
|
||||
"Custom spacemacs implementation for calling helm-find-files-1.
|
||||
|
||||
Removes the automatic guessing of the initial value based on thing at point. "
|
||||
(interactive "P")
|
||||
(let* ((hist (and arg helm-ff-history (helm-find-files-history)))
|
||||
(default-input hist )
|
||||
(input (cond ((and (eq major-mode 'dired-mode) default-input)
|
||||
(file-name-directory default-input))
|
||||
((and (not (string= default-input ""))
|
||||
default-input))
|
||||
(t (expand-file-name (helm-current-directory))))))
|
||||
(set-text-properties 0 (length input) nil input)
|
||||
(helm-find-files-1 input )))
|
||||
|
||||
;; helm-locate uses es (from everything on windows,
|
||||
;; which doesnt like fuzzy)
|
||||
(helm-locate-set-command)
|
||||
|
|
Loading…
Reference in a new issue