From: João Távora Date: Thu, 6 Mar 2014 08:05:53 +0000 (+0000) Subject: Merge pull request #466 from npostavs/no-reverse X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/e7599b9325d1a8b34e05e0a3e5ba62b4755eea2d Merge pull request #466 from npostavs/no-reverse Avoid double choices reversing --- e7599b9325d1a8b34e05e0a3e5ba62b4755eea2d diff --cc yasnippet.el index b3b51573b,1a87e3984..f4b475146 --- a/yasnippet.el +++ b/yasnippet.el @@@ -1534,57 -1528,27 +1528,20 @@@ Optional PROMPT sets the prompt to use. (defun yas-x-prompt (prompt choices &optional display-fn) "Display choices in a x-window prompt." - ;; FIXME: HACK: if we notice that one of the objects in choices is - ;; actually a `yas--template', defer to `yas--x-prompt-pretty-templates' - ;; - ;; This would be better implemented by passing CHOICES as a - ;; structured tree rather than a list. Modifications would go as far - ;; up as `yas--all-templates' I think. - ;; (when (and window-system choices) - (let ((chosen - (let (menu d) ;; d for display - (dolist (c choices) - (setq d (or (and display-fn (funcall display-fn c)) - c)) - (cond ((stringp d) - (push (cons (concat " " d) c) menu)) - ((listp d) - (push (car d) menu)))) - (setq menu (list prompt (push "title" menu))) - (x-popup-menu (if (fboundp 'posn-at-point) - (let ((x-y (posn-x-y (posn-at-point (point))))) - (list (list (+ (car x-y) 10) - (+ (cdr x-y) 20)) - (selected-window))) - t) - menu)))) - (or chosen - (keyboard-quit))))) - - (defun yas--x-pretty-prompt-templates (prompt templates) - "Display TEMPLATES, grouping neatly by table name." - (let ((organized (make-hash-table :test #'equal)) - menu - more-than-one-table - prefix) - (dolist (tl templates) - (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 - " " "")) - (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))))) - (list (list (+ (car x-y) 10) - (+ (cdr x-y) 20)) - (selected-window))) - t) - (list prompt (push "title" menu))) - (keyboard-quit)))) + (or + (x-popup-menu + (if (fboundp 'posn-at-point) + (let ((x-y (posn-x-y (posn-at-point (point))))) + (list (list (+ (car x-y) 10) + (+ (cdr x-y) 20)) + (selected-window))) + t) + `(,prompt ("title" + ,@(mapcar* (lambda (c d) `(,(concat " " d) . ,c)) + choices + (if display-fn (mapcar display-fn choices) choices))))) + (keyboard-quit)))) (defun yas-ido-prompt (prompt choices &optional display-fn) (when (and (fboundp 'ido-completing-read)