2014-12-20 04:48:31 +00:00
|
|
|
;;; helm-spacemacs.el --- Spacemacs layer exploration with `helm'.
|
|
|
|
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; Keywords: helm, spacemacs
|
|
|
|
;; Version: 0.1
|
|
|
|
;; Package-Requires: ((helm "1.5"))
|
|
|
|
|
|
|
|
;; 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 helm.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2015-08-27 06:58:05 +00:00
|
|
|
(require 'cl)
|
2014-12-21 07:53:14 +00:00
|
|
|
(require 'ht)
|
2015-01-27 05:16:44 +00:00
|
|
|
(require 'helm)
|
2015-11-11 21:49:07 +00:00
|
|
|
(require 'helm-command)
|
2015-10-05 15:34:57 +00:00
|
|
|
(require 'helm-org)
|
2015-01-27 05:16:44 +00:00
|
|
|
(require 'core-configuration-layer)
|
2014-12-21 07:53:14 +00:00
|
|
|
|
2015-08-12 12:59:25 +00:00
|
|
|
(defvar helm-spacemacs-all-layers nil
|
2014-12-21 07:53:14 +00:00
|
|
|
"Alist of all configuration layers.")
|
|
|
|
|
2015-08-12 12:59:25 +00:00
|
|
|
(defvar helm-spacemacs-all-packages nil
|
2014-12-21 07:53:14 +00:00
|
|
|
"Hash table of all packages in all layers.")
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode helm-spacemacs-mode
|
|
|
|
"Layers discovery with helm interface."
|
|
|
|
:group 'spacemacs
|
2015-08-12 12:59:25 +00:00
|
|
|
:global t)
|
|
|
|
|
|
|
|
(defun helm-spacemacs//init (&optional arg)
|
|
|
|
(when (or arg (null helm-spacemacs-all-packages))
|
|
|
|
(mapc (lambda (layer) (push (configuration-layer/make-layer layer)
|
|
|
|
helm-spacemacs-all-layers))
|
|
|
|
(configuration-layer/get-layers-list))
|
|
|
|
(dolist (layer helm-spacemacs-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))))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2015-08-12 12:59:25 +00:00
|
|
|
(defun helm-spacemacs (arg)
|
2014-12-20 04:48:31 +00:00
|
|
|
"Layers discovery with helm interface."
|
2015-08-12 12:59:25 +00:00
|
|
|
(interactive "P")
|
2014-12-21 07:53:14 +00:00
|
|
|
(helm-spacemacs-mode)
|
2015-08-12 12:59:25 +00:00
|
|
|
(helm-spacemacs//init arg)
|
2014-12-20 04:48:31 +00:00
|
|
|
(helm :buffer "*helm: spacemacs*"
|
2015-06-06 17:24:48 +00:00
|
|
|
:sources `(,(helm-spacemacs//documentation-source)
|
|
|
|
,(helm-spacemacs//layer-source)
|
2015-01-29 05:08:48 +00:00
|
|
|
,(helm-spacemacs//package-source)
|
2015-05-16 04:49:38 +00:00
|
|
|
,(helm-spacemacs//dotspacemacs-source)
|
2015-10-05 15:34:57 +00:00
|
|
|
,(helm-spacemacs//toggle-source)
|
|
|
|
,(helm-spacemacs//faq-source))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun helm-spacemacs-faq (arg)
|
|
|
|
"Looking in the FAQ with helm."
|
|
|
|
(interactive "P")
|
|
|
|
(helm-spacemacs-mode)
|
|
|
|
(helm :buffer "*helm: spacemacs*"
|
|
|
|
:sources `(,(helm-spacemacs//faq-source))))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2015-06-06 17:24:48 +00:00
|
|
|
(defun helm-spacemacs//documentation-source ()
|
|
|
|
"Construct the helm source for the documentation section."
|
2015-06-10 05:32:44 +00:00
|
|
|
(helm-build-sync-source "Spacemacs Documentation"
|
2015-06-10 02:56:08 +00:00
|
|
|
:candidates #'helm-spacemacs//documentation-candidates
|
|
|
|
:persistent-action #'helm-spacemacs//documentation-action-open-file
|
|
|
|
:keymap helm-map
|
|
|
|
:action (helm-make-actions
|
|
|
|
"Open Documentation" #'helm-spacemacs//documentation-action-open-file)))
|
2015-06-06 17:24:48 +00:00
|
|
|
|
|
|
|
(defun helm-spacemacs//documentation-candidates ()
|
2015-06-10 15:06:30 +00:00
|
|
|
(let (result file-extension)
|
2015-06-18 06:54:48 +00:00
|
|
|
(dolist (filename (directory-files spacemacs-docs-directory))
|
|
|
|
(setq file-extension (file-name-extension filename))
|
2015-06-10 15:06:30 +00:00
|
|
|
(when (or (equal file-extension "md")
|
|
|
|
(equal file-extension "org"))
|
2015-06-18 06:54:48 +00:00
|
|
|
(push filename result)))
|
Refactor CONTRIBUTING documentations
This commit merge the `CONTRIBUTING.md` and `doc/CONTRIBUTE.org` file
into a new `CONTRIBUTING.org` file. It also refactors the content to be
more organized and make its navigation more goal-oriented.
Github displays a link to the `CONTRIBUTING.*` file when people are
opening new issues or proposing new PRs. This file is important because
it is the entry-point to contributions guidelines for most of the users.
The current setup is non-optimal, even broken, as it adds a level of
indirection, and points to a contributing file that has broken
links (due to the new documentation format). The possible drawback of
the proposed solution is that I'm not sure if it is possible to include
it into the new online documentation as it is not in `doc/` folder.
The other possibility is to keep a small `CONTRIBUTING.md` file, as it
is now, pointing to the new documentation system (once online), but I'm
preferring the proposed solution for the following reasons:
- People that are willing to contribute will probably open Github
first (for forking, creating PR, etc), not the online documentation.
- It has one level of indirection less when people click on the
guidelines guide from a new issue/PR.
- `CONTRIBUTING.*` is by convention a special kind of file on github, so
it's valid reason to break the rule and not having it in the `doc/`
folder.
2015-11-22 13:11:08 +00:00
|
|
|
|
|
|
|
;; 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)
|
|
|
|
|
2015-06-11 05:00:54 +00:00
|
|
|
;; delete DOCUMENTATION.org to make it the first guide
|
|
|
|
(delete "DOCUMENTATION.org" result)
|
|
|
|
(push "DOCUMENTATION.org" result)
|
2015-06-10 02:56:08 +00:00
|
|
|
|
|
|
|
;; give each document an appropriate title
|
|
|
|
(mapcar (lambda (r)
|
|
|
|
(cond
|
Refactor CONTRIBUTING documentations
This commit merge the `CONTRIBUTING.md` and `doc/CONTRIBUTE.org` file
into a new `CONTRIBUTING.org` file. It also refactors the content to be
more organized and make its navigation more goal-oriented.
Github displays a link to the `CONTRIBUTING.*` file when people are
opening new issues or proposing new PRs. This file is important because
it is the entry-point to contributions guidelines for most of the users.
The current setup is non-optimal, even broken, as it adds a level of
indirection, and points to a contributing file that has broken
links (due to the new documentation format). The possible drawback of
the proposed solution is that I'm not sure if it is possible to include
it into the new online documentation as it is not in `doc/` folder.
The other possibility is to keep a small `CONTRIBUTING.md` file, as it
is now, pointing to the new documentation system (once online), but I'm
preferring the proposed solution for the following reasons:
- People that are willing to contribute will probably open Github
first (for forking, creating PR, etc), not the online documentation.
- It has one level of indirection less when people click on the
guidelines guide from a new issue/PR.
- `CONTRIBUTING.*` is by convention a special kind of file on github, so
it's valid reason to break the rule and not having it in the `doc/`
folder.
2015-11-22 13:11:08 +00:00
|
|
|
((string-equal r "CONTRIBUTING.org")
|
2015-06-10 02:56:08 +00:00
|
|
|
`("How to contribute to Spacemacs" . ,r))
|
2015-06-11 05:00:54 +00:00
|
|
|
((string-equal r "CONVENTIONS.org")
|
2015-06-10 02:56:08 +00:00
|
|
|
`("Spacemacs conventions" . ,r))
|
2015-06-11 05:00:54 +00:00
|
|
|
((string-equal r "DOCUMENTATION.org")
|
2015-09-24 04:17:37 +00:00
|
|
|
`("Spacemacs documentation" . ,r))
|
|
|
|
((string-equal r "FAQ.org")
|
|
|
|
`("Spacemacs FAQ" . ,r))
|
2015-06-11 05:00:54 +00:00
|
|
|
((string-equal r "HOWTOs.org")
|
2015-06-10 02:56:08 +00:00
|
|
|
`("Quick HOW-TOs for Spacemacs" . ,r))
|
2015-08-05 20:09:58 +00:00
|
|
|
((string-equal r "LAYERS.org")
|
|
|
|
`("Tips on writing layers for Spacemacs" . ,r))
|
2015-09-24 04:17:37 +00:00
|
|
|
((string-equal r "QUICK_START.org")
|
|
|
|
`("Quick start guide for Spacemacs" . ,r))
|
2015-06-10 02:56:08 +00:00
|
|
|
((string-equal r "VIMUSERS.org")
|
|
|
|
`("Vim users migration guide" . ,r))
|
|
|
|
(t
|
|
|
|
`(r . ,r))))
|
|
|
|
result)))
|
2015-06-06 17:24:48 +00:00
|
|
|
|
|
|
|
(defun helm-spacemacs//documentation-action-open-file (candidate)
|
|
|
|
"Open documentation FILE."
|
Refactor CONTRIBUTING documentations
This commit merge the `CONTRIBUTING.md` and `doc/CONTRIBUTE.org` file
into a new `CONTRIBUTING.org` file. It also refactors the content to be
more organized and make its navigation more goal-oriented.
Github displays a link to the `CONTRIBUTING.*` file when people are
opening new issues or proposing new PRs. This file is important because
it is the entry-point to contributions guidelines for most of the users.
The current setup is non-optimal, even broken, as it adds a level of
indirection, and points to a contributing file that has broken
links (due to the new documentation format). The possible drawback of
the proposed solution is that I'm not sure if it is possible to include
it into the new online documentation as it is not in `doc/` folder.
The other possibility is to keep a small `CONTRIBUTING.md` file, as it
is now, pointing to the new documentation system (once online), but I'm
preferring the proposed solution for the following reasons:
- People that are willing to contribute will probably open Github
first (for forking, creating PR, etc), not the online documentation.
- It has one level of indirection less when people click on the
guidelines guide from a new issue/PR.
- `CONTRIBUTING.*` is by convention a special kind of file on github, so
it's valid reason to break the rule and not having it in the `doc/`
folder.
2015-11-22 13:11:08 +00:00
|
|
|
(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))))
|
2015-06-09 03:32:55 +00:00
|
|
|
(cond ((and (equal (file-name-extension file) "md")
|
|
|
|
(not helm-current-prefix-arg))
|
|
|
|
(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")
|
2015-06-10 15:06:30 +00:00
|
|
|
(spacemacs/view-org-file file "^" 'all))
|
2015-06-09 03:32:55 +00:00
|
|
|
(t
|
|
|
|
(find-file file)))))
|
2015-06-06 17:24:48 +00:00
|
|
|
|
2014-12-20 04:48:31 +00:00
|
|
|
(defun helm-spacemacs//layer-source ()
|
|
|
|
"Construct the helm source for the layer section."
|
|
|
|
`((name . "Layers")
|
2014-12-25 19:45:27 +00:00
|
|
|
(candidates . ,(sort (configuration-layer/get-layers-list) 'string<))
|
2015-03-05 05:00:54 +00:00
|
|
|
(candidate-number-limit)
|
2015-11-20 04:43:01 +00:00
|
|
|
(keymap . ,helm-spacemacs--layer-map)
|
2015-08-09 03:31:02 +00:00
|
|
|
(action . (("Open README.org"
|
|
|
|
. helm-spacemacs//layer-action-open-readme)
|
|
|
|
("Open packages.el"
|
|
|
|
. helm-spacemacs//layer-action-open-packages)
|
|
|
|
;; TODO remove extensions in 0.105.0
|
|
|
|
("Open extensions.el"
|
2015-10-02 18:51:10 +00:00
|
|
|
. helm-spacemacs//layer-action-open-extensions)
|
2015-11-20 04:43:01 +00:00
|
|
|
("Add Layer"
|
|
|
|
. helm-spacemacs//layer-action-add-layer)
|
2015-10-02 18:51:10 +00:00
|
|
|
("Open README.org (for editing)"
|
|
|
|
. helm-spacemacs//layer-action-open-readme-edit)))))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2015-11-20 04:43:01 +00:00
|
|
|
(defvar helm-spacemacs--layer-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(set-keymap-parent map helm-map)
|
|
|
|
(define-key map (kbd "<S-return>") '(lambda () (interactive)
|
|
|
|
;; Add Layer
|
|
|
|
(helm-select-nth-action 3)))
|
|
|
|
map)
|
|
|
|
"Keymap for Spacemacs Layers sources")
|
|
|
|
|
2014-12-21 07:53:14 +00:00
|
|
|
(defun helm-spacemacs//package-source ()
|
|
|
|
"Construct the helm source for the packages."
|
|
|
|
`((name . "Packages")
|
|
|
|
(candidates . ,(helm-spacemacs//package-candidates))
|
2015-03-05 05:00:54 +00:00
|
|
|
(candidate-number-limit)
|
2015-08-09 03:31:02 +00:00
|
|
|
(action . (("Go to init function"
|
|
|
|
. helm-spacemacs//package-action-goto-init-func)))))
|
2014-12-21 07:53:14 +00:00
|
|
|
|
|
|
|
(defun helm-spacemacs//package-candidates ()
|
|
|
|
"Return the sorted candidates for package source."
|
|
|
|
(let (result)
|
2015-08-09 03:31:02 +00:00
|
|
|
(dolist (pkg helm-spacemacs-all-packages)
|
2015-11-11 21:49:07 +00:00
|
|
|
(push (format "%s (%S layer)"
|
|
|
|
(propertize (symbol-name (oref pkg :name))
|
|
|
|
'face 'font-lock-type-face)
|
|
|
|
(oref pkg :owner))
|
2015-08-09 03:31:02 +00:00
|
|
|
result))
|
2014-12-21 07:53:14 +00:00
|
|
|
(sort result 'string<)))
|
|
|
|
|
2015-01-29 05:08:48 +00:00
|
|
|
(defun helm-spacemacs//toggle-source ()
|
|
|
|
"Construct the helm source for the toggles."
|
2015-08-27 06:58:05 +00:00
|
|
|
(helm-build-sync-source "Toggles"
|
|
|
|
:candidates #'helm-spacemacs//toggle-candidates
|
|
|
|
:persistent-action #'helm-spacemacs//toggle
|
|
|
|
:keymap helm-map
|
|
|
|
:action (helm-make-actions "Toggle" #'helm-spacemacs//toggle)))
|
2015-01-29 05:08:48 +00:00
|
|
|
|
|
|
|
(defun helm-spacemacs//toggle-candidates ()
|
|
|
|
"Return the sorted candidates for toggle source."
|
|
|
|
(let (result)
|
|
|
|
(dolist (toggle spacemacs-toggles)
|
2015-08-27 06:58:05 +00:00
|
|
|
(let* ((toggle-symbol (symbol-name (car toggle)))
|
|
|
|
(toggle-name (capitalize (replace-regexp-in-string "-" " " toggle-symbol)))
|
2015-11-11 21:49:07 +00:00
|
|
|
(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)))))
|
2015-08-27 06:58:05 +00:00
|
|
|
(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))
|
2015-01-29 05:08:48 +00:00
|
|
|
|
2015-05-16 04:49:38 +00:00
|
|
|
(defun helm-spacemacs//dotspacemacs-source ()
|
|
|
|
`((name . "Dotfile")
|
|
|
|
(candidates . ,(helm-spacemacs//dotspacemacs-candidates))
|
|
|
|
(candidate-number-limit)
|
|
|
|
(action . (("Go to variable" . helm-spacemacs//go-to-dotfile-variable)))))
|
|
|
|
|
|
|
|
(defun helm-spacemacs//dotspacemacs-candidates ()
|
|
|
|
"Return the sorted candidates for all the dospacemacs variables."
|
2015-09-01 03:16:14 +00:00
|
|
|
(sort (dotspacemacs/get-variable-string-list) 'string<))
|
2015-05-16 04:49:38 +00:00
|
|
|
|
2015-10-02 18:51:10 +00:00
|
|
|
(defun helm-spacemacs//layer-action-open-file (file candidate &optional edit)
|
|
|
|
"Open FILE of the passed CANDIDATE. If EDIT is false, open in view mode."
|
2015-06-12 01:23:50 +00:00
|
|
|
(let ((path (if (and (equalp file "README.org") (equalp candidate "spacemacs"))
|
2015-02-27 16:23:50 +00:00
|
|
|
;; 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)))))
|
2015-06-12 01:23:50 +00:00
|
|
|
(if (and (equal (file-name-extension file) "org")
|
2015-04-29 18:07:05 +00:00
|
|
|
(not helm-current-prefix-arg))
|
2015-10-02 18:51:10 +00:00
|
|
|
(if edit
|
|
|
|
(find-file (concat path file))
|
|
|
|
(spacemacs/view-org-file (concat path file) "^" 'all))
|
2015-04-23 05:20:23 +00:00
|
|
|
(find-file (concat path file)))))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
|
|
|
(defun helm-spacemacs//layer-action-open-readme (candidate)
|
2015-10-02 18:51:10 +00:00
|
|
|
"Open the `README.org' file of the passed CANDIDATE for reading."
|
2015-06-12 01:23:50 +00:00
|
|
|
(helm-spacemacs//layer-action-open-file "README.org" candidate))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2015-11-20 04:43:01 +00:00
|
|
|
(defun helm-spacemacs//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))))
|
|
|
|
|
2015-10-02 18:51:10 +00:00
|
|
|
(defun helm-spacemacs//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))
|
|
|
|
|
2014-12-20 04:48:31 +00:00
|
|
|
(defun helm-spacemacs//layer-action-open-packages (candidate)
|
|
|
|
"Open the `packages.el' file of the passed CANDIDATE."
|
|
|
|
(helm-spacemacs//layer-action-open-file "packages.el" candidate))
|
|
|
|
|
2015-08-09 03:31:02 +00:00
|
|
|
;; TODO remove extensions in 0.105.0
|
2014-12-20 04:48:31 +00:00
|
|
|
(defun helm-spacemacs//layer-action-open-extensions (candidate)
|
|
|
|
"Open the `extensions.el' file of the passed CANDIDATE."
|
|
|
|
(helm-spacemacs//layer-action-open-file "extensions.el" candidate))
|
|
|
|
|
2014-12-21 07:53:14 +00:00
|
|
|
(defun helm-spacemacs//package-action-goto-init-func (candidate)
|
|
|
|
"Open the file `packages.el' and go to the init function."
|
|
|
|
(save-match-data
|
2015-11-12 09:49:31 +00:00
|
|
|
(string-match "^\\(.+\\)\s(\\(.+\\) layer)$" candidate)
|
|
|
|
;; (string-match "^(\\(.+\\))\s\\(.+\\):\s\\(.+\\)$" candidate)
|
|
|
|
(let* ((package (match-string 1 candidate))
|
|
|
|
(layer (match-string 2 candidate))
|
2014-12-21 07:53:14 +00:00
|
|
|
(path (file-name-as-directory
|
2014-12-25 19:45:27 +00:00
|
|
|
(concat (ht-get configuration-layer-paths (intern layer))
|
2014-12-21 07:53:14 +00:00
|
|
|
layer)))
|
2015-11-12 09:49:31 +00:00
|
|
|
(filename (concat path "packages.el")))
|
2014-12-21 07:53:14 +00:00
|
|
|
(find-file filename)
|
2014-12-24 05:21:47 +00:00
|
|
|
(goto-char (point-min))
|
2014-12-21 07:53:14 +00:00
|
|
|
(re-search-forward (format "init-%s" package))
|
|
|
|
(beginning-of-line))))
|
|
|
|
|
2015-01-29 05:08:48 +00:00
|
|
|
(defun helm-spacemacs//toggle (candidate)
|
|
|
|
"Toggle candidate."
|
|
|
|
(let ((toggle (assq (intern candidate) spacemacs-toggles)))
|
|
|
|
(when toggle
|
2015-01-30 05:18:48 +00:00
|
|
|
(funcall (plist-get (cdr toggle) :function)))))
|
2015-01-29 05:08:48 +00:00
|
|
|
|
2015-05-16 04:49:38 +00:00
|
|
|
(defun helm-spacemacs//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))
|
|
|
|
|
2015-10-08 16:09:22 +00:00
|
|
|
(defvar helm-spacemacs--faq-filename
|
|
|
|
(concat spacemacs-docs-directory "FAQ.org")
|
|
|
|
"Location of the FAQ file.")
|
|
|
|
|
2015-10-05 15:34:57 +00:00
|
|
|
(defun helm-spacemacs//faq-source ()
|
|
|
|
"Construct the helm source for the FAQ."
|
|
|
|
`((name . "FAQ")
|
|
|
|
(candidates . ,(helm-spacemacs//faq-candidates))
|
|
|
|
(candidate-number-limit)
|
2015-10-08 16:09:22 +00:00
|
|
|
(action . (("Go to question" . helm-spacemacs//faq-goto-marker)))))
|
2015-10-05 15:34:57 +00:00
|
|
|
|
2015-11-11 21:49:07 +00:00
|
|
|
(defun helm-spacemacs//faq-candidate (cand)
|
|
|
|
(let ((str (substring-no-properties (car cand))))
|
2015-12-18 10:27:37 +00:00
|
|
|
(when (string-match "\\`.*/\\([^/]*\\)/\\(.*\\)\\'" str)
|
2015-11-11 21:49:07 +00:00
|
|
|
(cons (concat (propertize
|
|
|
|
(match-string 1 str)
|
|
|
|
'face 'font-lock-type-face)
|
|
|
|
": " (match-string 2 str))
|
|
|
|
(cdr cand)))))
|
|
|
|
|
2015-10-05 15:34:57 +00:00
|
|
|
(defun helm-spacemacs//faq-candidates ()
|
2015-11-11 21:49:07 +00:00
|
|
|
(delq nil
|
|
|
|
(mapcar 'helm-spacemacs//faq-candidate
|
2015-12-18 10:27:37 +00:00
|
|
|
(helm-org-get-candidates (list helm-spacemacs--faq-filename) 1 8))))
|
2015-10-08 16:09:22 +00:00
|
|
|
|
|
|
|
(defun helm-spacemacs//faq-goto-marker (marker)
|
|
|
|
(find-file helm-spacemacs--faq-filename)
|
|
|
|
(goto-char marker)
|
|
|
|
(org-show-context)
|
|
|
|
(org-show-entry))
|
2015-05-16 04:49:38 +00:00
|
|
|
|
2014-12-20 04:48:31 +00:00
|
|
|
(provide 'helm-spacemacs)
|
|
|
|
|
|
|
|
;;; helm-spacemacs.el ends here
|