branch: elpa/popup commit bb51a53e995c0a634080c1cfb1ae715b380ff1b6 Merge: 8719cd9 ca3cc7f Author: Syohei YOSHIDA <syo...@gmail.com> Commit: Syohei YOSHIDA <syo...@gmail.com>
Merge branch 'add-initial-index' --- README.md | 5 ++++- popup.el | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2e2c3c..5da6d2f 100644 --- a/README.md +++ b/README.md @@ -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")) diff --git a/popup.el b/popup.el index 877fbfc..cb3ad0b 100644 --- a/popup.el +++ b/popup.el @@ -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