emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/popup ca3cc7f 106/184: Add: initial-index keyword argument


From: ELPA Syncer
Subject: [nongnu] elpa/popup ca3cc7f 106/184: Add: initial-index keyword argument to function `popup-menu*'. (initial-index argument is optional argument)
Date: Wed, 6 Oct 2021 00:01:21 -0400 (EDT)

branch: elpa/popup
commit ca3cc7f1805b3954f1c6d89db89322b0c515d0fe
Author: Kiyoka Nishiyama <kiyoka@sumibi.org>
Commit: Syohei YOSHIDA <syohex@gmail.com>

    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)
---
 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]