conf-yasnippet.el 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ;;; Code:
  2. (require 'yasnippet)
  3. (setq yas-snippet-dirs
  4. '("~/.emacs.d/snippets/my-snippets" ;; personal snippets
  5. "~/.emacs.d/snippets/yasnippet-snippets/snippets" ;; third party snippets
  6. "~/.emacs.d/snippets/yasmate/snippets" ;; the yasmate collection
  7. "~/.emacs.d/snippets/extend-snippets" ;; Extend basic snippets
  8. )
  9. yas-prompt-functions
  10. '(yas-maybe-ido-prompt
  11. yas-completing-prompt
  12. yas-no-prompt)
  13. hippie-expand-try-functions-list
  14. (cons 'yas-hippie-try-expand hippie-expand-try-functions-list))
  15. ;; Functions
  16. (defun yas-ido-expand ()
  17. "Lets you select (and expand) a yasnippet key with ido."
  18. (interactive)
  19. (let ((original-point (point)))
  20. (while (and
  21. (not (= (point) (point-min) ))
  22. (not
  23. (string-match "[[:space:]\n]" (char-to-string (char-before)))))
  24. (backward-word 1))
  25. (let* ((init-word (point))
  26. (word (buffer-substring init-word original-point))
  27. (list (yas-active-keys)))
  28. (goto-char original-point)
  29. (let ((key (remove-if-not
  30. (lambda (s) (string-match (concat "^" word) s)) list)))
  31. (if (= (length key) 1)
  32. (setq key (pop key))
  33. (setq key (ido-completing-read "key: " list nil nil word)))
  34. (delete-char (- init-word original-point))
  35. (insert key)
  36. (yas-expand)))))
  37. ;; Enable
  38. (yas-global-mode +1)
  39. (provide 'conf-yasnippet)
  40. ;;; conf-yasnippet.el ends here