emacs-devel
[Top][All Lists]
Advanced

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

Completion


From: Lars Ingebrigtsen
Subject: Completion
Date: Sat, 01 Sep 2018 11:51:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

I've been looking at the completion functions and documentation for
pretty much the first time in my life this morning, and I've got some
questions.  :-/

1)

From

20.6.7 Programmed Completion

     ‘nil’
          This specifies a ‘try-completion’ operation.  The function
          should return ‘t’ if the specified string is a unique and
          exact match; if there is more than one match, it should return
          the common substring of all matches (if the string is an exact
          match for one completion alternative but also matches other
          longer alternatives, the return value is the string); if there
          are no matches, it should return ‘nil’.

Let's say the set is '("foo" "zot") and the string is "fo".  Then
there's one match, and it's unique, of course.  But it's not exact?  So
should it return nil, then?

2) The entire `completing-read' machinery is based on prefix, matches
and nothing else; is that right?  That is, if you want to do completion
on words inside strings (for instance, if you want "foo" to have a match
in a collection string like "zot foo bar", then there is no built-in
machinery in Emacs for this?

3) The completion selection machinery in simple.el is nice, but it would
be nice to be able to pass more information about the strings into it
and get it all back after the user has chosen something.  The obvious
thing is to put a text property on the strings, and that almost, almost
works, except for this:

(defun choose-completion (&optional event)
  "Choose the completion at point.
If EVENT, use EVENT's position to determine the starting position."

[...]

               (setq end (or (next-single-property-change end 'mouse-face)
                             (point-max)))
               (buffer-substring-no-properties beg end)))))

If that had been just `buffer-substring', then the information would
survive back to the caller.

`minibuffer-allow-text-properties' exists.  Would it make sense to add a
new variable, like `completion-allow-text-properties', to handle this
case as well?


Like I said, this entire area is new to me, so I may be misunderstanding
something here...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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