Dispatch function spacemacs/jump-in-buffer to layers

Use imenu init and post-init functions to leverage the layer system and
get better isolation of configuration.
This commit is contained in:
syl20bnr 2016-08-25 20:42:01 -04:00
parent 0191a81ad2
commit e4b15b16de
6 changed files with 22 additions and 14 deletions

View File

@ -179,6 +179,14 @@ Ensure that helm is required before calling FUNC."
(interactive)
(helm-exit-and-execute-action 'spacemacs//helm-find-files-edit))
(defun spacemacs/helm-jump-in-buffer ()
"Jump in buffer using `imenu' facilities and helm."
(interactive)
(call-interactively
(cond
((eq major-mode 'org-mode) 'helm-org-in-buffer-headings)
(t 'helm-semantic-or-imenu))))
;; Generalized next-error interface

View File

@ -24,6 +24,7 @@
helm-swoop
helm-themes
(helm-spacemacs-help :location local)
imenu
popwin
projectile
))
@ -581,6 +582,9 @@ Search for a search tool in the order provided by `dotspacemacs-search-tools'."
(spacemacs/set-leader-keys
"Ts" 'helm-themes)))
(defun helm/post-init-imenu ()
(spacemacs/set-leader-keys "ji" 'spacemacs/helm-jump-in-buffer))
(defun helm/post-init-popwin ()
;; disable popwin-mode while Helm session is running
(add-hook 'helm-after-initialize-hook #'spacemacs//helm-prepare-display)

View File

@ -17,6 +17,7 @@
evil
flx
helm-make
imenu
ivy
ivy-hydra
(ivy-spacemacs-help :location local)
@ -133,6 +134,9 @@
"cc" 'helm-make-projectile
"cm" 'helm-make))))
(defun ivy/post-init-imenu ()
(spacemacs/set-leader-keys "ji" 'counsel-imenu))
(defun ivy/init-ivy ()
(use-package ivy
:config

View File

@ -61,19 +61,6 @@
(let ((message-log-max nil))
(apply 'message msg args)))
(defun spacemacs/jump-in-buffer ()
(interactive)
(call-interactively
(cond
((and (configuration-layer/layer-usedp 'helm)
(eq major-mode 'org-mode))
'helm-org-in-buffer-headings)
((configuration-layer/layer-usedp 'helm)
'helm-semantic-or-imenu)
((configuration-layer/layer-usedp 'ivy)
'counsel-imenu)
(t 'imenu))))
(defun spacemacs/split-and-new-line ()
"Split a quoted string or s-expression and insert a new line with
auto-indent."

View File

@ -221,7 +221,6 @@
"j$" 'spacemacs/push-mark-and-goto-end-of-line
"jF" 'find-function-at-point
"jf" 'find-function
"ji" 'spacemacs/jump-in-buffer
"jv" 'find-variable
"jV" 'find-variable-at-point)

View File

@ -32,6 +32,7 @@
(holy-mode :location local :step pre)
(hybrid-mode :location local :step pre)
(image-mode :location built-in)
(imenu :location built-in)
(linum :location built-in)
(occur-mode :location built-in)
(package-menu :location built-in)
@ -225,6 +226,11 @@
:config (evilified-state-evilify-map image-mode-map
:mode image-mode)))
(defun spacemacs-base/init-imenu ()
(use-package imenu
:defer t
:init (spacemacs/set-leader-keys "ji" 'imenu)))
(defun spacemacs-base/init-linum ()
(when dotspacemacs-line-numbers
(add-hook 'prog-mode-hook 'linum-mode)