2016-01-04 19:20:54 +00:00
|
|
|
;;; helm-spacemacs-help.el --- Spacemacs layer exploration with `helm'.
|
2014-12-20 04:48:31 +00:00
|
|
|
|
|
|
|
;; 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-01-27 05:16:44 +00:00
|
|
|
(require 'core-configuration-layer)
|
2014-12-21 07:53:14 +00:00
|
|
|
|
2016-07-17 19:00:43 +00:00
|
|
|
(defvar helm-spacemacs--initialized nil
|
|
|
|
"Non nil if helm-spacemacs is initialized.")
|
2014-12-21 07:53:14 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2016-01-04 19:20:54 +00:00
|
|
|
(define-minor-mode helm-spacemacs-help-mode
|
2014-12-21 07:53:14 +00:00
|
|
|
"Layers discovery with helm interface."
|
|
|
|
:group 'spacemacs
|
2015-08-12 12:59:25 +00:00
|
|
|
:global t)
|
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//init (&optional arg)
|
2016-07-17 19:00:43 +00:00
|
|
|
(when (or arg (null helm-spacemacs--initialized))
|
2017-01-16 02:40:07 +00:00
|
|
|
(configuration-layer/make-all-packages)
|
|
|
|
(setq helm-spacemacs--initialized t)))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help (arg)
|
2014-12-20 04:48:31 +00:00
|
|
|
"Layers discovery with helm interface."
|
2015-08-12 12:59:25 +00:00
|
|
|
(interactive "P")
|
2016-01-04 19:20:54 +00:00
|
|
|
(helm-spacemacs-help-mode)
|
|
|
|
(helm-spacemacs-help//init arg)
|
2014-12-20 04:48:31 +00:00
|
|
|
(helm :buffer "*helm: spacemacs*"
|
2016-01-04 19:20:54 +00:00
|
|
|
:sources `(,(helm-spacemacs-help//documentation-source)
|
|
|
|
,(helm-spacemacs-help//layer-source)
|
|
|
|
,(helm-spacemacs-help//package-source)
|
|
|
|
,(helm-spacemacs-help//dotspacemacs-source)
|
2017-01-16 02:53:43 +00:00
|
|
|
,(helm-spacemacs-help//toggle-source))))
|
2015-10-05 15:34:57 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2016-01-13 05:37:26 +00:00
|
|
|
(defun helm-spacemacs-help-dotspacemacs ()
|
|
|
|
"Helm session to search for dotfile variables."
|
|
|
|
(interactive)
|
|
|
|
(helm-spacemacs-help-mode)
|
|
|
|
(helm :buffer "*helm: spacemacs*"
|
|
|
|
:sources `(,(helm-spacemacs-help//dotspacemacs-source))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun helm-spacemacs-help-layers ()
|
|
|
|
"Helm session to search for layers."
|
|
|
|
(interactive)
|
|
|
|
(helm-spacemacs-help-mode)
|
|
|
|
(helm :buffer "*helm: spacemacs*"
|
|
|
|
:sources `(,(helm-spacemacs-help//layer-source))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun helm-spacemacs-help-packages (arg)
|
|
|
|
"Helm session to search for packages."
|
2015-10-05 15:34:57 +00:00
|
|
|
(interactive "P")
|
2016-01-04 19:20:54 +00:00
|
|
|
(helm-spacemacs-help-mode)
|
2016-01-13 05:37:26 +00:00
|
|
|
(helm-spacemacs-help//init arg)
|
|
|
|
(helm :buffer "*helm: spacemacs*"
|
|
|
|
:sources `(,(helm-spacemacs-help//package-source))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun helm-spacemacs-help-docs ()
|
|
|
|
"Helm session to search for documentation."
|
|
|
|
(interactive)
|
|
|
|
(helm-spacemacs-help-mode)
|
|
|
|
(helm :buffer "*helm: spacemacs*"
|
|
|
|
:sources `(,(helm-spacemacs-help//documentation-source))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun helm-spacemacs-help-toggles ()
|
|
|
|
"Helm session to search for toggles."
|
|
|
|
(interactive)
|
|
|
|
(helm-spacemacs-help-mode)
|
|
|
|
(helm :buffer "*helm: spacemacs*"
|
|
|
|
:sources `(,(helm-spacemacs-help//toggle-source))))
|
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//documentation-source ()
|
2015-06-06 17:24:48 +00:00
|
|
|
"Construct the helm source for the documentation section."
|
2015-06-10 05:32:44 +00:00
|
|
|
(helm-build-sync-source "Spacemacs Documentation"
|
2016-01-04 19:20:54 +00:00
|
|
|
:candidates #'helm-spacemacs-help//documentation-candidates
|
|
|
|
:persistent-action #'helm-spacemacs-help//documentation-action-open-file
|
2015-06-10 02:56:08 +00:00
|
|
|
:keymap helm-map
|
|
|
|
:action (helm-make-actions
|
2016-01-04 19:20:54 +00:00
|
|
|
"Open Documentation" #'helm-spacemacs-help//documentation-action-open-file)))
|
2015-06-06 17:24:48 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//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
|
2017-01-02 04:09:32 +00:00
|
|
|
((string-equal r "BEGINNERS_TUTORIAL.org")
|
|
|
|
`("Beginners tutorial" . ,r))
|
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-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
|
2016-04-08 20:04:54 +00:00
|
|
|
`(,r . ,r))))
|
2015-06-10 02:56:08 +00:00
|
|
|
result)))
|
2015-06-06 17:24:48 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//documentation-action-open-file (candidate)
|
2015-06-06 17:24:48 +00:00
|
|
|
"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.
|
2016-06-23 04:19:12 +00:00
|
|
|
(concat spacemacs-start-directory candidate)
|
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
|
|
|
(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))
|
2016-02-24 15:32:45 +00:00
|
|
|
(condition-case-unless-debug nil
|
2015-06-09 03:32:55 +00:00
|
|
|
(with-current-buffer (find-file-noselect file)
|
|
|
|
(gh-md-render-buffer)
|
2016-06-04 12:46:31 +00:00
|
|
|
(spacemacs/kill-this-buffer))
|
2015-06-09 03:32:55 +00:00
|
|
|
;; 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
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//layer-source ()
|
2014-12-20 04:48:31 +00:00
|
|
|
"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)
|
2016-01-04 19:20:54 +00:00
|
|
|
(keymap . ,helm-spacemacs-help--layer-map)
|
2015-08-09 03:31:02 +00:00
|
|
|
(action . (("Open README.org"
|
2016-01-04 19:20:54 +00:00
|
|
|
. helm-spacemacs-help//layer-action-open-readme)
|
2015-08-09 03:31:02 +00:00
|
|
|
("Open packages.el"
|
2016-01-04 19:20:54 +00:00
|
|
|
. helm-spacemacs-help//layer-action-open-packages)
|
2016-07-16 08:56:50 +00:00
|
|
|
("Open config.el"
|
|
|
|
. helm-spacemacs-help//layer-action-open-config)
|
2016-01-12 00:02:22 +00:00
|
|
|
("Install Layer"
|
|
|
|
. helm-spacemacs-help//layer-action-install-layer)
|
2015-10-02 18:51:10 +00:00
|
|
|
("Open README.org (for editing)"
|
2016-01-04 19:20:54 +00:00
|
|
|
. helm-spacemacs-help//layer-action-open-readme-edit)))))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defvar helm-spacemacs-help--layer-map
|
2015-11-20 04:43:01 +00:00
|
|
|
(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)))
|
2016-09-13 02:43:57 +00:00
|
|
|
(define-key map (kbd "<M-return>") '(lambda () (interactive)
|
|
|
|
;; Open packages.el
|
|
|
|
(helm-select-nth-action 1)))
|
2015-11-20 04:43:01 +00:00
|
|
|
map)
|
|
|
|
"Keymap for Spacemacs Layers sources")
|
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//package-source ()
|
2014-12-21 07:53:14 +00:00
|
|
|
"Construct the helm source for the packages."
|
|
|
|
`((name . "Packages")
|
2016-01-04 19:20:54 +00:00
|
|
|
(candidates . ,(helm-spacemacs-help//package-candidates))
|
2015-03-05 05:00:54 +00:00
|
|
|
(candidate-number-limit)
|
2016-06-11 02:48:41 +00:00
|
|
|
(action . (("Go to configuration function"
|
|
|
|
. helm-spacemacs-help//package-action-goto-config-func)
|
2016-02-22 07:29:43 +00:00
|
|
|
("Describe"
|
2017-06-05 02:39:56 +00:00
|
|
|
. helm-spacemacs-help//package-action-describe)))))
|
2014-12-21 07:53:14 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//package-candidates ()
|
2014-12-21 07:53:14 +00:00
|
|
|
"Return the sorted candidates for package source."
|
|
|
|
(let (result)
|
2016-07-17 19:00:43 +00:00
|
|
|
(dolist (pkg-name (configuration-layer/get-packages-list))
|
|
|
|
(let* ((pkg (configuration-layer/get-package pkg-name))
|
|
|
|
(owner (cfgl-package-get-safe-owner pkg))
|
2016-06-11 02:48:41 +00:00
|
|
|
;; the notion of owner does not make sense if the layer is not used
|
2017-07-02 13:48:06 +00:00
|
|
|
(init-type (if (configuration-layer/layer-used-p owner)
|
2016-06-11 02:48:41 +00:00
|
|
|
"owner" "init")))
|
|
|
|
(when owner
|
|
|
|
(push (format "%s (%s: %S layer)"
|
|
|
|
(propertize (symbol-name (oref pkg :name))
|
|
|
|
'face 'font-lock-type-face)
|
|
|
|
init-type
|
|
|
|
owner)
|
|
|
|
result))
|
|
|
|
(dolist (initfuncs `((,(oref pkg :owners) "init")
|
|
|
|
(,(oref pkg :pre-layers) "pre-init")
|
|
|
|
(,(oref pkg :post-layers) "post-init")))
|
|
|
|
(dolist (layer (car initfuncs))
|
|
|
|
(unless (and owner (eq owner layer))
|
|
|
|
(push (format "%s (%s: %S layer)"
|
|
|
|
(propertize (symbol-name (oref pkg :name))
|
|
|
|
'face 'font-lock-type-face)
|
|
|
|
(cadr initfuncs)
|
|
|
|
layer)
|
|
|
|
result))))))
|
2014-12-21 07:53:14 +00:00
|
|
|
(sort result 'string<)))
|
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//toggle-source ()
|
2015-01-29 05:08:48 +00:00
|
|
|
"Construct the helm source for the toggles."
|
2016-06-02 17:15:58 +00:00
|
|
|
(let ((candidates (helm-spacemacs-help//toggle-candidates)))
|
|
|
|
(helm-build-sync-source "Toggles"
|
|
|
|
:candidates candidates
|
|
|
|
:persistent-action #'helm-spacemacs-help//toggle
|
|
|
|
:keymap helm-map
|
|
|
|
:action (helm-make-actions "Toggle" #'helm-spacemacs-help//toggle))))
|
2015-01-29 05:08:48 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//toggle-candidates ()
|
2015-01-29 05:08:48 +00:00
|
|
|
"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)))
|
2016-05-31 13:33:44 +00:00
|
|
|
(toggle-status (funcall (plist-get (cdr toggle) :predicate)))
|
2015-08-27 06:58:05 +00:00
|
|
|
(toggle-name (capitalize (replace-regexp-in-string "-" " " toggle-symbol)))
|
2016-05-31 13:33:44 +00:00
|
|
|
(toggle-doc (format "(%s) %s: %s"
|
|
|
|
(if toggle-status "+" "-")
|
2015-11-11 21:49:07 +00:00
|
|
|
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
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//dotspacemacs-source ()
|
2015-05-16 04:49:38 +00:00
|
|
|
`((name . "Dotfile")
|
2016-01-04 19:20:54 +00:00
|
|
|
(candidates . ,(helm-spacemacs-help//dotspacemacs-candidates))
|
2015-05-16 04:49:38 +00:00
|
|
|
(candidate-number-limit)
|
2016-01-04 19:20:54 +00:00
|
|
|
(action . (("Go to variable" . helm-spacemacs-help//go-to-dotfile-variable)))))
|
2015-05-16 04:49:38 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//dotspacemacs-candidates ()
|
2015-05-16 04:49:38 +00:00
|
|
|
"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
|
|
|
|
2016-07-17 19:00:43 +00:00
|
|
|
(defun helm-spacemacs-help//layer-action-open-file
|
|
|
|
(file candidate &optional edit)
|
2015-10-02 18:51:10 +00:00
|
|
|
"Open FILE of the passed CANDIDATE. If EDIT is false, open in view mode."
|
2016-07-17 19:00:43 +00:00
|
|
|
(let ((path (configuration-layer/get-layer-path (intern 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))
|
2016-07-16 08:56:50 +00:00
|
|
|
(let ((filepath (concat path file)))
|
|
|
|
(if (file-exists-p filepath)
|
|
|
|
(find-file filepath)
|
|
|
|
(message "%s does not have %s" candidate file))))))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//layer-action-open-readme (candidate)
|
2015-10-02 18:51:10 +00:00
|
|
|
"Open the `README.org' file of the passed CANDIDATE for reading."
|
2016-01-04 19:20:54 +00:00
|
|
|
(helm-spacemacs-help//layer-action-open-file "README.org" candidate))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2016-01-12 00:02:22 +00:00
|
|
|
(defun helm-spacemacs-help//layer-action-install-layer (candidate-layer)
|
|
|
|
"Add CANDIDATE-LAYER to dotspacemacs file and reloads configuration"
|
2016-03-25 04:24:52 +00:00
|
|
|
(when (dotspacemacs/add-layer (intern candidate-layer))
|
|
|
|
(dotspacemacs/sync-configuration-layers)))
|
2015-11-20 04:43:01 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//layer-action-open-readme-edit (candidate)
|
2015-10-02 18:51:10 +00:00
|
|
|
"Open the `README.org' file of the passed CANDIDATE for editing."
|
2016-01-04 19:20:54 +00:00
|
|
|
(helm-spacemacs-help//layer-action-open-file "README.org" candidate t))
|
2015-10-02 18:51:10 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//layer-action-open-packages (candidate)
|
2014-12-20 04:48:31 +00:00
|
|
|
"Open the `packages.el' file of the passed CANDIDATE."
|
2016-01-04 19:20:54 +00:00
|
|
|
(helm-spacemacs-help//layer-action-open-file "packages.el" candidate))
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2016-07-16 08:56:50 +00:00
|
|
|
(defun helm-spacemacs-help//layer-action-open-config (candidate)
|
|
|
|
"Open the `config.el' file of the passed CANDIDATE."
|
|
|
|
(helm-spacemacs-help//layer-action-open-file "config.el" candidate))
|
|
|
|
|
2017-06-05 02:39:56 +00:00
|
|
|
(defun helm-spacemacs-help//package-action-describe (candidate)
|
2016-02-22 07:29:43 +00:00
|
|
|
"Describe the passed package using Spacemacs describe function."
|
|
|
|
(save-match-data
|
|
|
|
(string-match "^\\(.+\\)\s(\\(.+\\) layer)$" candidate)
|
|
|
|
(let* ((package (match-string 1 candidate)))
|
|
|
|
(configuration-layer/describe-package (intern package)))))
|
|
|
|
|
2016-06-11 02:48:41 +00:00
|
|
|
(defun helm-spacemacs-help//package-action-goto-config-func (candidate)
|
2014-12-21 07:53:14 +00:00
|
|
|
"Open the file `packages.el' and go to the init function."
|
|
|
|
(save-match-data
|
2016-06-11 02:48:41 +00:00
|
|
|
(string-match "^\\(.+\\)\s(\\(.*\\):\s\\(.+\\) layer.*)$" candidate)
|
2015-11-12 09:49:31 +00:00
|
|
|
(let* ((package (match-string 1 candidate))
|
2016-06-11 02:48:41 +00:00
|
|
|
(init-type (match-string 2 candidate))
|
|
|
|
(layer (match-string 3 candidate))
|
2014-12-21 07:53:14 +00:00
|
|
|
(path (file-name-as-directory
|
2016-07-17 19:00:43 +00:00
|
|
|
(configuration-layer/get-layer-path (intern layer))))
|
2015-11-12 09:49:31 +00:00
|
|
|
(filename (concat path "packages.el")))
|
2016-06-11 02:48:41 +00:00
|
|
|
(when (string-match-p "owner" init-type)
|
|
|
|
(setq init-type "init"))
|
2014-12-21 07:53:14 +00:00
|
|
|
(find-file filename)
|
2014-12-24 05:21:47 +00:00
|
|
|
(goto-char (point-min))
|
2016-06-11 02:48:41 +00:00
|
|
|
(re-search-forward (format "%s-%s" init-type package))
|
2014-12-21 07:53:14 +00:00
|
|
|
(beginning-of-line))))
|
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//toggle (candidate)
|
2015-01-29 05:08:48 +00:00
|
|
|
"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
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(defun helm-spacemacs-help//go-to-dotfile-variable (candidate)
|
2015-05-16 04:49:38 +00:00
|
|
|
"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))
|
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
(provide 'helm-spacemacs-help)
|
2014-12-20 04:48:31 +00:00
|
|
|
|
2016-01-04 19:20:54 +00:00
|
|
|
;;; helm-spacemacs-help.el ends here
|