Function: abbrev-table-menu

abbrev-table-menu is a byte-compiled function defined in abbrev.el.gz.

Signature

(abbrev-table-menu TABLE &optional PROMPT SORTFUN)

Documentation

Return a menu that shows all abbrevs in TABLE.

Selecting an entry runs abbrev-insert for that entry's abbrev. PROMPT is the prompt to use for the keymap. SORTFUN is passed to sort to change the default ordering.

Probably introduced at or before Emacs version 23.1.

Source Code

;; Defined in /usr/src/emacs/lisp/abbrev.el.gz
(defun abbrev-table-menu (table &optional prompt sortfun)
  "Return a menu that shows all abbrevs in TABLE.
Selecting an entry runs `abbrev-insert' for that entry's abbrev.
PROMPT is the prompt to use for the keymap.
SORTFUN is passed to `sort' to change the default ordering."
  (unless sortfun (setq sortfun 'string-lessp))
  (let ((entries ()))
    (obarray-map (lambda (abbrev)
                   (when (symbol-value abbrev)
                     (let ((name (symbol-name abbrev)))
                       (push `(,(intern name) menu-item ,name
                               (lambda () (interactive)
                                 (abbrev-insert ',abbrev)))
                             entries))))
                 table)
    (nconc (make-sparse-keymap prompt)
           (sort entries (lambda (x y)
                           (funcall sortfun (nth 2 x) (nth 2 y)))))))