Fix helm-spacemacs-help-faq, SPC h f

The function: helm-org-get-candidates was removed upstream.

Improvements:
Recenter the target candidate.

Reversed the helm headings list, to match the order of the
questions in FAQ.org, so that the Common questions are
listed first.

Removed the : (colon) after the heading: How do I
in FAQ.org, to match the other parent headings.
This commit is contained in:
duianto 2020-01-08 08:47:35 +01:00
parent 52d1b0f323
commit 27178f23e9
3 changed files with 45 additions and 15 deletions

View File

@ -1258,6 +1258,7 @@ Other:
- Fixed searching in the =helm-find-file= actions (thanks to duianto)
- Fixed =evilified-state=, mapped ~C-w~ to =evil-window-map=
(thanks to Muneeb Shaikh)
- Fixed ~SPC h f~ =helm-spacemacs-help-faq= (thanks to duianto)
*** Layer changes and fixes
**** Agda
- Fixes

View File

@ -26,7 +26,7 @@
- [[#why-are-my-font-settings-not-being-respected][Why are my font settings not being respected?]]
- [[#why-am-i-getting-a-message-about-environment-variables-on-startup][Why am I getting a message about environment variables on startup?]]
- [[#i-want-to-learn-elisp-where-do-i-start-][I want to learn elisp, where do I start ?]]
- [[#how-do-i][How do I:]]
- [[#how-do-i][How do I]]
- [[#install-a-package-not-provided-by-a-layer][Install a package not provided by a layer?]]
- [[#disable-a-package-completely][Disable a package completely?]]
- [[#disable-a-package-only-for-a-specific-major-mode][Disable a package only for a specific major-mode?]]
@ -280,7 +280,7 @@ Practical reference with code examples for various situations that you will
encounter: [[http://caiorss.github.io/Emacs-Elisp-Programming/][http://caiorss.github.io/Emacs-Elisp-Programming/]], more particularly
sections [[http://caiorss.github.io/Emacs-Elisp-Programming/Elisp_Programming.html][Elisp Programming]] and [[http://caiorss.github.io/Emacs-Elisp-Programming/Elisp_Snippets.html][Elisp code snippets]].
* How do I:
* How do I
** Install a package not provided by a layer?
Spacemacs provides a variable in the =dotspacemacs/layers= function in
=.spacemacs= called =dotspacemacs-additional-packages=. Just add a package name

View File

@ -59,26 +59,55 @@
": " (match-string 2 str))
(cdr cand)))))
(defun helm-spacemacs-help//get-faq-headings-list (sources)
"Given the helm-org sources from FAQ.org.
Return a list of all it's headings."
(aref (aref (cdadar sources) 2) 0))
(defun helm-spacemacs-help//faq-candidates ()
"Join the section headings to each of their questions.
Remove all text properties.
Color the section heading substring.
Add back the helm candidate text properties (to section substring):
`helm-real-display' with the joined \"section: question\"
`helm-realvalue' with the question marker.
The questions marker makes sure that the cursor
jumps to the selected question."
(let* ((helm-org-format-outline-path nil)
(cands (helm-org-get-candidates (list helm-spacemacs-help--faq-filename)))
section result)
(dolist (c cands)
(let ((str (substring-no-properties (car c))))
(when (string-match "\\`\\* \\(.*\\)\\'" str)
(setq section (match-string 1 str)))
(when (string-match "\\`\\*\\* \\(.*\\)\\'" str)
(push (cons (concat (propertize section 'face 'font-lock-type-face)
": " (match-string 1 str))
(cdr c))
result))))
result))
(cands (helm-org-build-sources
(list helm-spacemacs-help--faq-filename)))
section section-no-prop
question question-marker question-no-prop
section-and-question-with-marker
result)
(dolist (heading (helm-spacemacs-help//get-faq-headings-list cands))
(when (string-match "\\`\\* \\(.*\\)\\'" heading)
(setq section (match-string 1 heading))
(setq section-no-prop (substring-no-properties section)))
(when (string-match "\\*\\* \\(.*\\)" heading)
(setq question (match-string 1 heading))
(setq question-marker (get-text-property 0 'helm-realvalue question))
(setq question-no-prop (substring-no-properties question))
(setq section-and-question
(concat section-no-prop ": " question-no-prop))
(setq section-and-question-with-marker
(concat (propertize
section-no-prop
'face 'font-lock-type-face
'helm-real-display section-and-question
'helm-realvalue question-marker)
": " question-no-prop))
(push (cons section-and-question-with-marker heading) result)))
;; The result list is reversed, to show the questions in the same order as
;; they appear in the FAQ.org file, with the common questions first.
(reverse result)))
(defun helm-spacemacs-help//faq-goto-marker (marker)
(find-file helm-spacemacs-help--faq-filename)
(goto-char marker)
(org-show-context)
(org-show-entry))
(org-show-entry)
(recenter-top-bottom))
(provide 'helm-spacemacs-faq)