Merge branch 'ivy' into develop

This commit is contained in:
syl20bnr 2016-01-09 14:18:16 -05:00
commit efd122d6c5
34 changed files with 2017 additions and 1217 deletions

View file

@ -264,8 +264,12 @@ layer directory."
(candidates . ,(append current-layer-paths
(list other-choice)))
(action . (lambda (c) c))))
(layer-path-sel (helm :sources helm-lp-source
:prompt "Configuration layer path: "))
(layer-path-sel (if (configuration-layer/layer-usedp 'spacemacs-ivy)
(ivy-read "Configuration layer path: "
(append current-layer-paths
(list other-choice)))
(helm :sources helm-lp-source
:prompt "Configuration layer path: ")))
(layer-path (cond
((string-equal layer-path-sel other-choice)
(read-directory-name (concat "Other configuration "
@ -346,7 +350,7 @@ Properties that can be copied are `:location', `:step' and `:excluded'."
;; packages
(when (file-exists-p packages-file)
;; required for lazy-loading of unused layers
;; for instance for helm-spacemacs
;; for instance for helm-spacemacs-help
(eval `(defvar ,(intern (format "%S-packages" name)) nil))
(unless (configuration-layer/layer-usedp name)
(load packages-file))
@ -390,7 +394,7 @@ Properties that can be copied are `:location', `:step' and `:excluded'."
;; TODO remove extensions in 0.106.0
(when (file-exists-p extensions-file)
;; required for lazy-loading of unused layers
;; for instance for helm-spacemacs
;; for instance for helm-spacemacs-help
(unless (configuration-layer/layer-usedp name)
(load extensions-file))
(dolist (step '(pre post))

View file

@ -505,12 +505,19 @@ HPADDING is the horizontal spacing betwee the content line and the frame border.
:follow-link "\C-m"
)
(insert " ")
(widget-create 'url-link
:tag (propertize "Search in Spacemacs" 'face 'font-lock-function-name-face)
:help-echo "Find Spacemacs package and layer configs using helm-spacemacs."
:action (lambda (&rest ignore) (call-interactively 'helm-spacemacs))
:mouse-face 'highlight
:follow-link "\C-m")
(if (configuration-layer/layer-usedp 'spacemacs-helm)
(widget-create 'url-link
:tag (propertize "Search in Spacemacs" 'face 'font-lock-function-name-face)
:help-echo "Find Spacemacs package and layer configs using helm-spacemacs-help."
:action (lambda (&rest ignore) (call-interactively 'helm-spacemacs-help))
:mouse-face 'highlight
:follow-link "\C-m")
(widget-create 'url-link
:tag (propertize "Search in Spacemacs" 'face 'font-lock-function-name-face)
:help-echo "Find Spacemacs package and layer configs using helm-spacemacs-help."
:action (lambda (&rest ignore) (call-interactively 'ivy-spacemacs-help))
:mouse-face 'highlight
:follow-link "\C-m"))
(insert "\n\n"))
(defun spacemacs-buffer//insert-file-list (list-display-name list)
@ -559,7 +566,8 @@ HPADDING is the horizontal spacing betwee the content line and the frame border.
(spacemacs//insert--shortcut "r" "Recent Files:")
(insert list-separator)))
((eq el 'bookmarks)
(helm-mode)
(when (configuration-layer/layer-usedp 'spacemacs-helm) (helm-mode))
(require 'bookmark)
(when (spacemacs-buffer//insert-bookmark-list "Bookmarks:" (bookmark-all-names))
(spacemacs//insert--shortcut "b" "Bookmarks:")
(insert list-separator)))

View file

@ -23,6 +23,7 @@ values."
;; Uncomment some layer names and press <SPC f e R> (Vim style) or
;; <M-m f e R> (Emacs style) to install them.
;; ----------------------------------------------------------------
spacemacs-helm
;; auto-completion
;; better-defaults
emacs-lisp

View file

@ -791,7 +791,7 @@ Spacemacs ships with the following evil plugins:
Spacemacs has unique UI elements to make the Emacs experience even more
enjoyable:
- dedicated startup page with a mode aimed at easily managing Spacemacs
- dedicated helm source via =helm-spacemacs=
- dedicated helm source via =helm-spacemacs-help=
- a [[https://github.com/justbur/emacs-which-key][which-key]] buffer
** Graphical UI
@ -929,8 +929,8 @@ and ~T~):
| ~SPC T t~ | toggle tool bar |
| ~SPC T T~ | toggle frame transparency and enter transparency micro-state |
*Note*: These toggles are all available via the =helm-spacemacs= interface (press
~SPC h SPC~ to display the =helm-spacemacs= buffer).
*Note*: These toggles are all available via the =helm-spacemacs-help= interface
(press ~SPC f e h~ to display the =helm-spacemacs-help= buffer).
**** Global line numbers
Line numbers can be toggled on in all =prog-mode= and =text-mode= buffers by
@ -1300,8 +1300,8 @@ Navigation key bindings in =help-mode=:
| ~g h~ | go to help for symbol under point |
*** Available layers
All layers can be easily discovered via =helm-spacemacs= accessible with ~SPC f
e h~.
All layers can be easily discovered via =helm-spacemacs-help= accessible with
~SPC f e h~.
The following helm actions are available:
- default: open the layer =README.org=
@ -1309,9 +1309,9 @@ The following helm actions are available:
- 3nd: open the layer =extensions.el=
**** Available packages in Spacemacs
=helm-spacemacs= also lists all the packages available in Spacemacs. The entry
format is =(layer) packages=. If you type =flycheck= you'll be able to see all
the layers where =flycheck= is used.
=helm-spacemacs-help= also lists all the packages available in Spacemacs. The
entry format is =(layer) packages=. If you type =flycheck= you'll be able to see
all the layers where =flycheck= is used.
The following helm actions are available on packages:
- default: go the package init function
@ -1360,8 +1360,8 @@ Spacemacs.
| ~x~ | execute (action flags) |
*** Toggles
=helm-spacemacs= is also a central place to discover the available toggles. To
display only the toggles source press ~C-l~ (or in [[Helm micro-state][Helm micro-state]] you can
=helm-spacemacs-help= is also a central place to discover the available toggles.
To display only the toggles source press ~C-l~ (or in [[Helm micro-state][Helm micro-state]] you can
press just ~l~).
The following helm actions are available on packages:

View file

@ -122,7 +122,7 @@ In =vim= editing style the universal argument defaults to ~SPC u~
instead of ~C-u~ because the latter is used to scroll up as in Vim.
** Configuration layers and Package discovery
By using =helm-spacemacs= with ~SPC h SPC~ you can quickly search
By using =helm-spacemacs-help= with ~SPC h SPC~ you can quickly search
for a package and get the name of the layers using it.
You can also easily go to the =README.org= of a layer or go to the initialization

View file

@ -0,0 +1,30 @@
;;; keybindings.el --- Spacemacs Base Layer key-bindings File
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;; describe functions ---------------------------------------------------------
(defmacro spacemacs||set-helm-key (keys func)
"Define a key bindings for FUNC using KEYS.
Ensure that helm is required before calling FUNC."
(let ((func-name (intern (format "spacemacs/%s" (symbol-name func)))))
`(progn
(defun ,func-name ()
,(format "Wrapper to ensure that `helm' is loaded before calling %s."
(symbol-name func))
(interactive)
(require 'helm)
(call-interactively ',func))
(spacemacs/set-leader-keys ,keys ',func-name))))
(spacemacs||set-helm-key "hL" helm-locate-library)
(spacemacs||set-helm-key "hdm" describe-mode)
;; search functions -----------------------------------------------------------
(spacemacs||set-helm-key "sww" helm-wikipedia-suggest)
(spacemacs||set-helm-key "swg" helm-google-suggest)

View file

@ -1,4 +1,4 @@
;;; helm-spacemacs.el --- Spacemacs layer exploration with `helm'.
;;; helm-spacemacs-help.el --- Spacemacs layer exploration with `helm'.
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; Keywords: helm, spacemacs
@ -33,62 +33,62 @@
(require 'helm-org)
(require 'core-configuration-layer)
(defvar helm-spacemacs-all-layers nil
(defvar helm-spacemacs-help-all-layers nil
"Alist of all configuration layers.")
(defvar helm-spacemacs-all-packages nil
(defvar helm-spacemacs-help-all-packages nil
"Hash table of all packages in all layers.")
;;;###autoload
(define-minor-mode helm-spacemacs-mode
(define-minor-mode helm-spacemacs-help-mode
"Layers discovery with helm interface."
:group 'spacemacs
:global t)
(defun helm-spacemacs//init (&optional arg)
(when (or arg (null helm-spacemacs-all-packages))
(defun helm-spacemacs-help//init (&optional arg)
(when (or arg (null helm-spacemacs-help-all-packages))
(mapc (lambda (layer) (push (configuration-layer/make-layer layer)
helm-spacemacs-all-layers))
helm-spacemacs-help-all-layers))
(configuration-layer/get-layers-list))
(dolist (layer helm-spacemacs-all-layers)
(dolist (layer helm-spacemacs-help-all-layers)
(unless (configuration-layer/layer-usedp (oref layer :name))
(configuration-layer//load-layer-files layer '("funcs.el"
"config.el"))))
(setq helm-spacemacs-all-packages (configuration-layer/get-packages
helm-spacemacs-all-layers))))
(setq helm-spacemacs-help-all-packages (configuration-layer/get-packages
helm-spacemacs-help-all-layers))))
;;;###autoload
(defun helm-spacemacs (arg)
(defun helm-spacemacs-help (arg)
"Layers discovery with helm interface."
(interactive "P")
(helm-spacemacs-mode)
(helm-spacemacs//init arg)
(helm-spacemacs-help-mode)
(helm-spacemacs-help//init arg)
(helm :buffer "*helm: spacemacs*"
:sources `(,(helm-spacemacs//documentation-source)
,(helm-spacemacs//layer-source)
,(helm-spacemacs//package-source)
,(helm-spacemacs//dotspacemacs-source)
,(helm-spacemacs//toggle-source)
,(helm-spacemacs//faq-source))))
:sources `(,(helm-spacemacs-help//documentation-source)
,(helm-spacemacs-help//layer-source)
,(helm-spacemacs-help//package-source)
,(helm-spacemacs-help//dotspacemacs-source)
,(helm-spacemacs-help//toggle-source)
,(helm-spacemacs-help//faq-source))))
;;;###autoload
(defun helm-spacemacs-faq (arg)
(defun helm-spacemacs-help-faq (arg)
"Looking in the FAQ with helm."
(interactive "P")
(helm-spacemacs-mode)
(helm-spacemacs-help-mode)
(helm :buffer "*helm: spacemacs*"
:sources `(,(helm-spacemacs//faq-source))))
:sources `(,(helm-spacemacs-help//faq-source))))
(defun helm-spacemacs//documentation-source ()
(defun helm-spacemacs-help//documentation-source ()
"Construct the helm source for the documentation section."
(helm-build-sync-source "Spacemacs Documentation"
:candidates #'helm-spacemacs//documentation-candidates
:persistent-action #'helm-spacemacs//documentation-action-open-file
:candidates #'helm-spacemacs-help//documentation-candidates
:persistent-action #'helm-spacemacs-help//documentation-action-open-file
:keymap helm-map
:action (helm-make-actions
"Open Documentation" #'helm-spacemacs//documentation-action-open-file)))
"Open Documentation" #'helm-spacemacs-help//documentation-action-open-file)))
(defun helm-spacemacs//documentation-candidates ()
(defun helm-spacemacs-help//documentation-candidates ()
(let (result file-extension)
(dolist (filename (directory-files spacemacs-docs-directory))
(setq file-extension (file-name-extension filename))
@ -127,7 +127,7 @@
`(r . ,r))))
result)))
(defun helm-spacemacs//documentation-action-open-file (candidate)
(defun helm-spacemacs-help//documentation-action-open-file (candidate)
"Open documentation FILE."
(let ((file (if (string= candidate "CONTRIBUTING.org")
;; CONTRIBUTING.org is a special case as it should be at the
@ -148,25 +148,25 @@
(t
(find-file file)))))
(defun helm-spacemacs//layer-source ()
(defun helm-spacemacs-help//layer-source ()
"Construct the helm source for the layer section."
`((name . "Layers")
(candidates . ,(sort (configuration-layer/get-layers-list) 'string<))
(candidate-number-limit)
(keymap . ,helm-spacemacs--layer-map)
(keymap . ,helm-spacemacs-help--layer-map)
(action . (("Open README.org"
. helm-spacemacs//layer-action-open-readme)
. helm-spacemacs-help//layer-action-open-readme)
("Open packages.el"
. helm-spacemacs//layer-action-open-packages)
. helm-spacemacs-help//layer-action-open-packages)
;; TODO remove extensions in 0.106.0
("Open extensions.el"
. helm-spacemacs//layer-action-open-extensions)
. helm-spacemacs-help//layer-action-open-extensions)
("Add Layer"
. helm-spacemacs//layer-action-add-layer)
. helm-spacemacs-help//layer-action-add-layer)
("Open README.org (for editing)"
. helm-spacemacs//layer-action-open-readme-edit)))))
. helm-spacemacs-help//layer-action-open-readme-edit)))))
(defvar helm-spacemacs--layer-map
(defvar helm-spacemacs-help--layer-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "<S-return>") '(lambda () (interactive)
@ -175,18 +175,18 @@
map)
"Keymap for Spacemacs Layers sources")
(defun helm-spacemacs//package-source ()
(defun helm-spacemacs-help//package-source ()
"Construct the helm source for the packages."
`((name . "Packages")
(candidates . ,(helm-spacemacs//package-candidates))
(candidates . ,(helm-spacemacs-help//package-candidates))
(candidate-number-limit)
(action . (("Go to init function"
. helm-spacemacs//package-action-goto-init-func)))))
. helm-spacemacs-help//package-action-goto-init-func)))))
(defun helm-spacemacs//package-candidates ()
(defun helm-spacemacs-help//package-candidates ()
"Return the sorted candidates for package source."
(let (result)
(dolist (pkg helm-spacemacs-all-packages)
(dolist (pkg helm-spacemacs-help-all-packages)
(push (format "%s (%S layer)"
(propertize (symbol-name (oref pkg :name))
'face 'font-lock-type-face)
@ -194,15 +194,15 @@
result))
(sort result 'string<)))
(defun helm-spacemacs//toggle-source ()
(defun helm-spacemacs-help//toggle-source ()
"Construct the helm source for the toggles."
(helm-build-sync-source "Toggles"
:candidates #'helm-spacemacs//toggle-candidates
:persistent-action #'helm-spacemacs//toggle
:candidates #'helm-spacemacs-help//toggle-candidates
:persistent-action #'helm-spacemacs-help//toggle
:keymap helm-map
:action (helm-make-actions "Toggle" #'helm-spacemacs//toggle)))
:action (helm-make-actions "Toggle" #'helm-spacemacs-help//toggle)))
(defun helm-spacemacs//toggle-candidates ()
(defun helm-spacemacs-help//toggle-candidates ()
"Return the sorted candidates for toggle source."
(let (result)
(dolist (toggle spacemacs-toggles)
@ -227,17 +227,17 @@
(setq result (cl-sort result 'string< :key 'car))
result))
(defun helm-spacemacs//dotspacemacs-source ()
(defun helm-spacemacs-help//dotspacemacs-source ()
`((name . "Dotfile")
(candidates . ,(helm-spacemacs//dotspacemacs-candidates))
(candidates . ,(helm-spacemacs-help//dotspacemacs-candidates))
(candidate-number-limit)
(action . (("Go to variable" . helm-spacemacs//go-to-dotfile-variable)))))
(action . (("Go to variable" . helm-spacemacs-help//go-to-dotfile-variable)))))
(defun helm-spacemacs//dotspacemacs-candidates ()
(defun helm-spacemacs-help//dotspacemacs-candidates ()
"Return the sorted candidates for all the dospacemacs variables."
(sort (dotspacemacs/get-variable-string-list) 'string<))
(defun helm-spacemacs//layer-action-open-file (file candidate &optional edit)
(defun helm-spacemacs-help//layer-action-open-file (file candidate &optional edit)
"Open FILE of the passed CANDIDATE. If EDIT is false, open in view mode."
(let ((path (if (and (equalp file "README.org") (equalp candidate "spacemacs"))
;; Readme for spacemacs is in the project root
@ -253,11 +253,11 @@
(spacemacs/view-org-file (concat path file) "^" 'all))
(find-file (concat path file)))))
(defun helm-spacemacs//layer-action-open-readme (candidate)
(defun helm-spacemacs-help//layer-action-open-readme (candidate)
"Open the `README.org' file of the passed CANDIDATE for reading."
(helm-spacemacs//layer-action-open-file "README.org" candidate))
(helm-spacemacs-help//layer-action-open-file "README.org" candidate))
(defun helm-spacemacs//layer-action-add-layer (candidate)
(defun helm-spacemacs-help//layer-action-add-layer (candidate)
"Adds layer to dotspacemacs file and reloads configuration"
(if (configuration-layer/layer-usedp (intern candidate))
(message "Layer already added.")
@ -271,20 +271,19 @@
(save-current-buffer)))
(dotspacemacs/sync-configuration-layers))))
(defun helm-spacemacs//layer-action-open-readme-edit (candidate)
(defun helm-spacemacs-help//layer-action-open-readme-edit (candidate)
"Open the `README.org' file of the passed CANDIDATE for editing."
(helm-spacemacs//layer-action-open-file "README.org" candidate t))
(helm-spacemacs-help//layer-action-open-file "README.org" candidate t))
(defun helm-spacemacs//layer-action-open-packages (candidate)
(defun helm-spacemacs-help//layer-action-open-packages (candidate)
"Open the `packages.el' file of the passed CANDIDATE."
(helm-spacemacs//layer-action-open-file "packages.el" candidate))
(helm-spacemacs-help//layer-action-open-file "packages.el" candidate))
;; TODO remove extensions in 0.106.0
(defun helm-spacemacs//layer-action-open-extensions (candidate)
(defun helm-spacemacs-help//layer-action-open-extensions (candidate)
"Open the `extensions.el' file of the passed CANDIDATE."
(helm-spacemacs//layer-action-open-file "extensions.el" candidate))
(helm-spacemacs-help//layer-action-open-file "extensions.el" candidate))
(defun helm-spacemacs//package-action-goto-init-func (candidate)
(defun helm-spacemacs-help//package-action-goto-init-func (candidate)
"Open the file `packages.el' and go to the init function."
(save-match-data
(string-match "^\\(.+\\)\s(\\(.+\\) layer)$" candidate)
@ -300,13 +299,13 @@
(re-search-forward (format "init-%s" package))
(beginning-of-line))))
(defun helm-spacemacs//toggle (candidate)
(defun helm-spacemacs-help//toggle (candidate)
"Toggle candidate."
(let ((toggle (assq (intern candidate) spacemacs-toggles)))
(when toggle
(funcall (plist-get (cdr toggle) :function)))))
(defun helm-spacemacs//go-to-dotfile-variable (candidate)
(defun helm-spacemacs-help//go-to-dotfile-variable (candidate)
"Go to candidate in the dotfile."
(find-file dotspacemacs-filepath)
(goto-char (point-min))
@ -314,18 +313,18 @@
(re-search-forward (format "^[a-z\s\\(\\-]*%s" candidate))
(beginning-of-line))
(defvar helm-spacemacs--faq-filename
(defvar helm-spacemacs-help--faq-filename
(concat spacemacs-docs-directory "FAQ.org")
"Location of the FAQ file.")
(defun helm-spacemacs//faq-source ()
(defun helm-spacemacs-help//faq-source ()
"Construct the helm source for the FAQ."
`((name . "FAQ")
(candidates . ,(helm-spacemacs//faq-candidates))
(candidates . ,(helm-spacemacs-help//faq-candidates))
(candidate-number-limit)
(action . (("Go to question" . helm-spacemacs//faq-goto-marker)))))
(action . (("Go to question" . helm-spacemacs-help//faq-goto-marker)))))
(defun helm-spacemacs//faq-candidate (cand)
(defun helm-spacemacs-help//faq-candidate (cand)
(let ((str (substring-no-properties (car cand))))
(when (string-match "\\`.*/\\([^/]*\\)/\\(.*\\)\\'" str)
(cons (concat (propertize
@ -334,9 +333,9 @@
": " (match-string 2 str))
(cdr cand)))))
(defun helm-spacemacs//faq-candidates ()
(defun helm-spacemacs-help//faq-candidates ()
(let* ((helm-org-format-outline-path nil)
(cands (helm-org-get-candidates (list helm-spacemacs--faq-filename)))
(cands (helm-org-get-candidates (list helm-spacemacs-help--faq-filename)))
section result)
(dolist (c cands)
(let ((str (substring-no-properties (car c))))
@ -349,12 +348,12 @@
result))))
result))
(defun helm-spacemacs//faq-goto-marker (marker)
(find-file helm-spacemacs--faq-filename)
(defun helm-spacemacs-help//faq-goto-marker (marker)
(find-file helm-spacemacs-help--faq-filename)
(goto-char marker)
(org-show-context)
(org-show-entry))
(provide 'helm-spacemacs)
(provide 'helm-spacemacs-help)
;;; helm-spacemacs.el ends here
;;; helm-spacemacs-help.el ends here

View file

@ -0,0 +1,894 @@
;;; packages.el --- Spacemacs Core Layer packages File
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq spacemacs-helm-packages
'(ace-jump-helm-line
helm
helm-ag
helm-descbinds
helm-flx
helm-make
helm-mode-manager
helm-projectile
helm-swoop
helm-themes
(helm-spacemacs-help :location local)))
;; Initialization of packages
(defun spacemacs-helm/init-ace-jump-helm-line ()
(use-package ace-jump-helm-line
:defer t
:init
(with-eval-after-load 'helm
(define-key helm-map (kbd "C-q") 'ace-jump-helm-line))))
(defun spacemacs-helm/init-helm ()
(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
helm-bookmark-show-location t
helm-display-header-line nil
helm-split-window-in-side-p t
helm-always-two-windows t
helm-echo-input-in-header-line t
helm-imenu-execute-action-at-once-if-one nil
helm-org-format-outline-path t)
;; hide minibuffer in Helm session, since we use the header line already
(defun helm-hide-minibuffer-maybe ()
(when (with-helm-buffer helm-echo-input-in-header-line)
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
(overlay-put ov 'window (selected-window))
(overlay-put ov 'face (let ((bg-color (face-background 'default nil)))
`(:background ,bg-color :foreground ,bg-color)))
(setq-local cursor-type nil))))
(add-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)
;; fuzzy matching setting
(setq helm-M-x-fuzzy-match t
helm-apropos-fuzzy-match t
helm-file-cache-fuzzy-match t
helm-imenu-fuzzy-match t
helm-lisp-fuzzy-completion t
helm-recentf-fuzzy-match t
helm-semantic-fuzzy-match t
helm-buffers-fuzzy-matching t)
;; Use helm to provide :ls, unless ibuffer is used
(unless (configuration-layer/package-usedp 'ibuffer)
(evil-ex-define-cmd "buffers" 'helm-buffers-list))
(defun spacemacs//helm-do-grep-region-or-symbol (&optional targs use-region-or-symbol-p)
"Version of `helm-do-grep' with a default input."
(interactive)
(require 'helm)
(cl-letf*
(((symbol-function 'this-fn) (symbol-function 'helm-do-grep-1))
((symbol-function 'helm-do-grep-1)
(lambda (targets &optional recurse zgrep exts default-input region-or-symbol-p)
(let* ((new-input (when region-or-symbol-p
(if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(thing-at-point 'symbol t))))
(quoted-input (when new-input (rxt-quote-pcre new-input))))
(this-fn targets recurse zgrep exts default-input quoted-input))))
(preselection (or (dired-get-filename nil t)
(buffer-file-name (current-buffer))))
(targets (if targs
targs
(helm-read-file-name
"Search in file(s): "
:marked-candidates t
:preselect (if helm-ff-transformer-show-only-basename
(helm-basename preselection)
preselection)))))
(helm-do-grep-1 targets nil nil nil nil use-region-or-symbol-p)))
(defun spacemacs/helm-file-do-grep ()
"Search in current file with `grep' using a default input."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol
(list (buffer-file-name (current-buffer))) nil))
(defun spacemacs/helm-file-do-grep-region-or-symbol ()
"Search in current file with `grep' using a default input."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol
(list (buffer-file-name (current-buffer))) t))
(defun spacemacs/helm-files-do-grep ()
"Search in files with `grep'."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol nil nil))
(defun spacemacs/helm-files-do-grep-region-or-symbol ()
"Search in files with `grep' using a default input."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol nil t))
(defun spacemacs/helm-buffers-do-grep ()
"Search in opened buffers with `grep'."
(interactive)
(let ((buffers (cl-loop for buffer in (buffer-list)
when (buffer-file-name buffer)
collect (buffer-file-name buffer))))
(spacemacs//helm-do-grep-region-or-symbol buffers nil)))
(defun spacemacs/helm-buffers-do-grep-region-or-symbol ()
"Search in opened buffers with `grep' with a default input."
(interactive)
(let ((buffers (cl-loop for buffer in (buffer-list)
when (buffer-file-name buffer)
collect (buffer-file-name buffer))))
(spacemacs//helm-do-grep-region-or-symbol buffers t)))
(defun spacemacs/last-search-buffer ()
"open last helm-ag or hgrep buffer."
(interactive)
(cond ((get-buffer "*helm ag results*")
(switch-to-buffer-other-window "*helm ag results*"))
((get-buffer "*helm-ag*")
(helm-resume "*helm-ag*"))
((get-buffer "*hgrep*")
(switch-to-buffer-other-window "*hgrep*"))
(t
(message "No previous search buffer found"))))
(defun spacemacs/helm-faces ()
"Describe face."
(interactive)
(require 'helm-elisp)
(let ((default (or (face-at-point) (thing-at-point 'symbol))))
(helm :sources (helm-def-source--emacs-faces
(format "%s" (or default "default")))
:buffer "*helm faces*")))
;; use helm by default for M-x
(unless (configuration-layer/package-usedp 'smex)
(global-set-key (kbd "M-x") 'helm-M-x))
(spacemacs/set-leader-keys
"<f1>" 'helm-apropos
"bb" 'helm-mini
"Cl" 'helm-colors
"ff" 'spacemacs/helm-find-files
"fF" 'helm-find-files
"fL" 'helm-locate
"fr" 'helm-recentf
"hb" 'helm-filtered-bookmarks
"hdF" 'spacemacs/helm-faces
"hi" 'helm-info-at-point
"hl" 'helm-resume
"hm" 'helm-man-woman
"iu" 'helm-ucs
"jI" 'helm-imenu-in-all-buffers
"ry" 'helm-show-kill-ring
"rr" 'helm-register
"rm" 'helm-all-mark-rings
"sl" 'spacemacs/last-search-buffer
"sj" 'spacemacs/jump-in-buffer)
;; search with grep
(spacemacs/set-leader-keys
"sgb" 'spacemacs/helm-buffers-do-grep
"sgB" 'spacemacs/helm-buffers-do-grep-region-or-symbol
"sgf" 'spacemacs/helm-files-do-grep
"sgF" 'spacemacs/helm-files-do-grep-region-or-symbol
"sgg" 'spacemacs/helm-file-do-grep
"sgG" 'spacemacs/helm-file-do-grep-region-or-symbol)
;; define the key binding at the very end in order to allow the user
;; to overwrite any key binding
(add-hook 'emacs-startup-hook
(lambda ()
(unless (configuration-layer/package-usedp 'smex)
(spacemacs/set-leader-keys
dotspacemacs-emacs-command-key 'helm-M-x))))
(defun spacemacs//hide-cursor-in-helm-buffer ()
"Hide the cursor in helm buffers."
(with-helm-buffer
(setq cursor-in-non-selected-windows nil)))
(add-hook 'helm-after-initialize-hook 'spacemacs//hide-cursor-in-helm-buffer)
(defvar spacemacs-helm-display-help-buffer-regexp '("*.*Helm.*Help.**"))
(defvar spacemacs-helm-display-buffer-regexp `("*.*helm.**"
(display-buffer-in-side-window)
(inhibit-same-window . t)
(side . ,dotspacemacs-helm-position)
(window-width . 0.6)
(window-height . 0.4)))
(defvar spacemacs-display-buffer-alist nil)
(defun spacemacs//helm-prepare-display ()
"Prepare necessary settings to make Helm display properly."
;; avoid Helm buffer being diplaye twice when user
;; sets this variable to some function that pop buffer to
;; a window. See https://github.com/syl20bnr/spacemacs/issues/1396
(let ((display-buffer-base-action '(nil)))
(setq spacemacs-display-buffer-alist display-buffer-alist)
;; the only buffer to display is Helm, nothing else we must set this
;; otherwise Helm cannot reuse its own windows for copyinng/deleting
;; etc... because of existing popwin buffers in the alist
(setq display-buffer-alist nil)
(popwin-mode -1)
;; workaround for a helm-evil incompatibility
;; see https://github.com/syl20bnr/spacemacs/issues/3700
(when helm-prevent-escaping-from-minibuffer
(define-key evil-motion-state-map [down-mouse-1] nil))))
(defun spacemacs//display-helm-window (buffer)
(let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
;; this or any specialized case of Helm buffer must be added AFTER
;; `spacemacs-helm-display-buffer-regexp'. Otherwise,
;; `spacemacs-helm-display-buffer-regexp' will be used before
;; `spacemacs-helm-display-help-buffer-regexp' and display
;; configuration for normal Helm buffer is applied for helm help
;; buffer, making the help buffer unable to be displayed.
spacemacs-helm-display-buffer-regexp)))
(helm-default-display-buffer buffer)))
(setq helm-display-function 'spacemacs//display-helm-window)
(defun spacemacs//restore-previous-display-config ()
;; workaround for a helm-evil incompatibility
;; see https://github.com/syl20bnr/spacemacs/issues/3700
(when helm-prevent-escaping-from-minibuffer
(define-key evil-motion-state-map [down-mouse-1] 'evil-mouse-drag-region))
(popwin-mode 1)
;; we must enable popwin-mode first then restore `display-buffer-alist'
;; Otherwise, popwin keeps adding up its own buffers to `display-buffer-alist'
;; and could slow down Emacs as the list grows
(setq display-buffer-alist spacemacs-display-buffer-alist))
(add-hook 'helm-after-initialize-hook 'spacemacs//helm-prepare-display)
;; Restore popwin-mode after a Helm session finishes.
(add-hook 'helm-cleanup-hook 'spacemacs//restore-previous-display-config)
;; Add minibuffer history with `helm-minibuffer-history'
(define-key minibuffer-local-map (kbd "C-c C-l") 'helm-minibuffer-history)
(defun spacemacs//helm-cleanup ()
"Cleanup some helm related states when quitting."
;; deactivate any running transient map (micro-state)
(setq overriding-terminal-local-map nil))
(add-hook 'helm-cleanup-hook 'spacemacs//helm-cleanup)
(defface spacemacs-helm-navigation-ms-face
`((t :background ,(face-attribute 'error :foreground) :foreground "black"))
"Face for helm heder when helm micro-state is activated."
:group 'spacemacs))
:config
(progn
(helm-mode +1)
;; helm-locate uses es (from everything on windows, which doesnt like fuzzy)
(helm-locate-set-command)
(setq helm-locate-fuzzy-match (string-match "locate" helm-locate-command))
(defun spacemacs//set-dotted-directory ()
"Set the face of diretories for `.' and `..'"
(set-face-attribute 'helm-ff-dotted-directory
nil
:foreground nil
:background nil
:inherit 'helm-ff-directory))
(add-hook 'helm-find-files-before-init-hook 'spacemacs//set-dotted-directory)
;; alter helm-bookmark key bindings to be simpler
(defun simpler-helm-bookmark-keybindings ()
(define-key helm-bookmark-map (kbd "C-d") 'helm-bookmark-run-delete)
(define-key helm-bookmark-map (kbd "C-e") 'helm-bookmark-run-edit)
(define-key helm-bookmark-map (kbd "C-f") 'helm-bookmark-toggle-filename)
(define-key helm-bookmark-map (kbd "C-o") 'helm-bookmark-run-jump-other-window)
(define-key helm-bookmark-map (kbd "C-/") 'helm-bookmark-help))
(add-hook 'helm-mode-hook 'simpler-helm-bookmark-keybindings)
;; helm navigation on hjkl
(defun spacemacs//helm-hjkl-navigation (&optional arg)
"Set navigation in helm on `jklh'.
ARG non nil means that the editing style is `vim'."
(cond
(arg
;; better navigation on homerow
;; rebind `describe-key' for convenience
(define-key helm-map (kbd "C-j") 'helm-next-line)
(define-key helm-map (kbd "C-k") 'helm-previous-line)
(define-key helm-map (kbd "C-h") 'helm-next-source)
(define-key helm-map (kbd "C-S-h") 'describe-key)
(define-key helm-map (kbd "C-l") (kbd "RET"))
(dolist (keymap (list helm-find-files-map helm-read-file-map))
(define-key keymap (kbd "C-l") 'helm-execute-persistent-action)
(define-key keymap (kbd "C-h") 'helm-find-files-up-one-level)
(define-key keymap (kbd "C-S-h") 'describe-key)))
(t
(define-key helm-map (kbd "C-j") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-k") 'helm-delete-minibuffer-contents)
(define-key helm-map (kbd "C-h") nil)
(define-key helm-map (kbd "C-l") 'helm-recenter-top-bottom-other-window))))
(spacemacs//hjkl-completion-navigation)
(defun spacemacs/helm-edit ()
"Switch in edit mode depending on the current helm buffer."
(interactive)
(cond
((string-equal "*helm-ag*" helm-buffer)
(helm-ag-edit))))
(defun spacemacs//helm-navigation-ms-on-enter ()
"Initialization of helm micro-state."
;; faces
(spacemacs//helm-navigation-ms-set-face)
(setq spacemacs--helm-navigation-ms-face-cookie-minibuffer
(face-remap-add-relative
'minibuffer-prompt
'spacemacs-helm-navigation-ms-face)))
(defun spacemacs//helm-navigation-ms-set-face ()
"Set the face for helm header in helm navigation micro-state"
(with-helm-window
(setq spacemacs--helm-navigation-ms-face-cookie-header
(face-remap-add-relative
'helm-header
'spacemacs-helm-navigation-ms-face))))
(defun spacemacs//helm-navigation-ms-on-exit ()
"Action to perform when exiting helm micro-state."
(with-helm-window
(face-remap-remove-relative
spacemacs--helm-navigation-ms-face-cookie-header))
(face-remap-remove-relative
spacemacs--helm-navigation-ms-face-cookie-minibuffer))
(defun spacemacs//helm-navigation-ms-full-doc ()
"Full documentation for helm navigation micro-state."
"
[?] display this help
[a] toggle action selection page
[e] edit occurrences if supported
[j] [k] next/previous candidate
[h] [l] previous/next source
[t] toggle visible mark
[T] toggle all mark
[v] persistent action
[q] quit")
;; Define functions to pick actions
(dotimes (n 10)
(let ((func (intern (format "spacemacs/helm-action-%d" n)))
(doc (format "Select helm action #%d" n)))
(eval `(defun ,func ()
,doc
(intern)
(helm-select-nth-action ,(1- n))))))
(spacemacs|define-micro-state helm-navigation
:persistent t
:disable-evil-leader t
:define-key (helm-map . "M-SPC") (helm-map . "s-M-SPC")
:on-enter (spacemacs//helm-navigation-ms-on-enter)
:on-exit (spacemacs//helm-navigation-ms-on-exit)
:bindings
("1" spacemacs/helm-action-1 :exit t)
("2" spacemacs/helm-action-2 :exit t)
("3" spacemacs/helm-action-3 :exit t)
("4" spacemacs/helm-action-4 :exit t)
("5" spacemacs/helm-action-5 :exit t)
("6" spacemacs/helm-action-6 :exit t)
("7" spacemacs/helm-action-7 :exit t)
("8" spacemacs/helm-action-8 :exit t)
("9" spacemacs/helm-action-9 :exit t)
("0" spacemacs/helm-action-10 :exit t)
("<tab>" helm-select-action :exit t)
("TAB" helm-select-action :exit t)
("<RET>" helm-maybe-exit-minibuffer :exit t)
("?" nil :doc (spacemacs//helm-navigation-ms-full-doc))
("a" helm-select-action :post (spacemacs//helm-navigation-ms-set-face))
("e" spacemacs/helm-edit)
("g" helm-beginning-of-buffer)
("G" helm-end-of-buffer)
("h" helm-previous-source)
("j" helm-next-line)
("k" helm-previous-line)
("l" helm-next-source)
("q" nil :exit t)
("t" helm-toggle-visible-mark)
("T" helm-toggle-all-marks)
("v" helm-execute-persistent-action))
;; Swap default TAB and C-z commands.
;; For GUI.
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-find-files-map (kbd "S-<tab>") 'helm-find-files-up-one-level)
(define-key helm-find-files-map (kbd "<backtab>") 'helm-find-files-up-one-level)
;; For terminal.
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
(define-key helm-find-files-map (kbd "S-TAB") 'helm-find-files-up-one-level)
(define-key helm-map (kbd "C-z") 'helm-select-action)
(with-eval-after-load 'helm-mode ; required
(spacemacs|hide-lighter helm-mode)))))
(defun spacemacs-helm/init-helm-ag ()
(use-package helm-ag
:defer t
:init
(progn
(defun spacemacs//helm-do-ag-region-or-symbol (func &optional dir)
"Search with `ag' with a default input."
(require 'helm-ag)
(cl-letf* (((symbol-value 'helm-ag-insert-at-point) 'symbol)
;; make thing-at-point choosing the active region first
((symbol-function 'this-fn) (symbol-function 'thing-at-point))
((symbol-function 'thing-at-point)
(lambda (thing)
(let ((res (if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(this-fn thing))))
(when res (rxt-quote-pcre res))))))
(funcall func dir)))
(defun spacemacs//helm-do-search-find-tool (base tools default-inputp)
"Create a cond form given a TOOLS string list and evaluate it."
(eval
`(cond
,@(mapcar
(lambda (x)
`((executable-find ,x)
',(let ((func
(intern
(format (if default-inputp
"spacemacs/%s-%s-region-or-symbol"
"spacemacs/%s-%s")
base x))))
(if (fboundp func)
func
(intern (format "%s-%s" base x))))))
tools)
(t 'helm-do-grep))))
;; Search in current file ----------------------------------------------
(defun spacemacs/helm-file-do-ag (&optional _)
"Wrapper to execute `helm-ag-this-file.'"
(interactive)
(helm-ag-this-file))
(defun spacemacs/helm-file-do-ag-region-or-symbol ()
"Search in current file with `ag' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-file-do-ag))
(defun spacemacs/helm-file-smart-do-search (&optional default-inputp)
"Search in current file using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-file-do"
dotspacemacs-search-tools
default-inputp)))
(defun spacemacs/helm-file-smart-do-search-region-or-symbol ()
"Search in current file using `dotspacemacs-search-tools' with
default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-file-smart-do-search t))
;; Search in files -----------------------------------------------------
(defun spacemacs/helm-files-do-ag (&optional dir)
"Search in files with `ag' using a default input."
(interactive)
(helm-do-ag dir))
(defun spacemacs/helm-files-do-ag-region-or-symbol ()
"Search in files with `ag' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ag))
(defun spacemacs/helm-files-do-ack (&optional dir)
"Search in files with `ack'."
(interactive)
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
(helm-do-ag dir)))
(defun spacemacs/helm-files-do-ack-region-or-symbol ()
"Search in files with `ack' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack))
(defun spacemacs/helm-files-do-pt (&optional dir)
"Search in files with `pt'."
(interactive)
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
(helm-do-ag dir)))
(defun spacemacs/helm-files-do-pt-region-or-symbol ()
"Search in files with `pt' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt))
(defun spacemacs/helm-files-smart-do-search (&optional default-inputp)
"Search in opened buffers using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-files-do"
dotspacemacs-search-tools
default-inputp)))
(defun spacemacs/helm-files-smart-do-search-region-or-symbol ()
"Search in opened buffers using `dotspacemacs-search-tools'.
with default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-files-smart-do-search t))
;; Search in buffers ---------------------------------------------------
(defun spacemacs/helm-buffers-do-ag (&optional _)
"Wrapper to execute `helm-ag-buffers.'"
(interactive)
(helm-do-ag-buffers))
(defun spacemacs/helm-buffers-do-ag-region-or-symbol ()
"Search in opened buffers with `ag' with a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ag))
(defun spacemacs/helm-buffers-do-ack (&optional _)
"Search in opened buffers with `ack'."
(interactive)
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
(helm-do-ag-buffers)))
(defun spacemacs/helm-buffers-do-ack-region-or-symbol ()
"Search in opened buffers with `ack' with a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ack))
(defun spacemacs/helm-buffers-do-pt (&optional _)
"Search in opened buffers with `pt'."
(interactive)
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
(helm-do-ag-buffers)))
(defun spacemacs/helm-buffers-do-pt-region-or-symbol ()
"Search in opened buffers with `pt' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-pt))
(defun spacemacs/helm-buffers-smart-do-search (&optional default-inputp)
"Search in opened buffers using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-buffers-do"
dotspacemacs-search-tools
default-inputp)))
(defun spacemacs/helm-buffers-smart-do-search-region-or-symbol ()
"Search in opened buffers using `dotspacemacs-search-tools' with
default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-buffers-smart-do-search t))
;; Search in project ---------------------------------------------------
(defun spacemacs/helm-project-do-ag ()
"Search in current project with `ag'."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(helm-do-ag dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-ag-region-or-symbol ()
"Search in current project with `ag' using a default input."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs//helm-do-ag-region-or-symbol 'helm-do-ag dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-ack ()
"Search in current project with `ack'."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs/helm-files-do-ack dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-ack-region-or-symbol ()
"Search in current project with `ack' using a default input."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-pt ()
"Search in current project with `pt'."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs/helm-files-do-pt dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-pt-region-or-symbol ()
"Search in current project with `pt' using a default input."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-smart-do-search (&optional default-inputp)
"Search in current project using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(let ((projectile-require-project-root nil))
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-project-do"
dotspacemacs-search-tools
default-inputp))))
(defun spacemacs/helm-project-smart-do-search-region-or-symbol ()
"Search in current project using `dotspacemacs-search-tools' with
default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-project-smart-do-search t))
;; This overrides the default C-s action in helm-projectile-switch-project
;; to search using ag/pt/whatever instead of just grep
(with-eval-after-load 'helm-projectile
(defun spacemacs/helm-project-smart-do-search-in-dir (dir)
(interactive)
(let ((default-directory dir))
(spacemacs/helm-project-smart-do-search)))
(define-key helm-projectile-projects-map
(kbd "C-s")
(lambda ()
(interactive)
(helm-exit-and-execute-action 'spacemacs/helm-project-smart-do-search-in-dir))))
;; evilify the helm-grep buffer
(evilified-state-evilify helm-grep-mode helm-grep-mode-map
(kbd "RET") 'helm-grep-mode-jump-other-window
(kbd "q") 'quit-window)
(spacemacs/set-leader-keys
;; helm-ag marks
"s`" 'helm-ag-pop-stack
;; opened buffers scope
"sb" 'spacemacs/helm-buffers-smart-do-search
"sB" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
"sab" 'helm-do-ag-buffers
"saB" 'spacemacs/helm-buffers-do-ag-region-or-symbol
"skb" 'spacemacs/helm-buffers-do-ack
"skB" 'spacemacs/helm-buffers-do-ack-region-or-symbol
"stb" 'spacemacs/helm-buffers-do-pt
"stB" 'spacemacs/helm-buffers-do-pt-region-or-symbol
;; current file scope
"ss" 'spacemacs/helm-file-smart-do-search
"sS" 'spacemacs/helm-file-smart-do-search-region-or-symbol
"saa" 'helm-ag-this-file
"saA" 'spacemacs/helm-file-do-ag-region-or-symbol
;; files scope
"sf" 'spacemacs/helm-files-smart-do-search
"sF" 'spacemacs/helm-files-smart-do-search-region-or-symbol
"saf" 'helm-do-ag
"saF" 'spacemacs/helm-files-do-ag-region-or-symbol
"skf" 'spacemacs/helm-files-do-ack
"skF" 'spacemacs/helm-files-do-ack-region-or-symbol
"stf" 'spacemacs/helm-files-do-pt
"stF" 'spacemacs/helm-files-do-pt-region-or-symbol
;; current project scope
"/" 'spacemacs/helm-project-smart-do-search
"*" 'spacemacs/helm-project-smart-do-search-region-or-symbol
"sp" 'spacemacs/helm-project-smart-do-search
"sP" 'spacemacs/helm-project-smart-do-search-region-or-symbol
"sap" 'spacemacs/helm-project-do-ag
"saP" 'spacemacs/helm-project-do-ag-region-or-symbol
"skp" 'spacemacs/helm-project-do-ack
"skP" 'spacemacs/helm-project-do-ack-region-or-symbol
"stp" 'spacemacs/helm-project-do-pt
"stP" 'spacemacs/helm-project-do-pt-region-or-symbol))
:config
(progn
(evil-define-key 'normal helm-ag-map "SPC" spacemacs-default-map)
(evilified-state-evilify helm-ag-mode helm-ag-mode-map
(kbd "RET") 'helm-ag-mode-jump-other-window
(kbd "q") 'quit-window))))
(defun spacemacs-helm/init-helm-descbinds ()
(use-package helm-descbinds
:defer t
:init
(progn
(setq helm-descbinds-window-style 'split)
(add-hook 'helm-mode-hook 'helm-descbinds-mode)
(spacemacs/set-leader-keys "?" 'helm-descbinds))))
(defun spacemacs-helm/init-helm-flx ()
(use-package helm-flx
:defer t)
(spacemacs|use-package-add-hook helm
:pre-config
(progn
;; Disable for helm-find-files until performance issues are sorted
;; https://github.com/PythonNut/helm-flx/issues/9
(setq helm-flx-for-helm-find-files nil)
(helm-flx-mode))))
(defun spacemacs-helm/init-helm-make ()
(use-package helm-make
:defer t
:init
(spacemacs/set-leader-keys
"cc" 'helm-make-projectile
"cm" 'helm-make)))
(defun spacemacs-helm/init-helm-mode-manager ()
(use-package helm-mode-manager
:defer t
:init
(spacemacs/set-leader-keys
"hM" 'helm-switch-major-mode
;; "hm" 'helm-disable-minor-mode
"h C-m" 'helm-enable-minor-mode)))
(defun spacemacs-helm/init-helm-projectile ()
(use-package helm-projectile
:commands (helm-projectile-switch-to-buffer
helm-projectile-find-dir
helm-projectile-dired-find-dir
helm-projectile-recentf
helm-projectile-find-file
helm-projectile-grep
helm-projectile
helm-projectile-switch-project)
:init
(progn
(setq projectile-switch-project-action 'helm-projectile)
(defconst spacemacs-use-helm-projectile t
"This variable is only defined if helm-projectile is used.")
;; needed for smart search if user's default tool is grep
(defalias 'spacemacs/helm-project-do-grep 'helm-projectile-grep)
(defalias
'spacemacs/helm-project-do-grep-region-or-symbol 'helm-projectile-grep)
(spacemacs/set-leader-keys
"pb" 'helm-projectile-switch-to-buffer
"pd" 'helm-projectile-find-dir
"pf" 'helm-projectile-find-file
"ph" 'helm-projectile
"pp" 'helm-projectile-switch-project
"pr" 'helm-projectile-recentf
"pv" 'projectile-vc
"sgp" 'helm-projectile-grep))))
(defun spacemacs-helm/init-helm-spacemacs-help ()
(use-package helm-spacemacs-help
:commands (helm-spacemacs-help helm-spacemacs-help-faq)
:init
(progn
(defun spacemacs-base/helm-spacemacs-deprecated (arg)
"Provide helm-spacemacs with a binding's depreciation message."
(interactive "P")
(warn "The 'SPC f e h' (or 'M-m f e h') binding is now deprecated and will be remove in the next release. Please use 'SPC h SPC' (or 'M-m h SPC') instead.")
(helm-spacemacs arg))
(spacemacs/set-leader-keys "feh" 'spacemacs-base/helm-spacemacs-deprecated)
(spacemacs/set-leader-keys "fef" 'helm-spacemacs-faq)
(spacemacs/set-leader-keys "h SPC" 'helm-spacemacs))))
(defun spacemacs-helm/init-helm-swoop ()
(use-package helm-swoop
:defer t
:init
(progn
(setq helm-swoop-split-with-multiple-windows t
helm-swoop-split-direction 'split-window-vertically
helm-swoop-speed-or-color t
helm-swoop-split-window-function 'helm-default-display-buffer
helm-swoop-pre-input-function (lambda () ""))
(defun spacemacs/helm-swoop-region-or-symbol ()
"Call `helm-swoop' with default input."
(interactive)
(let ((helm-swoop-pre-input-function
(lambda ()
(if (region-active-p)
(buffer-substring-no-properties (region-beginning)
(region-end))
(let ((thing (thing-at-point 'symbol t)))
(if thing thing ""))))))
(call-interactively 'helm-swoop)))
(spacemacs/set-leader-keys
"ss" 'helm-swoop
"sS" 'spacemacs/helm-swoop-region-or-symbol
"s C-s" 'helm-multi-swoop-all)
(defadvice helm-swoop (before add-evil-jump activate)
(when (configuration-layer/package-usedp 'evil-jumper)
(evil-set-jump))))))
(defun spacemacs-helm/init-helm-themes ()
(use-package helm-themes
:defer t
:init
(spacemacs/set-leader-keys
"Th" 'helm-themes)))

View file

@ -0,0 +1,353 @@
;;; ivy-spacemacs-help.el --- Spacemacs layer exploration with `ivy'.
;; Author: Justin Burkett <justin@burkett.cc>
;; Keywords: ivy, spacemacs
;; Version: 0.1
;; Package-Requires: ((ivy "0.7"))
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This package adds a convenient way to discover Spacemacs configuration
;; layers thanks to ivy.
;;; Code:
(require 'cl)
(require 'ht)
(require 'ivy)
(require 'core-configuration-layer)
(defvar ivy-spacemacs-help-all-layers nil
"Alist of all configuration layers.")
(defvar ivy-spacemacs-help-all-packages nil
"Hash table of all packages in all layers.")
(defun ivy-spacemacs-help//init (&optional arg)
(when (or arg (null ivy-spacemacs-help-all-packages))
(mapc (lambda (layer) (push (configuration-layer/make-layer layer)
ivy-spacemacs-help-all-layers))
(configuration-layer/get-layers-list))
(dolist (layer ivy-spacemacs-help-all-layers)
(unless (configuration-layer/layer-usedp (oref layer :name))
(configuration-layer//load-layer-files layer '("funcs.el"
"config.el"))))
(setq ivy-spacemacs-help-all-packages (configuration-layer/get-packages
ivy-spacemacs-help-all-layers))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Docs
(defun ivy-spacemacs-help//documentation-candidates ()
(let (result file-extension)
(dolist (filename (directory-files spacemacs-docs-directory))
(setq file-extension (file-name-extension filename))
(when (or (equal file-extension "md")
(equal file-extension "org"))
(push filename result)))
;; CONTRIBUTING.org is a special case as it should be at the root of the
;; repository to be linked as the contributing guide on Github.
(push "CONTRIBUTING.org" result)
;; delete DOCUMENTATION.org to make it the first guide
(delete "DOCUMENTATION.org" result)
(push "DOCUMENTATION.org" result)
;; give each document an appropriate title
(mapcar (lambda (r)
(cond
((string-equal r "CONTRIBUTING.org")
`("How to contribute to Spacemacs" . ,r))
((string-equal r "CONVENTIONS.org")
`("Spacemacs conventions" . ,r))
((string-equal r "DOCUMENTATION.org")
`("Spacemacs documentation" . ,r))
((string-equal r "FAQ.org")
`("Spacemacs FAQ" . ,r))
((string-equal r "HOWTOs.org")
`("Quick HOW-TOs for Spacemacs" . ,r))
((string-equal r "LAYERS.org")
`("Tips on writing layers for Spacemacs" . ,r))
((string-equal r "QUICK_START.org")
`("Quick start guide for Spacemacs" . ,r))
((string-equal r "VIMUSERS.org")
`("Vim users migration guide" . ,r))
(t
`(r . ,r))))
result)))
(defun ivy-spacemacs-help//documentation-action-open-file (candidate)
"Open documentation FILE."
(let ((file (if (string= candidate "CONTRIBUTING.org")
;; CONTRIBUTING.org is a special case as it should be at the
;; root of the repository to be linked as the contributing
;; guide on Github.
(concat user-emacs-directory candidate)
(concat spacemacs-docs-directory candidate))))
(cond ((equal (file-name-extension file) "md")
(condition-case nil
(with-current-buffer (find-file-noselect file)
(gh-md-render-buffer)
(kill-this-buffer))
;; if anything fails, fall back to simply open file
(find-file file)))
((equal (file-name-extension file) "org")
(spacemacs/view-org-file file "^" 'all))
(t
(find-file file)))))
;;;###autoload
(defun ivy-spacemacs-help-docs (arg)
(interactive "P")
(ivy-spacemacs-help//init arg)
(ivy-read "Spacemacs Documentation: "
(ivy-spacemacs-help//documentation-candidates)
:action #'ivy-spacemacs-help//documentation-action-open-file))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Layers
(defun ivy-spacemacs-help//layer-candidates ()
(sort (mapcar 'symbol-name (configuration-layer/get-layers-list))
'string<))
(defun ivy-spacemacs-help//layer-action-open-file (file candidate &optional edit)
"Open FILE of the passed CANDIDATE. If EDIT is false, open in view mode."
(let ((path (if (and (equalp file "README.org") (equalp candidate "spacemacs"))
;; Readme for spacemacs is in the project root
(ht-get configuration-layer-paths (intern candidate))
(file-name-as-directory
(concat (ht-get configuration-layer-paths
(intern candidate))
candidate)))))
(if (equal (file-name-extension file) "org")
(if edit
(find-file (concat path file))
(spacemacs/view-org-file (concat path file) "^" 'all))
(find-file (concat path file)))))
(defun ivy-spacemacs-help//layer-action-open-readme (candidate)
"Open the `README.org' file of the passed CANDIDATE for reading."
(ivy-spacemacs-help//layer-action-open-file "README.org" candidate))
(defun ivy-spacemacs-help//layer-action-add-layer (candidate)
"Adds layer to dotspacemacs file and reloads configuration"
(if (configuration-layer/layer-usedp (intern candidate))
(message "Layer already added.")
(let ((dotspacemacs (find-file-noselect (dotspacemacs/location))))
(with-current-buffer dotspacemacs
(beginning-of-buffer)
(let ((insert-point (re-search-forward
"dotspacemacs-configuration-layers *\n?.*\\((\\)")))
(insert (format "\n%s\n" candidate))
(indent-region insert-point (+ insert-point (length candidate)))
(save-current-buffer)))
(dotspacemacs/sync-configuration-layers))))
(defun ivy-spacemacs-help//layer-action-open-readme-edit (candidate)
"Open the `README.org' file of the passed CANDIDATE for editing."
(ivy-spacemacs-help//layer-action-open-file "README.org" candidate t))
(defun ivy-spacemacs-help//layer-action-open-packages (candidate)
"Open the `packages.el' file of the passed CANDIDATE."
(ivy-spacemacs-help//layer-action-open-file "packages.el" candidate))
;; TODO remove extensions in 0.105.0
(defun ivy-spacemacs-help//layer-action-open-extensions (candidate)
"Open the `extensions.el' file of the passed CANDIDATE."
(ivy-spacemacs-help//layer-action-open-file "extensions.el" candidate))
;;;###autoload
(defun ivy-spacemacs-help-layers ()
(interactive)
(ivy-spacemacs-help//init)
(ivy-read "Spacemacs Layers: "
(ivy-spacemacs-help//layer-candidates)
:action 'ivy-spacemacs-help//layer-action-open-readme
:caller 'ivy-spacemacs-help-layers))
(ivy-set-actions
'ivy-spacemacs-help-layers
'(("a" ivy-spacemacs-help//layer-action-add-layer "add layer")
("e" ivy-spacemacs-help//layer-action-open-readme-edit "add readme for editing")
("p" ivy-spacemacs-help//layer-action-open-packages "open packages.el")
("r" ivy-spacemacs-help//layer-action-open-readme "open readme")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Layers and packages
(defun ivy-spacemacs-help//help-candidates ()
"Return the sorted candidates for package source."
(let (result
(left-column-width
(number-to-string
(cl-reduce
(lambda (a x) (max (length (symbol-name (oref x :name))) a))
ivy-spacemacs-help-all-layers :initial-value 0))))
(dolist (pkg ivy-spacemacs-help-all-packages)
(push (list (format (concat "%-" left-column-width "S %s %s")
(oref pkg :owner)
(propertize (symbol-name (oref pkg :name))
'face 'font-lock-type-face)
(propertize
(if (package-installed-p (oref pkg :name))
"[installed]" "")
'face 'font-lock-comment-face))
(symbol-name (oref pkg :owner))
(symbol-name (oref pkg :name)))
result))
(sort result (lambda (a b) (string< (car a) (car b))))))
(defun ivy-spacemacs-help//help-action (args)
"Open the file `packages.el' and go to the init function."
(let* ((layer-str (car args))
(layer-sym (intern layer-str))
(package-str (cadr args))
(path (file-name-as-directory
(concat (ht-get configuration-layer-paths layer-sym)
layer-str)))
(filename (concat path "packages.el")))
(find-file filename)
(goto-char (point-min))
(re-search-forward (format "init-%s" package-str))
(beginning-of-line)))
(defun ivy-spacemacs-help//help-action-add-layer (args)
(let* ((layer-str (car args))
(layer-sym (intern layer-str))
(package-str (cadr args))
(path (file-name-as-directory
(concat (ht-get configuration-layer-paths layer-sym)
layer-str)))
(filename (concat path "packages.el")))
(find-file filename)
(goto-char (point-min))
(re-search-forward (format "init-%s" package-str))
(beginning-of-line)))
(defun ivy-spacemacs-help//help-action-open-packages (args)
"Open the `packages.el' file of the passed CANDIDATE."
(ivy-spacemacs-help//layer-action-open-file "packages.el" (car args)))
(defun ivy-spacemacs-help//help-action-open-readme (args)
"Open the `README.org' file of the passed CANDIDATE for reading."
(ivy-spacemacs-help//layer-action-open-file "README.org" (car args)))
(defun ivy-spacemacs-help//help-action-open-readme-edit (args)
"Open the `README.org' file of the passed CANDIDATE for editing."
(ivy-spacemacs-help//layer-action-open-file "README.org" (car args) t))
(defun ivy-spacemacs-help//help-action-add-layer (args)
"Adds layer to dotspacemacs file and reloads configuration"
(if (configuration-layer/layer-usedp (intern (car args)))
(message "Layer already added.")
(let ((dotspacemacs (find-file-noselect (dotspacemacs/location))))
(with-current-buffer dotspacemacs
(beginning-of-buffer)
(let ((insert-point (re-search-forward
"dotspacemacs-configuration-layers *\n?.*\\((\\)")))
(insert (format "\n%s\n" (car args)))
(indent-region insert-point (+ insert-point (length (car args))))
(save-current-buffer)))
(dotspacemacs/sync-configuration-layers))))
;;;###autoload
(defun ivy-spacemacs-help ()
(interactive)
(ivy-spacemacs-help//init)
(ivy-read "Spacemacs Layers and Packages: "
(ivy-spacemacs-help//help-candidates)
:action 'ivy-spacemacs-help//help-action
:caller 'ivy-spacemacs-help))
(ivy-set-actions
'ivy-spacemacs-help
'(("a" ivy-spacemacs-help//help-action-add-layer "add layer")
("e" ivy-spacemacs-help//help-action-open-readme-edit "add readme for editing")
("p" ivy-spacemacs-help//help-action-open-packages "open packages.el")
("r" ivy-spacemacs-help//help-action-open-readme "open readme")))
;;;###autoload
(defalias 'ivy-spacemacs-help-packages 'ivy-spacemacs-help)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Toggles
(defun ivy-spacemacs-help//toggle-candidates ()
"Return the sorted candidates for toggle source."
(let (result)
(dolist (toggle spacemacs-toggles)
(let* ((toggle-symbol (symbol-name (car toggle)))
(toggle-name (capitalize (replace-regexp-in-string "-" " " toggle-symbol)))
(toggle-doc (format "%s: %s"
toggle-name
(propertize
(or (plist-get (cdr toggle) :documentation) "")
'face 'font-lock-doc-face))))
(when (plist-member (cdr toggle) :evil-leader)
(let ((key (key-description
(kbd (concat dotspacemacs-leader-key " "
(plist-get (cdr toggle) :evil-leader))))))
(setq toggle-doc
(format "%s (%s)"
toggle-doc
(propertize key 'face 'helm-M-x-key)))))
(if (plist-member (cdr toggle) :documentation)
(push `(,toggle-doc . ,toggle-symbol) result)
(push `(,toggle-name . ,toggle-symbol) result))))
(setq result (cl-sort result 'string< :key 'car))
result))
(defun ivy-spacemacs-help//toggle (candidate)
"Toggle candidate."
(let ((toggle (assq (intern candidate) spacemacs-toggles)))
(when toggle
(funcall (plist-get (cdr toggle) :function)))))
;;;###autoload
(defun ivy-spacemacs-help-toggles ()
(interactive)
(ivy-read "Spacemacs Toggles: "
(ivy-spacemacs-help//toggle-candidates)
:action 'ivy-spacemacs-help//toggle))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; .spacemacs vars
(defun ivy-spacemacs-help//dotspacemacs-candidates ()
"Return the sorted candidates for all the dospacemacs variables."
(sort (dotspacemacs/get-variable-string-list) 'string<))
(defun ivy-spacemacs-help//go-to-dotfile-variable (candidate)
"Go to candidate in the dotfile."
(find-file dotspacemacs-filepath)
(goto-char (point-min))
;; try to exclude comments
(re-search-forward (format "^[a-z\s\\(\\-]*%s" candidate))
(beginning-of-line))
;;;###autoload
(defun ivy-spacemacs-help-dotspacemacs ()
(interactive)
(ivy-read ".spacemacs variables: "
(ivy-spacemacs-help//dotspacemacs-candidates)
:action 'ivy-spacemacs-help//go-to-dotfile-variable))
(provide 'ivy-spacemacs-help)
;;; ivy-spacemacs-help.el ends here

View file

@ -0,0 +1,281 @@
;;; packages.el --- Spacemacs Core Layer packages File
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq spacemacs-ivy-packages
'(counsel
flx
hydra
(ivy-spacemacs-help :location local)
smex
swiper))
;; Initialization of packages
(defun spacemacs-ivy/init-counsel ()
(defvar spacemacs--counsel-commands
'(("ag" . "ag --vimgrep %S .")
("pt" . "pt.exe -e --nocolor --nogroup --column %S .")
("ack" . "ack --nocolor --nogroup --column %S .")
("grep" . "grep -nrP %S ."))
"Alist of search commands and their corresponding commands
with options to run in the shell.")
(defvar spacemacs--counsel-search-max-path-length 30
"Truncate the current path in counsel search if it is longer
than this amount.")
;; see `counsel-ag-function'
(defun spacemacs//make-counsel-search-function (tool)
(lexical-let ((base-cmd
(cdr (assoc-string tool spacemacs--counsel-commands))))
(lambda (string &optional _pred &rest _unused)
"Grep in the current directory for STRING."
(if (< (length string) 3)
(counsel-more-chars 3)
(let ((default-directory counsel--git-grep-dir)
(regex (counsel-unquote-regex-parens
(setq ivy--old-re
(ivy--regex string)))))
(counsel--async-command (format base-cmd regex))
nil)))))
;; see `counsel-ag'
(defun spacemacs/counsel-search
(&optional tools use-initial-input initial-directory)
"Search using the first available tool in TOOLS. Default tool
to try is grep. If INPUT is non nil, use the region or the symbol
at the point as the initial input. If DIR is non nil start in
that directory."
(interactive)
(require 'counsel)
(letf* ((initial-input (when use-initial-input
(if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(thing-at-point 'symbol t))))
(tool (catch 'tool
(dolist (tool tools)
(when (and (assoc-string tool spacemacs--counsel-commands)
(executable-find tool))
(throw 'tool tool)))
(throw 'tool "grep"))))
(setq counsel--git-grep-dir (or initial-directory default-directory))
(ivy-read
(format "%s from [%s]: "
tool
(if (< (length counsel--git-grep-dir)
spacemacs--counsel-search-max-path-length)
counsel--git-grep-dir
(concat "..."
(substring counsel--git-grep-dir
(- (length counsel--git-grep-dir)
spacemacs--counsel-search-max-path-length)
(length counsel--git-grep-dir)))))
(spacemacs//make-counsel-search-function tool)
:initial-input initial-input
:dynamic-collection t
:history 'counsel-git-grep-history
:action #'counsel-git-grep-action
:unwind (lambda ()
(counsel-delete-process)
(swiper--cleanup)))))
(cl-loop for (tools tool-name) in '((dotspacemacs-search-tools "auto")
((list "ag") "ag")
((list "pt") "pt")
((list "ack") "ack")
((list "grep") "grep"))
do
(eval
`(progn
(defun ,(intern (format "spacemacs/search-%s" tool-name)) ()
,(format
"Use `spacemacs/counsel-search' to search in the current
directory with %s." (if (string= tool-name "auto")
"a tool selected from `dotspacemacs-search-tools'."
tool-name))
(interactive)
(spacemacs/counsel-search ,tools))
(defun ,(intern (format "spacemacs/search-%s-region-or-symbol"
tool-name)) ()
,(format
"Use `spacemacs/counsel-search' to search for
the selected region or the symbol under the point in the current
directory with %s." (if (string= tool-name "auto")
"a tool selected from `dotspacemacs-search-tools'."
tool-name))
(interactive)
(spacemacs/counsel-search ,tools t))
(defun ,(intern (format "spacemacs/search-project-%s" tool-name)) ()
,(format
"Use `spacemacs/counsel-search' to search in the current
project with %s." (if (string= tool-name "auto")
"a tool selected from `dotspacemacs-search-tools'."
tool-name))
(interactive)
(spacemacs/counsel-search ,tools nil (projectile-project-root)))
(defun ,(intern (format "spacemacs/search-project-%s-region-or-symbol"
tool-name)) ()
,(format
"Use `spacemacs/counsel-search' to search for
the selected region or the symbol under the point in the current
project with %s." (if (string= tool-name "auto")
"a tool selected from `dotspacemacs-search-tools'."
tool-name))
(interactive)
(spacemacs/counsel-search ,tools t (projectile-project-root))))))
(defun spacemacs/counsel-git-grep-region-or-symbol ()
"Use `counsel-git-grep' to search for the selected region or
the symbol under the point in the current project with git grep."
(let ((input (if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(thing-at-point 'symbol t))))
(counsel-git-grep nil input)))
(defun spacemacs//ivy-command-not-implemented-yet (key)
(lexical-let ((-key key))
(spacemacs/set-leader-keys
-key (lambda ()
(interactive)
(message "The command usually bound to %s %s has \
not been implemented for the spacemacs-ivy layer yet."
dotspacemacs-leader-key -key)))))
(use-package counsel
:config
(spacemacs/set-leader-keys
dotspacemacs-command-key 'counsel-M-x
;; files
"ff" 'counsel-find-file
"fL" 'counsel-locate
;; help
"hdf" 'counsel-describe-function
"hdm" 'describe-mode
"hdv" 'counsel-describe-variable
;; insert
"iu" 'counsel-unicode-char
;; jump
;; projects
"pp" 'projectile-switch-project
;; jumping
"sj" 'counsel-imenu
;; themes
"Tc" 'counsel-load-theme
;; search
"/" 'spacemacs/search-project-auto
"*" 'spacemacs/search-project-auto-region-or-symbol
"sf" 'spacemacs/search-auto
"sF" 'spacemacs/search-auto-region-or-symbol
"sp" 'spacemacs/search-project
"sP" 'spacemacs/search-project-region-or-symbol
"saf" 'spacemacs/search-ag
"saF" 'spacemacs/search-ag-region-or-symbol
"sap" 'spacemacs/search-project-ag
"saP" 'spacemacs/search-project-ag-region-or-symbol
"stf" 'spacemacs/search-pt
"stF" 'spacemacs/search-pt-region-or-symbol
"stp" 'spacemacs/search-project-pt
"stP" 'spacemacs/search-project-pt-region-or-symbol
"sgf" 'spacemacs/search-grep
"sgF" 'spacemacs/search-grep-region-or-symbol
"sgp" 'counsel-git-grep
"sgP" 'spacemacs/counsel-git-grep-region-or-symbol
"skf" 'spacemacs/search-ack
"skF" 'spacemacs/search-ack-region-or-symbol
"skp" 'spacemacs/search-project-ack
"skP" 'spacemacs/search-project-ack-region-or-symbol)
;; TODO: Commands to port
(spacemacs//ivy-command-not-implemented-yet "?")
(spacemacs//ivy-command-not-implemented-yet "jI")))
(defun spacemacs-ivy/init-flx ())
(defun spacemacs-ivy/init-hydra ())
(defun spacemacs-ivy/init-ivy-spacemacs-help ()
(use-package ivy-spacemacs-help
:init
(progn
(spacemacs/set-leader-keys
"h SPC d" 'ivy-spacemacs-help-docs
"h SPC ." 'ivy-spacemacs-help-dotspacemacs
;; "h SPC f" 'ivy-spacemacs-help-faq
"h SPC l" 'ivy-spacemacs-help-layers
"h SPC SPC" 'ivy-spacemacs-help
"h SPC p" 'ivy-spacemacs-help-packages
"h SPC t" 'ivy-spacemacs-help-toggles))))
(defun spacemacs-ivy/init-smex ()
(use-package smex
:defer t
:init
(progn
(setq-default smex-history-length 32
smex-save-file (concat spacemacs-cache-directory
".smex-items")))))
(defun spacemacs-ivy/init-swiper ()
(use-package ivy
:config
(spacemacs/set-leader-keys
"fr" 'ivy-recentf
"ir" 'ivy-resume
"bb" 'ivy-switch-buffer)
(setq ivy-height 15)
(with-eval-after-load 'recentf
;; merge recentf and bookmarks into buffer switching. If we set this
;; before recentf loads, then ivy-mode loads recentf for us, which messes
;; up the spacemacs version of recentf.
(setq ivy-use-virtual-buffers t))
(when (configuration-layer/package-usedp 'projectile)
(setq projectile-completion-system 'ivy))
(ivy-mode 1)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(spacemacs//hjkl-completion-navigation))
(use-package swiper
:config
(defun spacemacs/swiper-region-or-symbol ()
"Run `swiper' with the selected region or the symbol under
the point as the initial input."
(interactive)
(let ((input (if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(thing-at-point 'symbol t))))
(swiper--ivy input)))
(defun spacemacs/swiper-all-region-or-symbol ()
"Run `swiper-all' with the selected region or the symbol
under the point as the initial input."
(interactive)
(ivy-read "Swiper: " (swiper--multi-candidates
(cl-remove-if-not
#'buffer-file-name
(buffer-list)))
:initial-input (if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(thing-at-point 'symbol t))
:action 'swiper-multi-action-2
:unwind #'swiper--cleanup
:caller 'swiper-multi))
(spacemacs/set-leader-keys
"ss" 'swiper
"sS" 'spacemacs/swiper-region-or-symbol
"sb" 'swiper-all
"sB" 'spacemacs/swiper-all-region-or-symbol)
(global-set-key "\C-s" 'swiper)))

View file

@ -65,11 +65,16 @@
(defun spacemacs/jump-in-buffer ()
(interactive)
(cond
((eq major-mode 'org-mode)
(call-interactively 'helm-org-in-buffer-headings))
(t
(call-interactively 'helm-semantic-or-imenu))))
(call-interactively
(cond
((and (configuration-layer/layer-usedp 'spacemacs-helm)
(eq major-mode 'org-mode))
'helm-org-in-buffer-headings)
((configuration-layer/layer-usedp 'spacemacs-helm)
'helm-semantic-or-imenu)
((configuration-layer/layer-usedp 'spacemacs-ivy)
'counsel-imenu)
(t 'imenu))))
(defun spacemacs/split-and-new-line ()
"Split a quoted string or s-expression and insert a new line with
@ -901,3 +906,36 @@ current major mode."
(when (and (integerp shift-width)
(< 0 shift-width))
(setq-local evil-shift-width shift-width))))
(defun spacemacs//hjkl-completion-navigation ()
(cond
((and (configuration-layer/layer-usedp 'spacemacs-helm)
(member dotspacemacs-editing-style '(vim hybrid)))
;; better navigation on homerow
;; rebind `describe-key' for convenience
(define-key helm-map (kbd "C-j") 'helm-next-line)
(define-key helm-map (kbd "C-k") 'helm-previous-line)
(define-key helm-map (kbd "C-h") 'helm-next-source)
(define-key helm-map (kbd "C-S-h") 'describe-key)
(define-key helm-map (kbd "C-l") (kbd "RET"))
(dolist (keymap (list helm-find-files-map helm-read-file-map))
(define-key keymap (kbd "C-l") 'helm-execute-persistent-action)
(define-key keymap (kbd "C-h") 'helm-find-files-up-one-level)
(define-key keymap (kbd "C-S-h") 'describe-key)))
((configuration-layer/layer-usedp 'spacemacs-helm)
(define-key helm-map (kbd "C-j") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-k") 'helm-delete-minibuffer-contents)
(define-key helm-map (kbd "C-h") nil)
(define-key helm-map (kbd "C-l") 'helm-recenter-top-bottom-other-window))
((and (configuration-layer/layer-usedp 'spacemacs-ivy)
(member dotspacemacs-editing-style '(vim hybrid)))
(define-key ivy-minibuffer-map (kbd "C-j") 'ivy-next-line)
(define-key ivy-minibuffer-map (kbd "C-k") 'ivy-previous-line)
(define-key ivy-minibuffer-map (kbd "C-h") (kbd "DEL"))
(define-key ivy-minibuffer-map (kbd "C-l") 'ivy-alt-done)
(define-key ivy-minibuffer-map (kbd "<escape>") 'minibuffer-keyboard-quit))
((configuration-layer/layer-usedp 'spacemacs-ivy)
(define-key ivy-minibuffer-map (kbd "C-j") 'ivy-alt-done)
(define-key ivy-minibuffer-map (kbd "C-k") 'ivy-kill-line)
(define-key ivy-minibuffer-map (kbd "C-h") nil)
(define-key ivy-minibuffer-map (kbd "C-l") nil))))

View file

@ -76,32 +76,7 @@
;; Cycling settings -----------------------------------------------------------
(spacemacs/set-leader-keys "Tn" 'spacemacs/cycle-spacemacs-theme)
;; describe functions ---------------------------------------------------------
(defmacro spacemacs||set-helm-key (keys func)
"Define a key bindings for FUNC using KEYS.
Ensure that helm is required before calling FUNC."
(let ((func-name (intern (format "spacemacs/%s" (symbol-name func)))))
`(progn
(defun ,func-name ()
,(format "Wrapper to ensure that `helm' is loaded before calling %s."
(symbol-name func))
(interactive)
(require 'helm)
(call-interactively ',func))
(spacemacs/set-leader-keys ,keys ',func-name))))
(spacemacs||set-helm-key "hdb" describe-bindings)
(spacemacs||set-helm-key "hdc" describe-char)
(spacemacs||set-helm-key "hdf" describe-function)
(spacemacs||set-helm-key "hdk" describe-key)
(spacemacs||set-helm-key "hdm" describe-mode)
(spacemacs||set-helm-key "hdp" describe-package)
(spacemacs/set-leader-keys "hds" 'spacemacs/describe-system-info)
(spacemacs||set-helm-key "hdt" describe-theme)
(spacemacs||set-helm-key "hdv" describe-variable)
(spacemacs||set-helm-key "hn" view-emacs-news)
(spacemacs||set-helm-key "hL" helm-locate-library)
;; search functions -----------------------------------------------------------
(spacemacs||set-helm-key "sww" helm-wikipedia-suggest)
(spacemacs||set-helm-key "swg" helm-google-suggest)
;; errors ---------------------------------------------------------------------
(spacemacs/set-leader-keys
"en" 'spacemacs/next-error
@ -130,6 +105,16 @@ Ensure that helm is required before calling FUNC."
"fvf" 'add-file-local-variable
"fvp" 'add-file-local-variable-prop-line
"fy" 'spacemacs/show-and-copy-buffer-filename)
;; help -----------------------------------------------------------------------
(spacemacs/set-leader-keys
"hdb" 'describe-bindings
"hdc" 'describe-char
"hdf" 'describe-function
"hdk" 'describe-key
"hdp" 'describe-package
"hds" 'spacemacs/describe-system-info
"hdt" 'describe-theme
"hdv" 'describe-variable)
;; insert stuff ---------------------------------------------------------------
(spacemacs/set-leader-keys
"iJ" 'spacemacs/insert-line-below-no-indent
@ -154,7 +139,6 @@ Ensure that helm is required before calling FUNC."
"jD" 'dired-jump-other-window
"jf" 'find-function-at-point
"ji" 'spacemacs/jump-in-buffer
"jI" 'helm-imenu-in-all-buffers
"jv" 'find-variable-at-point)
;; Compilation ----------------------------------------------------------------
@ -571,7 +555,7 @@ otherwise it is scaled down."
dotfile-setting
'(100 . 100))))
;; Immediately enter the micro-state, but also keep toggle
;; accessible from helm-spacemacs
;; accessible from helm-spacemacs-help
(spacemacs/scale-transparency-micro-state))
(defun spacemacs/increase-transparency ()

View file

@ -27,11 +27,6 @@
(evil-evilified-state :location local :step pre :protected t)
exec-path-from-shell
fill-column-indicator
helm
helm-descbinds
helm-flx
helm-projectile
(helm-spacemacs :location local)
help-fns+
hl-todo
(hs-minor-mode :location built-in)
@ -482,507 +477,6 @@ Example: (evil-map visual \"<\" \"<gv\")"
:config
(spacemacs|hide-lighter fci-mode)))
(defun spacemacs-base/init-helm ()
(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
helm-bookmark-show-location t
helm-display-header-line nil
helm-split-window-in-side-p t
helm-always-two-windows t
helm-echo-input-in-header-line t
helm-imenu-execute-action-at-once-if-one nil
helm-org-format-outline-path t)
;; hide minibuffer in Helm session, since we use the header line already
(defun helm-hide-minibuffer-maybe ()
(when (with-helm-buffer helm-echo-input-in-header-line)
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
(overlay-put ov 'window (selected-window))
(overlay-put ov 'face (let ((bg-color (face-background 'default nil)))
`(:background ,bg-color :foreground ,bg-color)))
(setq-local cursor-type nil))))
(add-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)
;; fuzzy matching setting
(setq helm-M-x-fuzzy-match t
helm-apropos-fuzzy-match t
helm-file-cache-fuzzy-match t
helm-imenu-fuzzy-match t
helm-lisp-fuzzy-completion t
helm-recentf-fuzzy-match t
helm-semantic-fuzzy-match t
helm-buffers-fuzzy-matching t)
;; Use helm to provide :ls, unless ibuffer is used
(unless (configuration-layer/package-usedp 'ibuffer)
(evil-ex-define-cmd "buffers" 'helm-buffers-list))
(defun spacemacs//helm-do-grep-region-or-symbol (&optional targs use-region-or-symbol-p)
"Version of `helm-do-grep' with a default input."
(interactive)
(require 'helm)
(cl-letf*
(((symbol-function 'this-fn) (symbol-function 'helm-do-grep-1))
((symbol-function 'helm-do-grep-1)
(lambda (targets &optional recurse zgrep exts default-input region-or-symbol-p)
(let* ((new-input (when region-or-symbol-p
(if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(thing-at-point 'symbol t))))
(quoted-input (when new-input (rxt-quote-pcre new-input))))
(this-fn targets recurse zgrep exts default-input quoted-input))))
(preselection (or (dired-get-filename nil t)
(buffer-file-name (current-buffer))))
(targets (if targs
targs
(helm-read-file-name
"Search in file(s): "
:marked-candidates t
:preselect (if helm-ff-transformer-show-only-basename
(helm-basename preselection)
preselection)))))
(helm-do-grep-1 targets nil nil nil nil use-region-or-symbol-p)))
(defun spacemacs/helm-file-do-grep ()
"Search in current file with `grep' using a default input."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol
(list (buffer-file-name (current-buffer))) nil))
(defun spacemacs/helm-file-do-grep-region-or-symbol ()
"Search in current file with `grep' using a default input."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol
(list (buffer-file-name (current-buffer))) t))
(defun spacemacs/helm-files-do-grep ()
"Search in files with `grep'."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol nil nil))
(defun spacemacs/helm-files-do-grep-region-or-symbol ()
"Search in files with `grep' using a default input."
(interactive)
(spacemacs//helm-do-grep-region-or-symbol nil t))
(defun spacemacs/helm-buffers-do-grep ()
"Search in opened buffers with `grep'."
(interactive)
(let ((buffers (cl-loop for buffer in (buffer-list)
when (buffer-file-name buffer)
collect (buffer-file-name buffer))))
(spacemacs//helm-do-grep-region-or-symbol buffers nil)))
(defun spacemacs/helm-buffers-do-grep-region-or-symbol ()
"Search in opened buffers with `grep' with a default input."
(interactive)
(let ((buffers (cl-loop for buffer in (buffer-list)
when (buffer-file-name buffer)
collect (buffer-file-name buffer))))
(spacemacs//helm-do-grep-region-or-symbol buffers t)))
(defun spacemacs/last-search-buffer ()
"open last helm-ag or hgrep buffer."
(interactive)
(cond ((get-buffer "*helm ag results*")
(switch-to-buffer-other-window "*helm ag results*"))
((get-buffer "*helm-ag*")
(helm-resume "*helm-ag*"))
((get-buffer "*hgrep*")
(switch-to-buffer-other-window "*hgrep*"))
(t
(message "No previous search buffer found"))))
(defun spacemacs/helm-faces ()
"Describe face."
(interactive)
(require 'helm-elisp)
(let ((default (or (face-at-point) (thing-at-point 'symbol))))
(helm :sources (helm-def-source--emacs-faces
(format "%s" (or default "default")))
:buffer "*helm faces*")))
;; use helm by default for M-x
(unless (configuration-layer/package-usedp 'smex)
(global-set-key (kbd "M-x") 'helm-M-x))
(spacemacs/set-leader-keys
"<f1>" 'helm-apropos
"bb" 'helm-mini
"Cl" 'helm-colors
"ff" 'spacemacs/helm-find-files
"fF" 'helm-find-files
"fL" 'helm-locate
"fr" 'helm-recentf
"hb" 'helm-filtered-bookmarks
"hdF" 'spacemacs/helm-faces
"hi" 'helm-info-at-point
"hl" 'helm-resume
"hm" 'helm-man-woman
"iu" 'helm-ucs
"ry" 'helm-show-kill-ring
"rr" 'helm-register
"rm" 'helm-all-mark-rings
"sl" 'spacemacs/last-search-buffer
"sj" 'spacemacs/jump-in-buffer)
;; search with grep
(spacemacs/set-leader-keys
"sgb" 'spacemacs/helm-buffers-do-grep
"sgB" 'spacemacs/helm-buffers-do-grep-region-or-symbol
"sgf" 'spacemacs/helm-files-do-grep
"sgF" 'spacemacs/helm-files-do-grep-region-or-symbol
"sgg" 'spacemacs/helm-file-do-grep
"sgG" 'spacemacs/helm-file-do-grep-region-or-symbol)
;; define the key binding at the very end in order to allow the user
;; to overwrite any key binding
(add-hook 'emacs-startup-hook
(lambda ()
(unless (configuration-layer/package-usedp 'smex)
(spacemacs/set-leader-keys
dotspacemacs-emacs-command-key 'helm-M-x))))
(defun spacemacs//hide-cursor-in-helm-buffer ()
"Hide the cursor in helm buffers."
(with-helm-buffer
(setq cursor-in-non-selected-windows nil)))
(add-hook 'helm-after-initialize-hook 'spacemacs//hide-cursor-in-helm-buffer)
(defvar spacemacs-helm-display-help-buffer-regexp '("*.*Helm.*Help.**"))
(defvar spacemacs-helm-display-buffer-regexp `("*.*helm.**"
(display-buffer-in-side-window)
(inhibit-same-window . t)
(side . ,dotspacemacs-helm-position)
(window-width . 0.6)
(window-height . 0.4)))
(defvar spacemacs-display-buffer-alist nil)
(defun spacemacs//helm-prepare-display ()
"Prepare necessary settings to make Helm display properly."
;; avoid Helm buffer being diplaye twice when user
;; sets this variable to some function that pop buffer to
;; a window. See https://github.com/syl20bnr/spacemacs/issues/1396
(let ((display-buffer-base-action '(nil)))
(setq spacemacs-display-buffer-alist display-buffer-alist)
;; the only buffer to display is Helm, nothing else we must set this
;; otherwise Helm cannot reuse its own windows for copyinng/deleting
;; etc... because of existing popwin buffers in the alist
(setq display-buffer-alist nil)
(popwin-mode -1)
;; workaround for a helm-evil incompatibility
;; see https://github.com/syl20bnr/spacemacs/issues/3700
(when helm-prevent-escaping-from-minibuffer
(define-key evil-motion-state-map [down-mouse-1] nil))))
(defun spacemacs//display-helm-window (buffer)
(let ((display-buffer-alist (list spacemacs-helm-display-help-buffer-regexp
;; this or any specialized case of Helm buffer must be added AFTER
;; `spacemacs-helm-display-buffer-regexp'. Otherwise,
;; `spacemacs-helm-display-buffer-regexp' will be used before
;; `spacemacs-helm-display-help-buffer-regexp' and display
;; configuration for normal Helm buffer is applied for helm help
;; buffer, making the help buffer unable to be displayed.
spacemacs-helm-display-buffer-regexp)))
(helm-default-display-buffer buffer)))
(setq helm-display-function 'spacemacs//display-helm-window)
(defun spacemacs//restore-previous-display-config ()
;; workaround for a helm-evil incompatibility
;; see https://github.com/syl20bnr/spacemacs/issues/3700
(when helm-prevent-escaping-from-minibuffer
(define-key evil-motion-state-map [down-mouse-1] 'evil-mouse-drag-region))
(popwin-mode 1)
;; we must enable popwin-mode first then restore `display-buffer-alist'
;; Otherwise, popwin keeps adding up its own buffers to `display-buffer-alist'
;; and could slow down Emacs as the list grows
(setq display-buffer-alist spacemacs-display-buffer-alist))
(add-hook 'helm-after-initialize-hook 'spacemacs//helm-prepare-display)
;; Restore popwin-mode after a Helm session finishes.
(add-hook 'helm-cleanup-hook 'spacemacs//restore-previous-display-config)
;; Add minibuffer history with `helm-minibuffer-history'
(define-key minibuffer-local-map (kbd "C-c C-l") 'helm-minibuffer-history)
(defun spacemacs//helm-cleanup ()
"Cleanup some helm related states when quitting."
;; deactivate any running transient map (micro-state)
(setq overriding-terminal-local-map nil))
(add-hook 'helm-cleanup-hook 'spacemacs//helm-cleanup)
(defface spacemacs-helm-navigation-ms-face
`((t :background ,(face-attribute 'error :foreground) :foreground "black"))
"Face for helm heder when helm micro-state is activated."
:group 'spacemacs))
:config
(progn
(helm-mode +1)
;; helm-locate uses es (from everything on windows, which doesnt like fuzzy)
(helm-locate-set-command)
(setq helm-locate-fuzzy-match (string-match "locate" helm-locate-command))
(defun spacemacs//set-dotted-directory ()
"Set the face of diretories for `.' and `..'"
(set-face-attribute 'helm-ff-dotted-directory
nil
:foreground nil
:background nil
:inherit 'helm-ff-directory))
(add-hook 'helm-find-files-before-init-hook 'spacemacs//set-dotted-directory)
;; alter helm-bookmark key bindings to be simpler
(defun simpler-helm-bookmark-keybindings ()
(define-key helm-bookmark-map (kbd "C-d") 'helm-bookmark-run-delete)
(define-key helm-bookmark-map (kbd "C-e") 'helm-bookmark-run-edit)
(define-key helm-bookmark-map (kbd "C-f") 'helm-bookmark-toggle-filename)
(define-key helm-bookmark-map (kbd "C-o") 'helm-bookmark-run-jump-other-window)
(define-key helm-bookmark-map (kbd "C-/") 'helm-bookmark-help))
(add-hook 'helm-mode-hook 'simpler-helm-bookmark-keybindings)
;; helm navigation on hjkl
(defun spacemacs//helm-hjkl-navigation (&optional arg)
"Set navigation in helm on `jklh'.
ARG non nil means that the editing style is `vim'."
(cond
(arg
;; better navigation on homerow
;; rebind `describe-key' for convenience
(define-key helm-map (kbd "C-j") 'helm-next-line)
(define-key helm-map (kbd "C-k") 'helm-previous-line)
(define-key helm-map (kbd "C-h") 'helm-next-source)
(define-key helm-map (kbd "C-S-h") 'describe-key)
(define-key helm-map (kbd "C-l") (kbd "RET"))
(dolist (keymap (list helm-find-files-map helm-read-file-map))
(define-key keymap (kbd "C-l") 'helm-execute-persistent-action)
(define-key keymap (kbd "C-h") 'helm-find-files-up-one-level)
(define-key keymap (kbd "C-S-h") 'describe-key)))
(t
(define-key helm-map (kbd "C-j") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-k") 'helm-delete-minibuffer-contents)
(define-key helm-map (kbd "C-h") nil)
(define-key helm-map (kbd "C-l") 'helm-recenter-top-bottom-other-window))))
(spacemacs//helm-hjkl-navigation (member dotspacemacs-editing-style '(vim hybrid)))
(defun spacemacs/helm-edit ()
"Switch in edit mode depending on the current helm buffer."
(interactive)
(cond
((string-equal "*helm-ag*" helm-buffer)
(helm-ag-edit))))
(defun spacemacs//helm-navigation-ms-on-enter ()
"Initialization of helm micro-state."
;; faces
(spacemacs//helm-navigation-ms-set-face)
(setq spacemacs--helm-navigation-ms-face-cookie-minibuffer
(face-remap-add-relative
'minibuffer-prompt
'spacemacs-helm-navigation-ms-face)))
(defun spacemacs//helm-navigation-ms-set-face ()
"Set the face for helm header in helm navigation micro-state"
(with-helm-window
(setq spacemacs--helm-navigation-ms-face-cookie-header
(face-remap-add-relative
'helm-header
'spacemacs-helm-navigation-ms-face))))
(defun spacemacs//helm-navigation-ms-on-exit ()
"Action to perform when exiting helm micro-state."
(with-helm-window
(face-remap-remove-relative
spacemacs--helm-navigation-ms-face-cookie-header))
(face-remap-remove-relative
spacemacs--helm-navigation-ms-face-cookie-minibuffer))
(defun spacemacs//helm-navigation-ms-full-doc ()
"Full documentation for helm navigation micro-state."
"
[?] display this help
[a] toggle action selection page
[e] edit occurrences if supported
[j] [k] next/previous candidate
[h] [l] previous/next source
[t] toggle visible mark
[T] toggle all mark
[v] persistent action
[q] quit")
;; Define functions to pick actions
(dotimes (n 10)
(let ((func (intern (format "spacemacs/helm-action-%d" n)))
(doc (format "Select helm action #%d" n)))
(eval `(defun ,func ()
,doc
(intern)
(helm-select-nth-action ,(1- n))))))
(spacemacs|define-micro-state helm-navigation
:persistent t
:disable-evil-leader t
:define-key (helm-map . "M-SPC") (helm-map . "s-M-SPC")
:on-enter (spacemacs//helm-navigation-ms-on-enter)
:on-exit (spacemacs//helm-navigation-ms-on-exit)
:bindings
("1" spacemacs/helm-action-1 :exit t)
("2" spacemacs/helm-action-2 :exit t)
("3" spacemacs/helm-action-3 :exit t)
("4" spacemacs/helm-action-4 :exit t)
("5" spacemacs/helm-action-5 :exit t)
("6" spacemacs/helm-action-6 :exit t)
("7" spacemacs/helm-action-7 :exit t)
("8" spacemacs/helm-action-8 :exit t)
("9" spacemacs/helm-action-9 :exit t)
("0" spacemacs/helm-action-10 :exit t)
("<tab>" helm-select-action :exit t)
("TAB" helm-select-action :exit t)
("<RET>" helm-maybe-exit-minibuffer :exit t)
("?" nil :doc (spacemacs//helm-navigation-ms-full-doc))
("a" helm-select-action :post (spacemacs//helm-navigation-ms-set-face))
("e" spacemacs/helm-edit)
("g" helm-beginning-of-buffer)
("G" helm-end-of-buffer)
("h" helm-previous-source)
("j" helm-next-line)
("k" helm-previous-line)
("l" helm-next-source)
("q" nil :exit t)
("t" helm-toggle-visible-mark)
("T" helm-toggle-all-marks)
("v" helm-execute-persistent-action))
;; Swap default TAB and C-z commands.
;; For GUI.
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-find-files-map (kbd "S-<tab>") 'helm-find-files-up-one-level)
(define-key helm-find-files-map (kbd "<backtab>") 'helm-find-files-up-one-level)
;; For terminal.
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
(define-key helm-find-files-map (kbd "S-TAB") 'helm-find-files-up-one-level)
(define-key helm-map (kbd "C-z") 'helm-select-action)
(with-eval-after-load 'helm-mode ; required
(spacemacs|hide-lighter helm-mode)))))
(defun spacemacs-base/init-helm-flx ()
(use-package helm-flx
:defer t)
(spacemacs|use-package-add-hook helm
:pre-config
(progn
;; Disable for helm-find-files until performance issues are sorted
;; https://github.com/PythonNut/helm-flx/issues/9
(setq helm-flx-for-helm-find-files nil)
(helm-flx-mode))))
(defun spacemacs-base/init-helm-descbinds ()
(use-package helm-descbinds
:defer t
:init
(progn
(setq helm-descbinds-window-style 'split)
(add-hook 'helm-mode-hook 'helm-descbinds-mode)
(spacemacs/set-leader-keys "?" 'helm-descbinds))))
(defun spacemacs-base/init-helm-projectile ()
(use-package helm-projectile
:commands (helm-projectile-switch-to-buffer
helm-projectile-find-dir
helm-projectile-dired-find-dir
helm-projectile-recentf
helm-projectile-find-file
helm-projectile-grep
helm-projectile
helm-projectile-switch-project)
:init
(progn
(setq projectile-switch-project-action 'helm-projectile)
(defconst spacemacs-use-helm-projectile t
"This variable is only defined if helm-projectile is used.")
;; needed for smart search if user's default tool is grep
(defalias 'spacemacs/helm-project-do-grep 'helm-projectile-grep)
(defalias
'spacemacs/helm-project-do-grep-region-or-symbol 'helm-projectile-grep)
(spacemacs/set-leader-keys
"pb" 'helm-projectile-switch-to-buffer
"pd" 'helm-projectile-find-dir
"pf" 'helm-projectile-find-file
"ph" 'helm-projectile
"pp" 'helm-projectile-switch-project
"pr" 'helm-projectile-recentf
"pv" 'projectile-vc
"sgp" 'helm-projectile-grep))))
(defun spacemacs-base/init-helm-spacemacs ()
(use-package helm-spacemacs
:commands (helm-spacemacs helm-spacemacs-faq)
:init
(progn
(defun spacemacs-base/helm-spacemacs-deprecated (arg)
"Provide helm-spacemacs with a binding's depreciation message."
(interactive "P")
(warn "The 'SPC f e h' (or 'M-m f e h') binding is now deprecated and will be remove in the next release. Please use 'SPC h SPC' (or 'M-m h SPC') instead.")
(helm-spacemacs arg))
(spacemacs/set-leader-keys "feh" 'spacemacs-base/helm-spacemacs-deprecated)
(spacemacs/set-leader-keys "fef" 'helm-spacemacs-faq)
(spacemacs/set-leader-keys "h SPC" 'helm-spacemacs))))
(defun spacemacs-base/init-help-fns+ ()
(use-package help-fns+
:commands (describe-keymap)
@ -1313,10 +807,7 @@ ARG non nil means that the editing style is `vim'."
"po" 'projectile-multi-occur
"pR" 'projectile-replace
"pT" 'projectile-find-test-file
"py" 'projectile-find-tag)
(when (configuration-layer/package-usedp 'persp-mode)
(spacemacs/set-leader-keys
"pl" 'spacemacs/helm-persp-switch-project)))
"py" 'projectile-find-tag))
:config
(progn
(projectile-global-mode)

View file

@ -13,3 +13,8 @@
;; Prerequisites
(configuration-layer/declare-layers '(spacemacs-base spacemacs-layouts))
;; If the user has not explicitly declared spacemacs-helm or spacemacs-ivy and
;; they are using the standard distribution, assume they want helm completion.
(unless (or (configuration-layer/layer-usedp 'spacemacs-ivy)
(configuration-layer/layer-usedp 'spacemacs-helm))
(configuration-layer/declare-layers '(spacemacs-helm)))

View file

@ -13,7 +13,6 @@
(setq spacemacs-packages
'(
;; default
ace-jump-helm-line
ace-link
ace-window
adaptive-wrap
@ -51,11 +50,6 @@
flx-ido
golden-ratio
google-translate
helm-ag
helm-make
helm-mode-manager
helm-swoop
helm-themes
highlight-indentation
highlight-numbers
highlight-parentheses
@ -92,13 +86,6 @@
;; Initialization of packages
(defun spacemacs/init-ace-jump-helm-line ()
(use-package ace-jump-helm-line
:defer t
:init
(with-eval-after-load 'helm
(define-key helm-map (kbd "C-q") 'ace-jump-helm-line))))
(defun spacemacs/init-ace-link ()
(use-package ace-link
:commands spacemacs/ace-buffer-links
@ -921,364 +908,6 @@ For instance pass En as source for English."
(setq google-translate-default-source-language "en")
(setq google-translate-default-target-language "fr"))))
(defun spacemacs/init-helm-ag ()
(use-package helm-ag
:defer t
:init
(progn
(defun spacemacs//helm-do-ag-region-or-symbol (func &optional dir)
"Search with `ag' with a default input."
(require 'helm-ag)
(cl-letf* (((symbol-value 'helm-ag-insert-at-point) 'symbol)
;; make thing-at-point choosing the active region first
((symbol-function 'this-fn) (symbol-function 'thing-at-point))
((symbol-function 'thing-at-point)
(lambda (thing)
(let ((res (if (region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end))
(this-fn thing))))
(when res (rxt-quote-pcre res))))))
(funcall func dir)))
(defun spacemacs//helm-do-search-find-tool (base tools default-inputp)
"Create a cond form given a TOOLS string list and evaluate it."
(eval
`(cond
,@(mapcar
(lambda (x)
`((executable-find ,x)
',(let ((func
(intern
(format (if default-inputp
"spacemacs/%s-%s-region-or-symbol"
"spacemacs/%s-%s")
base x))))
(if (fboundp func)
func
(intern (format "%s-%s" base x))))))
tools)
(t 'helm-do-grep))))
;; Search in current file ----------------------------------------------
(defun spacemacs/helm-file-do-ag (&optional _)
"Wrapper to execute `helm-ag-this-file.'"
(interactive)
(helm-ag-this-file))
(defun spacemacs/helm-file-do-ag-region-or-symbol ()
"Search in current file with `ag' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-file-do-ag))
(defun spacemacs/helm-file-smart-do-search (&optional default-inputp)
"Search in current file using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-file-do"
dotspacemacs-search-tools
default-inputp)))
(defun spacemacs/helm-file-smart-do-search-region-or-symbol ()
"Search in current file using `dotspacemacs-search-tools' with
default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-file-smart-do-search t))
;; Search in files -----------------------------------------------------
(defun spacemacs/helm-files-do-ag (&optional dir)
"Search in files with `ag' using a default input."
(interactive)
(helm-do-ag dir))
(defun spacemacs/helm-files-do-ag-region-or-symbol ()
"Search in files with `ag' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ag))
(defun spacemacs/helm-files-do-ack (&optional dir)
"Search in files with `ack'."
(interactive)
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
(helm-do-ag dir)))
(defun spacemacs/helm-files-do-ack-region-or-symbol ()
"Search in files with `ack' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack))
(defun spacemacs/helm-files-do-pt (&optional dir)
"Search in files with `pt'."
(interactive)
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
(helm-do-ag dir)))
(defun spacemacs/helm-files-do-pt-region-or-symbol ()
"Search in files with `pt' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt))
(defun spacemacs/helm-files-smart-do-search (&optional default-inputp)
"Search in opened buffers using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-files-do"
dotspacemacs-search-tools
default-inputp)))
(defun spacemacs/helm-files-smart-do-search-region-or-symbol ()
"Search in opened buffers using `dotspacemacs-search-tools'.
with default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-files-smart-do-search t))
;; Search in buffers ---------------------------------------------------
(defun spacemacs/helm-buffers-do-ag (&optional _)
"Wrapper to execute `helm-ag-buffers.'"
(interactive)
(helm-do-ag-buffers))
(defun spacemacs/helm-buffers-do-ag-region-or-symbol ()
"Search in opened buffers with `ag' with a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ag))
(defun spacemacs/helm-buffers-do-ack (&optional _)
"Search in opened buffers with `ack'."
(interactive)
(let ((helm-ag-base-command "ack --nocolor --nogroup"))
(helm-do-ag-buffers)))
(defun spacemacs/helm-buffers-do-ack-region-or-symbol ()
"Search in opened buffers with `ack' with a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-ack))
(defun spacemacs/helm-buffers-do-pt (&optional _)
"Search in opened buffers with `pt'."
(interactive)
(let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
(helm-do-ag-buffers)))
(defun spacemacs/helm-buffers-do-pt-region-or-symbol ()
"Search in opened buffers with `pt' using a default input."
(interactive)
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-buffers-do-pt))
(defun spacemacs/helm-buffers-smart-do-search (&optional default-inputp)
"Search in opened buffers using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-buffers-do"
dotspacemacs-search-tools
default-inputp)))
(defun spacemacs/helm-buffers-smart-do-search-region-or-symbol ()
"Search in opened buffers using `dotspacemacs-search-tools' with
default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-buffers-smart-do-search t))
;; Search in project ---------------------------------------------------
(defun spacemacs/helm-project-do-ag ()
"Search in current project with `ag'."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(helm-do-ag dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-ag-region-or-symbol ()
"Search in current project with `ag' using a default input."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs//helm-do-ag-region-or-symbol 'helm-do-ag dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-ack ()
"Search in current project with `ack'."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs/helm-files-do-ack dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-ack-region-or-symbol ()
"Search in current project with `ack' using a default input."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-ack dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-pt ()
"Search in current project with `pt'."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs/helm-files-do-pt dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-do-pt-region-or-symbol ()
"Search in current project with `pt' using a default input."
(interactive)
(let ((dir (projectile-project-root)))
(if dir
(spacemacs//helm-do-ag-region-or-symbol 'spacemacs/helm-files-do-pt dir)
(message "error: Not in a project."))))
(defun spacemacs/helm-project-smart-do-search (&optional default-inputp)
"Search in current project using `dotspacemacs-search-tools'.
Search for a search tool in the order provided by `dotspacemacs-search-tools'
If DEFAULT-INPUTP is non nil then the current region or symbol at point
are used as default input."
(interactive)
(let ((projectile-require-project-root nil))
(call-interactively
(spacemacs//helm-do-search-find-tool "helm-project-do"
dotspacemacs-search-tools
default-inputp))))
(defun spacemacs/helm-project-smart-do-search-region-or-symbol ()
"Search in current project using `dotspacemacs-search-tools' with
default input.
Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(interactive)
(spacemacs/helm-project-smart-do-search t))
;; This overrides the default C-s action in helm-projectile-switch-project
;; to search using ag/pt/whatever instead of just grep
(with-eval-after-load 'helm-projectile
(defun spacemacs/helm-project-smart-do-search-in-dir (dir)
(interactive)
(let ((default-directory dir))
(spacemacs/helm-project-smart-do-search)))
(define-key helm-projectile-projects-map
(kbd "C-s")
(lambda ()
(interactive)
(helm-exit-and-execute-action 'spacemacs/helm-project-smart-do-search-in-dir))))
;; evilify the helm-grep buffer
(evilified-state-evilify helm-grep-mode helm-grep-mode-map
(kbd "RET") 'helm-grep-mode-jump-other-window
(kbd "q") 'quit-window)
(spacemacs/set-leader-keys
;; helm-ag marks
"s`" 'helm-ag-pop-stack
;; opened buffers scope
"sb" 'spacemacs/helm-buffers-smart-do-search
"sB" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
"sab" 'helm-do-ag-buffers
"saB" 'spacemacs/helm-buffers-do-ag-region-or-symbol
"skb" 'spacemacs/helm-buffers-do-ack
"skB" 'spacemacs/helm-buffers-do-ack-region-or-symbol
"stb" 'spacemacs/helm-buffers-do-pt
"stB" 'spacemacs/helm-buffers-do-pt-region-or-symbol
;; current file scope
"ss" 'spacemacs/helm-file-smart-do-search
"sS" 'spacemacs/helm-file-smart-do-search-region-or-symbol
"saa" 'helm-ag-this-file
"saA" 'spacemacs/helm-file-do-ag-region-or-symbol
;; files scope
"sf" 'spacemacs/helm-files-smart-do-search
"sF" 'spacemacs/helm-files-smart-do-search-region-or-symbol
"saf" 'helm-do-ag
"saF" 'spacemacs/helm-files-do-ag-region-or-symbol
"skf" 'spacemacs/helm-files-do-ack
"skF" 'spacemacs/helm-files-do-ack-region-or-symbol
"stf" 'spacemacs/helm-files-do-pt
"stF" 'spacemacs/helm-files-do-pt-region-or-symbol
;; current project scope
"/" 'spacemacs/helm-project-smart-do-search
"*" 'spacemacs/helm-project-smart-do-search-region-or-symbol
"sp" 'spacemacs/helm-project-smart-do-search
"sP" 'spacemacs/helm-project-smart-do-search-region-or-symbol
"sap" 'spacemacs/helm-project-do-ag
"saP" 'spacemacs/helm-project-do-ag-region-or-symbol
"skp" 'spacemacs/helm-project-do-ack
"skP" 'spacemacs/helm-project-do-ack-region-or-symbol
"stp" 'spacemacs/helm-project-do-pt
"stP" 'spacemacs/helm-project-do-pt-region-or-symbol))
:config
(progn
(evil-define-key 'normal helm-ag-map "SPC" spacemacs-default-map)
(evilified-state-evilify helm-ag-mode helm-ag-mode-map
(kbd "RET") 'helm-ag-mode-jump-other-window
(kbd "q") 'quit-window))))
(defun spacemacs/init-helm-make ()
(use-package helm-make
:defer t
:init
(spacemacs/set-leader-keys
"cc" 'helm-make-projectile
"cm" 'helm-make)))
(defun spacemacs/init-helm-mode-manager ()
(use-package helm-mode-manager
:defer t
:init
(spacemacs/set-leader-keys
"hM" 'helm-switch-major-mode
;; "hm" 'helm-disable-minor-mode
"h C-m" 'helm-enable-minor-mode)))
(defun spacemacs/init-helm-swoop ()
(use-package helm-swoop
:defer t
:init
(progn
(setq helm-swoop-split-with-multiple-windows t
helm-swoop-split-direction 'split-window-vertically
helm-swoop-speed-or-color t
helm-swoop-split-window-function 'helm-default-display-buffer
helm-swoop-pre-input-function (lambda () ""))
(defun spacemacs/helm-swoop-region-or-symbol ()
"Call `helm-swoop' with default input."
(interactive)
(let ((helm-swoop-pre-input-function
(lambda ()
(if (region-active-p)
(buffer-substring-no-properties (region-beginning)
(region-end))
(let ((thing (thing-at-point 'symbol t)))
(if thing thing ""))))))
(call-interactively 'helm-swoop)))
(spacemacs/set-leader-keys
"ss" 'helm-swoop
"sS" 'spacemacs/helm-swoop-region-or-symbol
"s C-s" 'helm-multi-swoop-all)
(defadvice helm-swoop (before add-evil-jump activate)
(when (configuration-layer/package-usedp 'evil-jumper)
(evil-set-jump))))))
(defun spacemacs/init-helm-themes ()
(use-package helm-themes
:defer t
:init
(spacemacs/set-leader-keys
"Th" 'helm-themes)))
(defun spacemacs/init-highlight-indentation ()
(use-package highlight-indentation
@ -1419,19 +1048,29 @@ It will toggle the overlay under point or create an overlay of one character."
:commands (open-junk-file)
:init
(setq open-junk-file-format (concat spacemacs-cache-directory "junk/%Y/%m/%d-%H%M%S."))
(defun spacemacs/helm-open-junk-file (&optional arg)
"Open junk file
Open junk file using helm, with `prefix-arg' search in junk files"
(defun spacemacs/open-junk-file (&optional arg)
"Open junk file Open junk file using helm or ivy depending
on whether the spacemacs-ivy layer is used or not, with
`prefix-arg' search in junk files"
(interactive "P")
(require 'helm)
(let* ((fname (format-time-string open-junk-file-format (current-time)))
(rel-fname (file-name-nondirectory fname))
(junk-dir (file-name-directory fname))
(helm-ff-newfile-prompt-p nil)
(default-directory junk-dir))
(if arg
(spacemacs/helm-files-smart-do-search)
(helm-find-files-1 fname))))
(spacemacs/set-leader-keys "fJ" 'spacemacs/helm-open-junk-file)))
(cond ((and arg (configuration-layer/layer-usedp 'spacemacs-ivy))
(spacemacs/counsel-search dotspacemacs-search-tools nil junk-dir))
((configuration-layer/layer-usedp 'spacemacs-ivy)
(require 'counsel)
(counsel-find-file rel-fname))
(arg
(require 'helm)
(let (helm-ff-newfile-prompt-p)
(spacemacs/helm-files-smart-do-search)))
(t
(require 'helm)
(let (helm-ff-newfile-prompt-p)
(helm-find-files-1 fname))))))
(spacemacs/set-leader-keys "fJ" 'spacemacs/open-junk-file)))
(defun spacemacs/init-info+ ()
(use-package info+
@ -1478,7 +1117,7 @@ Open junk file using helm, with `prefix-arg' search in junk files"
:init
(spacemacs|define-micro-state move-text
:doc "[J] move down [K] move up"
:use-minibuffer t
:use-minibuffer t
:execute-binding-on-enter t
:evil-leader "xJ" "xK"
:bindings
@ -1966,3 +1605,4 @@ Open junk file using helm, with `prefix-arg' search in junk files"
;; Font size, either with ctrl + mouse wheel
(global-set-key (kbd "<C-wheel-up>") 'spacemacs/zoom-frm-in)
(global-set-key (kbd "<C-wheel-down>") 'spacemacs/zoom-frm-out))))

View file

@ -44,7 +44,8 @@
"l" 'tetris-move-right
"q" 'spacemacs/tetris-quit-game))))
(defun games/init-helm-games ()
(use-package helm-games
:commands helm-games
:init (spacemacs/set-leader-keys "aG" 'helm-games)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun games/init-helm-games ()
(use-package helm-games
:commands helm-games
:init (spacemacs/set-leader-keys "aG" 'helm-games))))

View file

@ -1,10 +1,9 @@
(setq rcirc-post-extensions
'(
helm-rcirc
))
'(helm-rcirc))
(defun rcirc/init-helm-rcirc ()
(use-package helm-rcirc
:commands helm-rcirc-auto-join-channels
:init
(spacemacs/set-leader-keys "irc" 'helm-rcirc-auto-join-channels)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun rcirc/init-helm-rcirc ()
(use-package helm-rcirc
:commands helm-rcirc-auto-join-channels
:init
(spacemacs/set-leader-keys "irc" 'helm-rcirc-auto-join-channels))))

View file

@ -105,9 +105,10 @@
;; Non-nil means display source file containing the main routine at startup
gdb-show-main t)))
(defun c-c++/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'c-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'c++-mode))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun c-c++/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'c-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'c++-mode)))
(defun c-c++/post-init-semantic ()
(semantic/enable-semantic-mode 'c-mode)
@ -136,8 +137,9 @@
(dolist (mode '(c-mode c++-mode))
(spacemacs/set-leader-keys-for-major-mode mode "gi" 'cscope-index-files))))
(defun c-c++/pre-init-helm-cscope ()
(spacemacs|use-package-add-hook xcscope
:post-init
(dolist (mode '(c-mode c++-mode))
(spacemacs/setup-helm-cscope mode))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun c-c++/pre-init-helm-cscope ()
(spacemacs|use-package-add-hook xcscope
:post-init
(dolist (mode '(c-mode c++-mode))
(spacemacs/setup-helm-cscope mode)))))

View file

@ -113,12 +113,13 @@
(use-package haml-mode
:defer t))
(defun html/init-helm-css-scss ()
(use-package helm-css-scss
:defer t
:init
(dolist (mode '(css-mode scss-mode))
(spacemacs/set-leader-keys-for-major-mode mode "gh" 'helm-css-scss))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun html/init-helm-css-scss ()
(use-package helm-css-scss
:defer t
:init
(dolist (mode '(css-mode scss-mode))
(spacemacs/set-leader-keys-for-major-mode mode "gh" 'helm-css-scss)))))
(defun html/init-jade-mode ()
(use-package jade-mode

View file

@ -44,8 +44,9 @@
(defun php/post-init-ggtags ()
(add-hook 'php-mode-hook 'ggtags-mode))
(defun php/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'php-mode))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun php/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'php-mode)))
(defun php/init-php-auto-yasnippets ()
(use-package php-auto-yasnippets

View file

@ -284,11 +284,12 @@
(use-package hy-mode
:defer t))
(defun python/init-helm-pydoc ()
(use-package helm-pydoc
:defer t
:init
(spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun python/init-helm-pydoc ()
(use-package helm-pydoc
:defer t
:init
(spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc))))
(defun python/post-init-smartparens ()
(defadvice python-indent-dedent-line-backspace
@ -334,7 +335,8 @@ fix this issue."
:post-init
(spacemacs/set-leader-keys-for-major-mode 'python-mode "gi" 'cscope/run-pycscope)))
(defun python/pre-init-helm-cscope ()
(spacemacs|use-package-add-hook xcscope
:post-init
(spacemacs/setup-helm-cscope 'python-mode)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun python/pre-init-helm-cscope ()
(spacemacs|use-package-add-hook xcscope
:post-init
(spacemacs/setup-helm-cscope 'python-mode))))

View file

@ -35,10 +35,11 @@
(evil-define-key 'motion magit-mode-map
(kbd dotspacemacs-leader-key) spacemacs-default-map))))
(defun git/init-helm-gitignore ()
(use-package helm-gitignore
:defer t
:init (spacemacs/set-leader-keys "gI" 'helm-gitignore)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun git/init-helm-gitignore ()
(use-package helm-gitignore
:defer t
:init (spacemacs/set-leader-keys "gI" 'helm-gitignore))))
(defun git/init-git-commit ()
(use-package git-commit
@ -105,8 +106,11 @@
magit-status)
:init
(progn
(setq magit-completing-read-function 'magit-builtin-completing-read
magit-revision-show-gravatars '("^Author: " . "^Commit: "))
(setq magit-completing-read-function
(if (configuration-layer/layer-usedp 'spacemacs-ivy)
'ivy-completing-read
'magit-builtin-completing-read))
(setq magit-revision-show-gravatars '("^Author: " . "^Commit: "))
(add-hook 'git-commit-mode-hook 'fci-mode)
;; On Windows, we must use Git GUI to enter username and password
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https

View file

@ -8,21 +8,22 @@
(spacemacs/system-is-mswindows))
(push 'zeal-at-point dash-packages)))
(defun dash/init-helm-dash ()
(use-package helm-dash
:defer t
:init
(spacemacs/set-leader-keys
"dh" 'helm-dash-at-point
"dH" 'helm-dash)
:config
(defun dash//activate-package-docsets (path)
"Add dash docsets from specified PATH."
(setq helm-dash-docsets-path path
helm-dash-common-docsets (helm-dash-installed-docsets))
(message (format "activated %d docsets from: %s"
(length helm-dash-common-docsets) path)))
(dash//activate-package-docsets dash-helm-dash-docset-path)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun dash/init-helm-dash ()
(use-package helm-dash
:defer t
:init
(spacemacs/set-leader-keys
"dh" 'helm-dash-at-point
"dH" 'helm-dash)
:config
(defun dash//activate-package-docsets (path)
"Add dash docsets from specified PATH."
(setq helm-dash-docsets-path path
helm-dash-common-docsets (helm-dash-installed-docsets))
(message (format "activated %d docsets from: %s"
(length helm-dash-common-docsets) path)))
(dash//activate-package-docsets dash-helm-dash-docset-path))))
(defun dash/init-dash-at-point ()
(use-package dash-at-point

View file

@ -118,6 +118,22 @@ perspectives does."
(projectile-switch-project-by-name project)))))))
:buffer "*Projectile Layouts*"))
(defun spacemacs/ivy-persp-switch-project (arg)
(interactive "P")
(ivy-read "Switch to Project Perspective:"
(if (projectile-project-p)
(cons (abbreviate-file-name (projectile-project-root))
(projectile-relevant-known-projects))
projectile-known-projects)
:action (lambda (project)
(let ((persp-reset-windows-on-nil-window-conf t))
(persp-switch project)
(let ((projectile-completion-system 'ivy))
(projectile-switch-project-by-name project))))
)
)
;; Autosave ----------------------------------------------------------------
(defun spacemacs//layout-autosave ()

View file

@ -16,7 +16,9 @@
:repo "syl20bnr/persp-mode.el"
:branch "fix-emacsclient-crash"))
spaceline
eyebrowse))
eyebrowse
helm
swiper))
(defun spacemacs-layouts/init-persp-mode ()
(use-package persp-mode
@ -313,3 +315,11 @@ format so they are supported by the
(add-hook 'persp-before-switch-functions #'spacemacs/update-eyebrowse-for-perspective)
(add-hook 'eyebrowse-post-window-switch-hook #'spacemacs/save-eyebrowse-for-perspective)
(add-hook 'persp-activated-hook #'spacemacs/load-eyebrowse-for-perspective))
(defun spacemacs-layouts/post-init-helm ()
(spacemacs/set-leader-keys
"pl" 'spacemacs/helm-persp-switch-project))
(defun spacemacs-layouts/post-init-swiper ()
(spacemacs/set-leader-keys
"pl" 'spacemacs/ivy-persp-switch-project))

View file

@ -142,27 +142,29 @@
:defer t
:init (add-hook 'company-mode-hook 'company-quickhelp-mode)))
(defun auto-completion/init-helm-c-yasnippet ()
(use-package helm-c-yasnippet
:defer t
:init
(progn
(defun spacemacs/helm-yas ()
"Properly lazy load helm-c-yasnipper."
(interactive)
(spacemacs/load-yasnippet)
(require 'helm-c-yasnippet)
(call-interactively 'helm-yas-complete))
(spacemacs/set-leader-keys "is" 'spacemacs/helm-yas)
(setq helm-c-yas-space-match-any-greedy t))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun auto-completion/init-helm-c-yasnippet ()
(use-package helm-c-yasnippet
:defer t
:init
(progn
(defun spacemacs/helm-yas ()
"Properly lazy load helm-c-yasnipper."
(interactive)
(spacemacs/load-yasnippet)
(require 'helm-c-yasnippet)
(call-interactively 'helm-yas-complete))
(spacemacs/set-leader-keys "is" 'spacemacs/helm-yas)
(setq helm-c-yas-space-match-any-greedy t)))))
(defun auto-completion/init-helm-company ()
(use-package helm-company
:if (configuration-layer/package-usedp 'company)
:defer t
:init
(with-eval-after-load 'company
(define-key company-active-map (kbd "C-/") 'helm-company))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun auto-completion/init-helm-company ()
(use-package helm-company
:if (configuration-layer/package-usedp 'company)
:defer t
:init
(with-eval-after-load 'company
(define-key company-active-map (kbd "C-/") 'helm-company)))))
(defun auto-completion/init-hippie-exp ()
;; replace dabbrev-expand

View file

@ -45,18 +45,19 @@
(format "pycscope -R -f '%s'"
(expand-file-name "cscope.out" directory))))))))
(defun cscope/init-helm-cscope ()
(use-package helm-cscope
:defer t
:init
(defun spacemacs/setup-helm-cscope (mode)
"Setup `helm-cscope' for MODE"
(spacemacs/set-leader-keys-for-major-mode mode
"gc" 'helm-cscope-find-called-function
"gC" 'helm-cscope-find-calling-this-funtcion
"gd" 'helm-cscope-find-global-definition
"ge" 'helm-cscope-find-egrep-pattern
"gf" 'helm-cscope-find-this-file
"gF" 'helm-cscope-find-files-including-file
"gr" 'helm-cscope-find-this-symbol
"gx" 'helm-cscope-find-this-text-string))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun cscope/init-helm-cscope ()
(use-package helm-cscope
:defer t
:init
(defun spacemacs/setup-helm-cscope (mode)
"Setup `helm-cscope' for MODE"
(spacemacs/set-leader-keys-for-major-mode mode
"gc" 'helm-cscope-find-called-function
"gC" 'helm-cscope-find-calling-this-funtcion
"gd" 'helm-cscope-find-global-definition
"ge" 'helm-cscope-find-egrep-pattern
"gf" 'helm-cscope-find-this-file
"gF" 'helm-cscope-find-files-including-file
"gr" 'helm-cscope-find-this-symbol
"gx" 'helm-cscope-find-this-text-string)))))

View file

@ -20,33 +20,34 @@
(use-package ggtags
:defer t))
(defun gtags/init-helm-gtags ()
(use-package helm-gtags
:defer t
:init
(progn
(setq helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t)
;; modes that do not have a layer, define here
(spacemacs/helm-gtags-define-keys-for-mode 'tcl-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'java-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'vhdl-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'shell-script-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'awk-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'asm-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'dired-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'compilation-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'shell-mode)
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun gtags/init-helm-gtags ()
(use-package helm-gtags
:defer t
:init
(progn
(setq helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t)
;; modes that do not have a layer, define here
(spacemacs/helm-gtags-define-keys-for-mode 'tcl-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'java-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'vhdl-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'shell-script-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'awk-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'asm-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'dired-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'compilation-mode)
(spacemacs/helm-gtags-define-keys-for-mode 'shell-mode)
(spacemacs/ggtags-enable-eldoc 'tcl-mode)
(spacemacs/ggtags-enable-eldoc 'java-mode)
(spacemacs/ggtags-enable-eldoc 'vhdl-mode))
:config
(progn
;; if anyone uses helm-gtags, they would want to use these key bindings
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
(define-key helm-gtags-mode-map (kbd "C-x 4 .") 'helm-gtags-find-tag-other-window)
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
(define-key helm-gtags-mode-map (kbd "M-*") 'helm-gtags-pop-stack))))
(spacemacs/ggtags-enable-eldoc 'tcl-mode)
(spacemacs/ggtags-enable-eldoc 'java-mode)
(spacemacs/ggtags-enable-eldoc 'vhdl-mode))
:config
(progn
;; if anyone uses helm-gtags, they would want to use these key bindings
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
(define-key helm-gtags-mode-map (kbd "C-x 4 .") 'helm-gtags-find-tag-other-window)
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
(define-key helm-gtags-mode-map (kbd "M-*") 'helm-gtags-pop-stack)))))

View file

@ -10,11 +10,12 @@
(defun nixos/init-nixos-options ()
(use-package nixos-options))
(defun nixos/init-helm-nixos-options ()
(use-package helm-nixos-options
:config
(spacemacs/set-leader-keys
"h>" 'helm-nixos-options)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun nixos/init-helm-nixos-options ()
(use-package helm-nixos-options
:config
(spacemacs/set-leader-keys
"h>" 'helm-nixos-options))))
(when (configuration-layer/layer-usedp 'auto-completion)
(defun nixos/post-init-company ()

View file

@ -73,12 +73,13 @@
:if (spacemacs/system-is-mac)
:commands reveal-in-osx-finder))
(defun osx/pre-init-helm ()
;; Use `mdfind' instead of `locate'.
(when (spacemacs/system-is-mac)
(spacemacs|use-package-add-hook helm
:post-config
;; Disable fuzzy matchting to make mdfind work with helm-locate
;; https://github.com/emacs-helm/helm/issues/799
(setq helm-locate-fuzzy-match nil)
(setq helm-locate-command "mdfind -name %s %s"))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun osx/pre-init-helm ()
;; Use `mdfind' instead of `locate'.
(when (spacemacs/system-is-mac)
(spacemacs|use-package-add-hook helm
:post-config
;; Disable fuzzy matchting to make mdfind work with helm-locate
;; https://github.com/emacs-helm/helm/issues/799
(setq helm-locate-fuzzy-match nil)
(setq helm-locate-command "mdfind -name %s %s")))))

View file

@ -176,33 +176,34 @@ is achieved by adding the relevant text properties."
(setq eshell-highlight-prompt nil
eshell-prompt-function 'epe-theme-lambda)))
(defun shell/pre-init-helm ()
(spacemacs|use-package-add-hook helm
:post-init
(progn
;; eshell
(defun spacemacs/helm-eshell-history ()
"Correctly revert to insert state after selection."
(interactive)
(helm-eshell-history)
(evil-insert-state))
(defun spacemacs/helm-shell-history ()
"Correctly revert to insert state after selection."
(interactive)
(helm-comint-input-ring)
(evil-insert-state))
(defun spacemacs/init-helm-eshell ()
"Initialize helm-eshell."
;; this is buggy for now
;; (define-key eshell-mode-map (kbd "<tab>") 'helm-esh-pcomplete)
(spacemacs/set-leader-keys-for-major-mode 'eshell-mode
"H" 'spacemacs/helm-eshell-history)
(define-key eshell-mode-map
(kbd "M-l") 'spacemacs/helm-eshell-history))
(add-hook 'eshell-mode-hook 'spacemacs/init-helm-eshell)
;;shell
(spacemacs/set-leader-keys-for-major-mode 'shell-mode
"H" 'spacemacs/helm-shell-history))))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun shell/pre-init-helm ()
(spacemacs|use-package-add-hook helm
:post-init
(progn
;; eshell
(defun spacemacs/helm-eshell-history ()
"Correctly revert to insert state after selection."
(interactive)
(helm-eshell-history)
(evil-insert-state))
(defun spacemacs/helm-shell-history ()
"Correctly revert to insert state after selection."
(interactive)
(helm-comint-input-ring)
(evil-insert-state))
(defun spacemacs/init-helm-eshell ()
"Initialize helm-eshell."
;; this is buggy for now
;; (define-key eshell-mode-map (kbd "<tab>") 'helm-esh-pcomplete)
(spacemacs/set-leader-keys-for-major-mode 'eshell-mode
"H" 'spacemacs/helm-eshell-history)
(define-key eshell-mode-map
(kbd "M-l") 'spacemacs/helm-eshell-history))
(add-hook 'eshell-mode-hook 'spacemacs/init-helm-eshell)
;;shell
(spacemacs/set-leader-keys-for-major-mode 'shell-mode
"H" 'spacemacs/helm-shell-history)))))
(defun shell/init-multi-term ()
(use-package multi-term

View file

@ -12,31 +12,57 @@
(setq smex-packages '(smex))
(defun smex/init-smex ()
(use-package smex
:defer t
:init
(progn
(setq-default smex-history-length 32
smex-save-file (concat spacemacs-cache-directory
".smex-items"))
(if (configuration-layer/layer-usedp 'spacemacs-ivy)
(defun smex/post-init-smex ()
(use-package smex
:defer t
:init
(progn
(defun spacemacs/smex ()
"Execute smex with a better prompt."
(interactive)
(let ((smex-prompt-string "Emacs commands: "))
(smex)))
(defun spacemacs/smex ()
"Execute smex with a better prompt."
(interactive)
(let ((smex-prompt-string "Emacs commands: "))
(smex)))
(defun spacemacs/smex-major-mode-commands ()
"Reexecute smex with major mode commands only."
(interactive)
(let ((smex-prompt-string (format "%s commands: " major-mode)))
(smex-major-mode-commands)))
(defun spacemacs/smex-major-mode-commands ()
"Reexecute smex with major mode commands only."
(interactive)
(let ((smex-prompt-string (format "%s commands: " major-mode)))
(smex-major-mode-commands)))
;; define the key binding at the very end in order to allow the user
;; to overwrite any key binding
(add-hook 'emacs-startup-hook
(lambda () (spacemacs/set-leader-keys
dotspacemacs-emacs-command-key 'spacemacs/smex)))
(spacemacs/set-leader-keys ":" 'spacemacs/smex-major-mode-commands)
(global-set-key (kbd "M-x") 'spacemacs/smex))))
;; define the key binding at the very end in order to allow the user
;; to overwrite any key binding
(add-hook 'emacs-startup-hook
(lambda () (spacemacs/set-leader-keys
dotspacemacs-emacs-command-key 'spacemacs/smex)))
(spacemacs/set-leader-keys ":" 'spacemacs/smex-major-mode-commands)
(global-set-key (kbd "M-x") 'spacemacs/smex))))
(defun smex/init-smex ()
(use-package smex
:defer t
:init
(progn
(setq-default smex-history-length 32
smex-save-file (concat spacemacs-cache-directory
".smex-items"))
(defun spacemacs/smex ()
"Execute smex with a better prompt."
(interactive)
(let ((smex-prompt-string "Emacs commands: "))
(smex)))
(defun spacemacs/smex-major-mode-commands ()
"Reexecute smex with major mode commands only."
(interactive)
(let ((smex-prompt-string (format "%s commands: " major-mode)))
(smex-major-mode-commands)))
;; define the key binding at the very end in order to allow the user
;; to overwrite any key binding
(add-hook 'emacs-startup-hook
(lambda () (spacemacs/set-leader-keys dotspacemacs-command-key
'spacemacs/smex)))
(spacemacs/set-leader-keys ":" 'spacemacs/smex-major-mode-commands)
(global-set-key (kbd "M-x") 'spacemacs/smex)))))

View file

@ -64,7 +64,8 @@
:config
(spacemacs|diminish flyspell-mode "" " S")))
(defun spell-checking/init-helm-flyspell ()
(use-package helm-flyspell
:commands helm-flyspell-correct
:init (spacemacs/set-leader-keys "Sc" 'helm-flyspell-correct)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun spell-checking/init-helm-flyspell ()
(use-package helm-flyspell
:commands helm-flyspell-correct
:init (spacemacs/set-leader-keys "Sc" 'helm-flyspell-correct))))

View file

@ -20,7 +20,8 @@
"amsN" 'spotify-previous
"amsQ" 'spotify-quit)))
(defun spotify/init-helm-spotify ()
(use-package helm-spotify
:config (spacemacs/set-leader-keys
"amsg" 'helm-spotify)))
(when (configuration-layer/layer-usedp 'spacemacs-helm)
(defun spotify/init-helm-spotify ()
(use-package helm-spotify
:config (spacemacs/set-leader-keys
"amsg" 'helm-spotify))))