Reactormonk
Reactormonk

Reputation: 21730

Display all snippets of yasnippet

What's a nice way to display all snippets available to yasnippet to the current major mode?

Upvotes: 34

Views: 7284

Answers (5)

fap
fap

Reputation: 683

If you are using company mode for autocompletion you can also call company-yasnippet to show all available snippets in the company interface.

Screenshot showing the available yasnippets through the company interface

Upvotes: 2

lawlist
lawlist

Reputation: 13457

(defvar lawlist-context-menu-map
  (let ((map (make-sparse-keymap "Context Menu")))
    (define-key map [help-for-help] (cons "Help" 'help-for-help))
    (define-key map [seperator-two] '(menu-item "--"))
    (define-key map [my-menu] (cons "LAWLIST" (make-sparse-keymap "My Menu")))
    (define-key map [my-menu 01] (cons "Next Line" 'next-line))
    (define-key map [my-menu 02] (cons "Previous Line" 'previous-line))
    (define-key map [seperator-one] '(menu-item "--"))
  map) "Keymap for the LAWLIST context menu.")

(defun lawlist-popup-context-menu  (event &optional prefix)
  "Popup a context menu."
  (interactive "@e \nP")
    (define-key lawlist-context-menu-map [lawlist-major-mode-menu]
      `(menu-item ,(symbol-name major-mode)
        ,(mouse-menu-major-mode-map) :visible t))
    (define-key lawlist-context-menu-map (vector major-mode)
      `(menu-item ,(concat "YAS " (symbol-name major-mode))
        ,(gethash major-mode yas--menu-table)
          :visible (yas--show-menu-p ',major-mode)))
    (popup-menu lawlist-context-menu-map event prefix))

(global-set-key [mouse-3] 'lawlist-popup-context-menu)

Example:

Upvotes: 5

Slava Ignatyev
Slava Ignatyev

Reputation: 181

yas/describe-tables is an alias for yas-describe-tables in yasnippet.el.

(yas/describe-tables &optional CHOOSE)

This function is obsolete since yasnippet 0.8;

use yas-describe-tables instead.

Display snippets for each table.

Upvotes: 16

kindahero
kindahero

Reputation: 5867

this command shows the snippets and keys

 m-x yas/describe-tables

Upvotes: 44

Julian Qian
Julian Qian

Reputation: 726

Are you looking for M-x yas/insert-snippet? It will list all available snippets and you can choose one of them to insert.

Upvotes: 6

Related Questions