[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Choosing interactively from a list (starting off at any position)
From: |
John Mastro |
Subject: |
Fwd: Choosing interactively from a list (starting off at any position) |
Date: |
Mon, 8 Dec 2014 11:19:09 -0800 |
Sigh, forgot to include the list when sending the below.
Florian v. Savigny <florian@fsavigny.de> wrote:
> Yes, this does work, but only forwards, not backwards. I would like to
> go forwards with M-n and backwards (i.e. to the (index - 1)th element
> of list) with M-p.
Ah, indeed. It only appeared to work because of the completion packages
I'm using (see below).
> (It's interesting, BTW, that completing-read accepts an anonymous list
> instead of a list variable name. It cannot possibly modify this
> "history", can it?)
Indeed, the history needs to be something it can modify. But it won't
modify the list of choices. So, how about this?
(defvar choose-from-list-history nil)
(defun choose-from-list-cmplr (list &optional index)
(setq choose-from-list-history list)
(completing-read "Choose: "
list
nil
t
(nth index list)
(cons 'choose-from-list-history index)))
> In the problem I am working on, the ever-available completion is very
> unhelpful - simply not the natural method of choosing -, because the
> dates all start with one of just one, two or three different weekdays,
> followed by the day of the month (still not unique). But whether the
> date is one, two positions before or after today is almost always
> relevant, because I am usually interested in the dates around today.
Have you tried `ido' and the related packages out there? I'm using
`ido', `ido-ubiquitous', `flx-ido', and `ido-vertical-mode'. I find it
quite helpful even in situations like you describe, since you can type
just the part(s) that are likely to matter.
--
john