Commit ca3cc7f1 authored by Kiyoka Nishiyama's avatar Kiyoka Nishiyama Committed by Syohei YOSHIDA

Add: initial-index keyword argument to function `popup-menu*'. (initial-index...

Add: initial-index keyword argument to function `popup-menu*'. (initial-index argument is optional argument)
Usage:
  (popup-menu*
   '(0 1 2 3)
   :initial-index 2)
parent 8719cd92
......@@ -282,7 +282,7 @@ select an item of a list.
popup-menu* list &key point around width height margin margin-left
margin-right scroll-bar symbol parent parent-offset keymap
fallback help-delay nowait prompt isearch isearch-cursor-color
isearch-keymap isearch-callback => selected-value
isearch-keymap isearch-callback initial-index => selected-value
Show a popup menu of `LIST` at `POINT`. This function returns the value
of the selected item. Almost all arguments are same as `popup-create`
......@@ -317,6 +317,9 @@ during event loop. The default value is `popup-isearch-keymap`.
calls `ISEARCH-CALLBACK`, if specified, after isearch finished or
isearch canceled. The arguments is whole filtered list of items.
If `INITIAL-INDEX` is non-nil, this is an initial index value for
`popup-select`. Only positive integer is valid.
Here is an example:
(popup-menu* '("Foo" "Bar" "Baz"))
......
......@@ -1317,6 +1317,7 @@ PROMPT is a prompt string when reading events during event loop."
(isearch-cursor-color popup-isearch-cursor-color)
(isearch-keymap popup-isearch-keymap)
isearch-callback
initial-index
&aux menu event)
"Show a popup menu of LIST at POINT. This function returns a
value of the selected item. Almost arguments are same as
......@@ -1350,7 +1351,10 @@ during event loop. The default value is `popup-isearch-keymap'.
ISEARCH-CALLBACK is a function taking one argument. `popup-menu'
calls ISEARCH-CALLBACK, if specified, after isearch finished or
isearch canceled. The arguments is whole filtered list of items."
isearch canceled. The arguments is whole filtered list of items.
If `INITIAL-INDEX' is non-nil, this is an initial index value for
`popup-select'. Only positive integer is valid."
(and (eq margin t) (setq margin 1))
(or margin-left (setq margin-left margin))
(or margin-right (setq margin-right margin))
......@@ -1378,6 +1382,9 @@ isearch canceled. The arguments is whole filtered list of items."
(if cursor
(popup-jump menu cursor)
(popup-draw menu))
(when initial-index
(popup-select menu
(min (- (length list) 1) initial-index)))
(if nowait
menu
(popup-menu-event-loop menu keymap fallback
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment