* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
[not found] ` <E1Yj1NW-0003Ri-FV@vcs.savannah.gnu.org>
@ 2015-04-17 14:49 ` Stefan Monnier
2015-04-17 14:57 ` Oleh Krehel
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2015-04-17 14:49 UTC (permalink / raw)
To: emacs-devel; +Cc: Oleh Krehel
> + (cond ((or (functionp collection)
> + (vectorp collection))
> + (when (eq collection 'read-file-name-internal)
> + (setq ivy--directory default-directory)
> + (setq initial-input nil))
> + (setq collection (all-completions "" collection predicate)))
> + ((hash-table-p collection)
> + (error "Hash table as a collection unsupported"))
> + ((listp (car collection))
> + (setq collection (all-completions "" collection predicate))))
I suggest you also try
C-h i
g (em TAB
-- Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 14:49 ` [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file' Stefan Monnier
@ 2015-04-17 14:57 ` Oleh Krehel
2015-04-17 18:28 ` Stefan Monnier
0 siblings, 1 reply; 9+ messages in thread
From: Oleh Krehel @ 2015-04-17 14:57 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On Fri, Apr 17, 2015 at 4:49 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> + (cond ((or (functionp collection)
>> + (vectorp collection))
>> + (when (eq collection 'read-file-name-internal)
>> + (setq ivy--directory default-directory)
>> + (setq initial-input nil))
>> + (setq collection (all-completions "" collection predicate)))
>> + ((hash-table-p collection)
>> + (error "Hash table as a collection unsupported"))
>> + ((listp (car collection))
>> + (setq collection (all-completions "" collection predicate))))
>
> I suggest you also try
>
> C-h i
> g (em TAB
Info-read-node-name-1 takes STRING, PREDICATE, and CODE and says to
look in the `completing-read' doc. But there's nothing abount CODE
there. Where do I get it?
Oleh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 14:57 ` Oleh Krehel
@ 2015-04-17 18:28 ` Stefan Monnier
2015-04-17 18:39 ` Oleh Krehel
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2015-04-17 18:28 UTC (permalink / raw)
To: Oleh Krehel; +Cc: emacs-devel
> Info-read-node-name-1 takes STRING, PREDICATE, and CODE and says to
> look in the `completing-read' doc. But there's nothing abount CODE
> there. Where do I get it?
I think you're better off reading about it in the Elisp manual.
The third argument (called ACTION usually) is basically the *method* to
use on the "object implemented as a function". It can be nil (which
means `try-completion'), t (which means `all-completions'), lambda
(which means `test-completion'), or `boundaries', or `metadata'.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 18:28 ` Stefan Monnier
@ 2015-04-17 18:39 ` Oleh Krehel
2015-04-17 19:22 ` Stefan Monnier
0 siblings, 1 reply; 9+ messages in thread
From: Oleh Krehel @ 2015-04-17 18:39 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> Info-read-node-name-1 takes STRING, PREDICATE, and CODE and says to
>> look in the `completing-read' doc. But there's nothing abount CODE
>> there. Where do I get it?
>
> I think you're better off reading about it in the Elisp manual.
> The third argument (called ACTION usually) is basically the *method* to
> use on the "object implemented as a function". It can be nil (which
> means `try-completion'), t (which means `all-completions'), lambda
> (which means `test-completion'), or `boundaries', or `metadata'.
Seems very complex for just returning a (short) list of strings.
Why doesn't this work for `Info-read-node-name-1':
(setq collection (all-completions "" collection predicate))
while this works within the topic, but not in the directory:
(setq collection (funcall collection "" nil t))
If I understood the info page correctly, both should be equivalent.
Oleh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 18:39 ` Oleh Krehel
@ 2015-04-17 19:22 ` Stefan Monnier
2015-04-17 19:27 ` Oleh Krehel
2015-04-18 4:50 ` Thierry Volpiatto
0 siblings, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-04-17 19:22 UTC (permalink / raw)
To: Oleh Krehel; +Cc: emacs-devel
> Seems very complex for just returning a (short) list of strings.
The set of files or the set of Info nodes (which can appear in any file)
can't conveniently be treated as "a (short) list of strings".
> Why doesn't this work for `Info-read-node-name-1':
> (setq collection (all-completions "" collection predicate))
I don't understand the question. AFAIK it does work. It just doesn't
return every possible node name, since there's pretty much an infinite
supply (if you include those that can be accessed via Tramp, for example).
> (setq collection (funcall collection "" nil t))
Indeed (funcall collection "" pred t) should be equivalent to
(all-completions "" collection predicate) when `collection' is a function.
If you see otherwise, we have a problem.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 19:22 ` Stefan Monnier
@ 2015-04-17 19:27 ` Oleh Krehel
2015-04-18 4:56 ` Stefan Monnier
2015-04-18 4:50 ` Thierry Volpiatto
1 sibling, 1 reply; 9+ messages in thread
From: Oleh Krehel @ 2015-04-17 19:27 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> Seems very complex for just returning a (short) list of strings.
>
> The set of files or the set of Info nodes (which can appear in any file)
> can't conveniently be treated as "a (short) list of strings".
>
>> Why doesn't this work for `Info-read-node-name-1':
>> (setq collection (all-completions "" collection predicate))
>
> I don't understand the question. AFAIK it does work. It just doesn't
> return every possible node name, since there's pretty much an infinite
> supply (if you include those that can be accessed via Tramp, for example).
>
>> (setq collection (funcall collection "" nil t))
>
> Indeed (funcall collection "" pred t) should be equivalent to
> (all-completions "" collection predicate) when `collection' is a function.
> If you see otherwise, we have a problem.
You can try the current ivy-mode code in elpa. It uses this for functions:
(all-completions "" collection predicate)
And it does't work with Info. I tried also with helm-mode, it doesn't
work either.
Oleh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 19:27 ` Oleh Krehel
@ 2015-04-18 4:56 ` Stefan Monnier
0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-04-18 4:56 UTC (permalink / raw)
To: Oleh Krehel; +Cc: emacs-devel
>> Indeed (funcall collection "" pred t) should be equivalent to
>> (all-completions "" collection predicate) when `collection' is a function.
>> If you see otherwise, we have a problem.
> You can try the current ivy-mode code in elpa. It uses this for functions:
> (all-completions "" collection predicate)
> And it does't work with Info.
That doesn't seem related to whether it gives the same result as
(funcall collection "" predicate t)
I'm not surprised "it doesn't work" (which of course, is poor as
a description of problem) if you expect this to give you the (infinite)
list of possible node named.
> I tried also with helm-mode, it doesn't work either.
Not surprised either.
There's a good reason why icomplete.el doesn't try to re-implement
completion, but instead piggybacks on top of the default
completion code.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-17 19:22 ` Stefan Monnier
2015-04-17 19:27 ` Oleh Krehel
@ 2015-04-18 4:50 ` Thierry Volpiatto
2015-04-18 14:12 ` Stefan Monnier
1 sibling, 1 reply; 9+ messages in thread
From: Thierry Volpiatto @ 2015-04-18 4:50 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> Seems very complex for just returning a (short) list of strings.
>
> The set of files or the set of Info nodes (which can appear in any file)
> can't conveniently be treated as "a (short) list of strings".
>
>> Why doesn't this work for `Info-read-node-name-1':
>> (setq collection (all-completions "" collection predicate))
>
> I don't understand the question. AFAIK it does work. It just doesn't
> return every possible node name, since there's pretty much an infinite
> supply (if you include those that can be accessed via Tramp, for example).
>
>> (setq collection (funcall collection "" nil t))
>
> Indeed (funcall collection "" pred t) should be equivalent to
> (all-completions "" collection predicate) when `collection' is a function.
> If you see otherwise, we have a problem.
This is working, but the problem is that functions are made to return
the completion part of what you have in minibuffer, and this is
impossible to handle from 3rd tools.
Take the example of find-file-at-point, it returns a list of relative
file names, what should we call to return the same list prefixed by what
is in minibuffer ?
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file'
2015-04-18 4:50 ` Thierry Volpiatto
@ 2015-04-18 14:12 ` Stefan Monnier
0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-04-18 14:12 UTC (permalink / raw)
To: Thierry Volpiatto; +Cc: emacs-devel
> This is working, but the problem is that functions are made to return
> the completion part of what you have in minibuffer, and this is
> impossible to handle from 3rd tools.
> Take the example of find-file-at-point, it returns a list of relative
> file names, what should we call to return the same list prefixed by what
> is in minibuffer ?
I have the impression that the question is aimed in my direction, but
I don't understand it enough to answer. E.g. I don't understand what
you mean by "find-file-at-point returns a list of relative
file names" and how it's relevant to the discussion.
Maybe the answer you're looking for is something like:
(pcase-let ((`(,start . ,_)
(completion-boundaries <str> <collection> <pred> ""))
(compls (all-completions <str> <collection> <pred>)))
(if (zerop start) compls
(let ((prefix (substring <str> 0 start)))
(mapcar (lambda (compl) (concat prefix compl)) compls))))
-- Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-04-18 14:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20150417081157.13187.57850@vcs.savannah.gnu.org>
[not found] ` <E1Yj1NW-0003Ri-FV@vcs.savannah.gnu.org>
2015-04-17 14:49 ` [elpa] master 567ea7e 1/3: Ivy-mode now works better with `find-file' Stefan Monnier
2015-04-17 14:57 ` Oleh Krehel
2015-04-17 18:28 ` Stefan Monnier
2015-04-17 18:39 ` Oleh Krehel
2015-04-17 19:22 ` Stefan Monnier
2015-04-17 19:27 ` Oleh Krehel
2015-04-18 4:56 ` Stefan Monnier
2015-04-18 4:50 ` Thierry Volpiatto
2015-04-18 14:12 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).