emacs-devel
[Top][All Lists]
Advanced

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

Re: `isearch-complete1' should use `completion-at-point' or `completion-


From: Stefan Monnier
Subject: Re: `isearch-complete1' should use `completion-at-point' or `completion-in-region'
Date: Wed, 15 Jan 2020 08:57:54 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> Maybe something like this:
>
> (defun isearch-completion-at-point-function ()
>   (list (minibuffer-prompt-end) (point-max)
>         (if isearch-regexp regexp-search-ring search-ring)))

Looks fine, yes.

> (defun isearch-completion-at-point ()
>   (interactive)
>   (let* ((completion-ignore-case case-fold-search)
>          (completion-at-point-functions 
> '(isearch-completion-at-point-function)))
>     (completion-at-point)))

Ah, no I was thinking rather of something like

    (minibuffer-with-setup-hook
        (lambda ()
          (setq-local completion-ignore-case case-fold-search)
          (add-hook 'completion-at-point-functions
                    #'isearch-completion-at-point-function nil t))
      ...)

This way, things like `company-mode` can use it (tho IIUC company-mode
currently doesn't work in the minibuffer) and `isearch-complete-edit`
can be an obsolete alias of `completion-at-point`.

>> For `isearch-complete`, it's a bit more tricky because it's a form of
>> completion that is performed on a text that's kept inside a string
>> rather than inside a buffer, so I think we'll still need some ad-hoc
>> code, but it could better use our completion framework.
> `isearch-complete` already activates the minibuffer conditionally
> when there are completions. It could activate the minibuffer always,
> then immediately exit the minibuffer when completion-at-point
> finds no completions.

Yes.  What I meant is that `isearch-complete` can't be turned into
a mere obsolete alias of `completion-at-point`.

FWIW, I think it might be worthwhile trying to rewrite isearch such that
it always uses the minibuffer (instead of using a transient keymap and
displaying the search string in the echo area).

Then `isearch-edit` would simply change the minibuffer's keymap such
that we only exit the minibuffer in the "usual" way.

In such a setting `isearch-complete` could be a simple alias of
`completion-at-point`.


        Stefan




reply via email to

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