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

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

Re: Choosing interactively from a list (starting off at any position)


From: Florian v. Savigny
Subject: Re: Choosing interactively from a list (starting off at any position)
Date: Sun, 07 Dec 2014 11:56:15 +0100

Hi John,

thanks for your ideas!

  > As an alternative, does this do something like what you're looking for?
  > 
  >     (defun rotate-to-index (list index)
  >       (append (cl-subseq list index)
  >               (cl-subseq list 0 index)))
  > 
  > 
  >     (defun choose-from-list-cmplr (list &optional index)
  >       (completing-read "Choose: "
  >                        (if index (rotate-to-index list index) list)
  >                        nil
  >                        t))


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.

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

The practical context is that I have a long, long file which contains
a lot of dates in chronological order, some of which are usually past,
one perhaps today's date, and the rest is in the future. I would like
to devise a convenient and orderly method of jumping to any of these
dates, starting off at the most current date, i.e. either today's or
next. (It is actually much like moving back and forth in a calendar or
diary.)

I have written all of that, and with read-from-minibuffer, it works
fine, so there is no pressing need to solve it. (That the user can
enter non-existant dates is not a practical problem because I am the
user, and I know better.) I have just become really curious about why
the two functions seem to work differently with respect to the
minibuffer history.

On a more fundamental note, it has made me start wondering if
minibuffer completion and history might be worth supplementing with
further kinds of user input methods. (Because the minibuffer stuff is
really just a hack; that's not what histories are there for.)

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.

As Lisp is a list-processing language, it seems to me that an input
method which works like that should come easy to Emacs, and that
somebody might already have written something as basic as that. Does
anybody know of anything ... ?

Best regards!

Florian

-- 

Florian von Savigny
Melanchthonstr. 41
33615 Bielefeld



reply via email to

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