help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Going through a list using the minibuffer


From: Emanuel Berg
Subject: Re: Going through a list using the minibuffer
Date: Sun, 13 Jun 2021 02:14:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

arvid-harnack wrote:

> Would like to have a list of strings that can be selected
> using the minibuffer. And then set a variable
>
> number "k" that corresponds to the location of the string in
> the list.

Try this ...

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/string-minibuffer.el
;;;   https://dataswamp.org/~incal/emacs-init/string-minibuffer.el

(require 'cl-lib)

(defun select-list-item (lst)
  (let ((ps ""))
    (cl-loop for i from 0 to (1- (length lst))
             for l in lst
             do (setq ps (concat ps (format "%d: %s " i l))))
    (nth (read-number (concat ps "[index?] ")) lst)))

;; (select-list-item '("test" "string" "three"))


-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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