This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+web-services/search-engine/funcs.el
Eivind Fonn 65faddcba0 Improved search-engine layer
- Move defuns to funcs.el
- Add progn as per conventions
- Denote all search functions as autoloadable
2016-08-17 19:53:06 +02:00

44 lines
1.7 KiB
EmacsLisp

;;; funcs.el --- search-engine Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2016 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
(defun spacemacs//search-engine-source (engines)
"return a source for helm selection"
`((name . "Search Engines")
(candidates . ,(mapcar (lambda (engine)
(cons (plist-get (cdr engine) :name)
(intern (format "engine/search-%S"
(car engine)))))
engines))
(action . (lambda (candidate) (call-interactively candidate)))))
(defun spacemacs/helm-search-engine-select ()
"Set search engine to use with helm."
(interactive)
(helm :sources (list (spacemacs//search-engine-source
search-engine-alist))))
(defun spacemacs/ivy-search-engine-select ()
"Set search engine to use with ivy."
(interactive)
(ivy-read "Search Engines: "
(mapcar (lambda (engine)
(cons (plist-get (cdr engine) :name)
(intern (format "engine/search-%S"
(car engine)))))
search-engine-alist)
:action (lambda (candidate) (call-interactively (cdr candidate)))))
(defun spacemacs/search-engine-select ()
"Set search engine to use."
(interactive)
(if (configuration-layer/layer-usedp 'ivy)
(call-interactively 'spacemacs/ivy-search-engine-select)
(call-interactively 'spacemacs/helm-search-engine-select)))