From: florian@fsavigny.de (Florian v. Savigny)
To: John Mastro <john.b.mastro@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Fwd: Choosing interactively from a list (starting off at any position)
Date: Mon, 08 Dec 2014 23:51:33 +0100 [thread overview]
Message-ID: <87oardah6y.fsf@bertrandrussell.Speedport_W_723V_1_36_000> (raw)
In-Reply-To: <CAOj2CQSEVqvdHwP5W_MhjTQvN+18Mf4Me=aTo-zjfS0wtK-Thw@mail.gmail.com> (message from John Mastro on Mon, 8 Dec 2014 11:19:09 -0800)
Hi John,
> 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)))
This comes indeed closer, although - can you explain why? Did it have
to do with the history variable???? (I actually had not made any such
connection myself.)
I changed two aspects:
(defun choose-from-list-cmplr (list &optional index)
(setq choose-from-list-history (reverse list))
;; ^^^^^^^^
(completing-read "Choose: "
list
nil
t
(nth index list)
(cons 'choose-from-list-history (1- index))))
;; ^^^
because without the reverse, M-n and M-p work counter-intuitively, and
the 1- because the index that completing-read uses in the history is
1-based, not 0-based, like in lists. (But then, why did I subtract 1,
rather than add 1?)
> 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.
No, I haven't, but I use icicles, which provides a gazillion methods
of doing completion with less keystrokes. (I have understood one or
two of them so far.) I am not sure if ido is basically different.
But my point is that I do not want to type ANY part of the date I am
looking for; rather, I want to choose according to a logic of "it's
before the date offered" and "it's after the date offered". Or
perhaps, "I want the first date" or "I want the last date". The parts
of dates are not like the strings you usually look for, but, apart
from numbers you can easily get wrong, weekdays which occur in many of
the dates. Thus, although each date is unique, this uniqueness is very
difficult to spot for a human because identical parts are only mixed
differently. (Spelled-out months would make choosing easier, but the
usual German date format uses the numbers 1 to 12 for them.) And a
helpful feature they DO have, in contrast, is a strict (chronlogical)
ORDER.
But your solution works perfectly - thanks a lot for your ideas!! I
would still like to understand why it works, though. ;-)
--
Florian von Savigny
Melanchthonstr. 41
33615 Bielefeld
next prev parent reply other threads:[~2014-12-08 22:51 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 ` Choosing interactively from a list (starting off at any position) Florian v. Savigny
[not found] ` <CAOj2CQQ45gZpmuQUsMNp=iokkbB1Wz2cWpy6ZKfZ=BzyoSY6xg@mail.gmail.com>
2014-12-08 19:19 ` Fwd: " John Mastro
2014-12-08 22:51 ` Florian v. Savigny [this message]
[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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oardah6y.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).