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

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

Re: Fwd: Choosing interactively from a list (starting off at any positio


From: Florian v. Savigny
Subject: Re: Fwd: Choosing interactively from a list (starting off at any position)
Date: Mon, 08 Dec 2014 23:51:33 +0100


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



reply via email to

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