Skip to content

Commit

Permalink
bugfix: Fix #242
Browse files Browse the repository at this point in the history
  • Loading branch information
joaotavora committed May 22, 2012
1 parent a7b78cf commit c38c3aa
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 55 deletions.
2 changes: 1 addition & 1 deletion extras/imported/html-mode/.yas-setup.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
(interactive)
(let* ((tag-at-point (sgml-beginning-of-tag))
(fragment (and tag-at-point
(aget yas/html-tag-description-urls (upcase tag-at-point)))))
(cdr (assoc (upcase tag-at-point) yas/html-tag-description-urls)))))
(if fragment
(browse-url (concat "http://www.w3.org/TR/html4/index/"
fragment))
Expand Down
4 changes: 2 additions & 2 deletions extras/imported/rails-mode/.yas-setup.el
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
(let* ((start (point))
(end (save-excursion
(search-forward-regexp "^\s*def\sself\.down" nil 'noerror)))
(up (aget (aget yas/rails-intelligent-migration-snippet-bits type) :up))
(down (aget (aget yas/rails-intelligent-migration-snippet-bits type) :down))
(up (cdr (assoc :up (cdr (assoc type yas/rails-intelligent-migration-snippet-bits)))))
(down (cdr (assoc :down (cdr (assoc type yas/rails-intelligent-migration-snippet-bits)))))
(snippet
(and up down start end (concat up
(buffer-substring-no-properties start end)
Expand Down
106 changes: 54 additions & 52 deletions yasnippet.el
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
;;; Code:

(require 'cl)
(require 'assoc)
(require 'easymenu)
(require 'help-mode)

Expand Down Expand Up @@ -1289,8 +1288,9 @@ ensure your use `make-local-variable' when you set it.")
(unless table
(setq table (yas/make-snippet-table (symbol-name mode)))
(puthash mode table yas/tables)
(aput 'yas/direct-keymaps (intern (format "yas//direct-%s" mode))
(yas/table-direct-keymap table)))
(push (cons (intern (format "yas//direct-%s" mode))
(yas/table-direct-keymap table))
yas/direct-keymaps))
table))

(defun yas/get-snippet-tables ()
Expand Down Expand Up @@ -1520,22 +1520,25 @@ TEMPLATES is a list of `yas/template'."

(defun yas/x-pretty-prompt-templates (prompt templates)
"Display TEMPLATES, grouping neatly by table name."
(let ((pretty-alist (list))
(let ((organized (make-hash-table :test #'equal))
menu
more-than-one-table
prefix)
(dolist (tl templates)
(aput 'pretty-alist (yas/template-table tl) (cons tl (aget pretty-alist (yas/template-table tl)))))
(setq more-than-one-table (> (length pretty-alist) 1))
(puthash (yas/template-table tl)
(cons tl
(gethash (yas/template-table tl) organized))
organized))
(setq more-than-one-table (> (hash-table-count organized) 1))
(setq prefix (if more-than-one-table
" " ""))
(dolist (table-and-templates pretty-alist)
(when (cdr table-and-templates)
(if more-than-one-table
(push (yas/table-name (car table-and-templates)) menu))
(dolist (template (cdr table-and-templates))
(push (cons (concat prefix (yas/template-name template))
template) menu))))
(if more-than-one-table
(maphash #'(lambda (table templates)
(push (yas/table-name table) menu)
(dolist (tl templates)
(push (cons (concat prefix (yas/template-name tl)) tl) menu))) organized)
(setq menu (mapcar #'(lambda (tl) (cons (concat prefix (yas/template-name tl)) tl)) templates)))

(setq menu (nreverse menu))
(or (x-popup-menu (if (fboundp 'posn-at-point)
(let ((x-y (posn-x-y (posn-at-point (point)))))
Expand Down Expand Up @@ -2603,47 +2606,46 @@ With optional prefix argument KILL quit the window and buffer."
(insert "\n"))
(insert (make-string 100 ?-) "\n")
(insert "group state name key binding\n")
(let ((groups-alist (list))
group)
(let ((groups-hash (make-hash-table :test #'equal)))
(maphash #'(lambda (k v)
(setq group (or (yas/template-fine-group v)
"(top level)"))
(when (yas/template-name v)

(aput 'groups-alist group (cons v (aget groups-alist group)))))
(let ((group (or (yas/template-fine-group v)
"(top level)")))
(when (yas/template-name v)
(puthash group
(cons v (gethash group groups-hash))
groups-hash))))
(yas/table-uuidhash table))
(dolist (group-and-templates groups-alist)
(when (rest group-and-templates)
(setq group (truncate-string-to-width (car group-and-templates) 25 0 ? "..."))
(insert (make-string 100 ?-) "\n")
(dolist (p (cdr group-and-templates))
(let ((name (truncate-string-to-width (propertize (format "\\\\snippet `%s'" (yas/template-name p))
'yasnippet p)
50 0 ? "..."))
(group (prog1 group
(setq group (make-string (length group) ? ))))
(condition-string (let ((condition (yas/template-condition p)))
(if (and condition
original-buffer)
(with-current-buffer original-buffer
(if (yas/eval-condition condition)
"(y)"
"(s)"))
"(a)"))))
(insert group " ")
(insert condition-string " ")
(insert name
(if (string-match "\\.\\.\\.$" name)
"'"
" ")
" ")
(insert (truncate-string-to-width (or (yas/template-key p) "")
15 0 ? "...") " ")
(insert (truncate-string-to-width (key-description (yas/template-keybinding p))
15 0 ? "...") " ")
(insert "\n")))))))


(maphash
#'(lambda (group templates)
(setq group (truncate-string-to-width group 25 0 ? "..."))
(insert (make-string 100 ?-) "\n")
(dolist (p templates)
(let ((name (truncate-string-to-width (propertize (format "\\\\snippet `%s'" (yas/template-name p))
'yasnippet p)
50 0 ? "..."))
(group (prog1 group
(setq group (make-string (length group) ? ))))
(condition-string (let ((condition (yas/template-condition p)))
(if (and condition
original-buffer)
(with-current-buffer original-buffer
(if (yas/eval-condition condition)
"(y)"
"(s)"))
"(a)"))))
(insert group " ")
(insert condition-string " ")
(insert name
(if (string-match "\\.\\.\\.$" name)
"'"
" ")
" ")
(insert (truncate-string-to-width (or (yas/template-key p) "")
15 0 ? "...") " ")
(insert (truncate-string-to-width (key-description (yas/template-keybinding p))
15 0 ? "...") " ")
(insert "\n"))))
groups-hash)))



Expand Down

0 comments on commit c38c3aa

Please sign in to comment.