all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: florian@fsavigny.de (Florian v. Savigny)
To: John Mastro <john.b.mastro@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Choosing interactively from a list (starting off at any position)
Date: Sun, 07 Dec 2014 11:56:15 +0100	[thread overview]
Message-ID: <8761dnhgog.fsf@bertrandrussell.Speedport_W_723V_1_36_000> (raw)
In-Reply-To: <CAOj2CQS=e+fRGgLoaON+avkzvhVXfYqb3doEUd=wwES9tUOYJQ@mail.gmail.com> (message from John Mastro on Sat, 6 Dec 2014 19:33:08 -0800)


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	other threads:[~2014-12-07 10:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-07  2:58 Choosing interactively from a list Florian v. Savigny
2014-12-07  3:33 ` John Mastro
2014-12-07 10:56   ` Florian v. Savigny [this message]
     [not found]     ` <CAOj2CQQ45gZpmuQUsMNp=iokkbB1Wz2cWpy6ZKfZ=BzyoSY6xg@mail.gmail.com>
2014-12-08 19:19       ` Fwd: Choosing interactively from a list (starting off at any position) John Mastro
2014-12-08 22:51         ` Florian v. Savigny
     [not found]         ` <<87oardah6y.fsf@bertrandrussell.Speedport_W_723V_1_36_000>
2014-12-09  2:20           ` Drew Adams
2014-12-09 19:52             ` John Mastro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8761dnhgog.fsf@bertrandrussell.Speedport_W_723V_1_36_000 \
    --to=florian@fsavigny.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=john.b.mastro@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.