emacs-devel
[Top][All Lists]
Advanced

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

Re: C-r and C-s in minibuffer should search completion


From: Stefan Monnier
Subject: Re: C-r and C-s in minibuffer should search completion
Date: Sat, 19 Apr 2008 17:10:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>>> If there is no equivalent of Vbuffer_alist in Lisp, then
>>> internal-complete-buffer-sans-current will produce wrong results.
>> 
>> I don't understand what's the problem.  Your previously posted code
>> should work just fine, for example.

> I understood that the reason not to move `internal-complete-buffer'
> to Lisp is because it uses the internal variable Vbuffer_alist.

> Since these two functions are equivalent in behavior with the exception
> that one of them omits the current buffer, I thought that it would be
> better to have equivalent implementations

Actually it's better in that case to have one of the two implemented as
a "diff" over the other.

> by having both in Lisp with removing possible problems of using
> Vbuffer_alist that you mentioned.

Yes, except that your proposal doesn't remove possible problems with using
Vbuffer_alist (that problem is if someone gets hold of this list
and does things like "rplcd" (i.e. setcdr) on it).

>> Or you could define it on top of the internal-complete-buffer code,
>> using the `predicate' argument.

> Do you mean something like

> (defun internal-complete-buffer-sans-current (string predicate flag)
>   "Perform completion on buffer names excluding the current buffer.
> Like `internal-complete-buffer', but removes the current buffer from
> the completion list."
>   (let ((current-buffer (buffer-name (other-buffer (current-buffer) t))))
>     (internal-complete-buffer
>      string (lambda (buffer) (not (equal current-buffer buffer))) flag)))

Yes, except it should not ignore `predicate'.
You could define it in terms of completion-table-with-predicate (100%
untested code, of course):

(defun internal-complete-buffer-except (&optional buf)
  (lexical-let ((except (if (stringp buf) buf (buffer-name buf))))
    (apply-partially 'completion-table-with-predicate
                     'internal-complete-buffer
                     (lambda (name) (not (equal name except)))
                     nil)))


        Stefan




reply via email to

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