unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 44016@debbugs.gnu.org
Subject: bug#44016: 28.0.50; Add new "gnus-search" search interface to Gnus
Date: Mon, 02 Nov 2020 08:16:48 -0800	[thread overview]
Message-ID: <87blgfbuof.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <jwv8sbjx2qw.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 02 Nov 2020 09:24:23 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> (the "(consp (cdr (completion-all-completions" bit above definitely
>> felt like I was holding the tool upside down),
>
> It's just another way (more efficient) way to write
>
>    (< 1 (length (completion-all-completions ...)))
>
> so it looks fine from where I stand.

The return value for multiple matches is not a proper list (looks like
("subject" "since" . 0)), so I couldn't use `length' on it. That and the
fact that the strings have a face property made it seem like the
function wasn't really meant for what I was doing with it

>> but they're absolutely useful in a programmatic setting. I wonder if
>> there could be some version of these functions that could be "blessed"
>> for use in Elisp programs.
>
> They're definitely allowed to be used for ELisp programs.  They're not
> 100% pure functions, but not too far off.  The main issue I can see for
> use "internal use" is that their behavior is influenced by the
> `completion-styles` user-config, which may or may not be what you want.

I'll wait and see if that's a problem. If I'm expecting a completion
style that completes hyphenated strings ("con-f" -> "contact-from") and
the user has removed that style it could be an issue. I wonder how many
users even know about this configuration, though.

>>> (defvar gnus-search-minibuffer-map
>>>       (let ((km (make-sparse-keymap)))
>>>         (set-keymap-parent km minibuffer-local-map)
>>>         (define-key km (kbd "SPC") #'self-insert-command) ;; Isn't this redundant?
>>
>> Somewhere I'd gotten the idea that SPC was bound to
>> `minibuffer-complete-word', I don't know how.
>
> I presume you earlier inherited from `minibuffer-local-completion-map`
> or something like that.

Yes, I was confusing with `completing-read'.

>> Ah, of course! And if `gnus-search--complete-key-data' is conservative
>> about when it fires, it leaves the door open for other completion
>> functions.
>
> If by "fires" you mean "returns non-nil", then yes, indeed.
>
>> This function could complete "cont" to "contact:", at which
>> point (for example) an EBDB-specific capf function could take over and
>> complete names or email addresses to search for.
>
> Right.  Or it could itself recognize "contact:" and return the bounds of
> the contact info along with EBDB's completion table (since EBDB's
> capf presumably doesn't know about the "contact:" syntax).

Right, it would be much easier just to have a variable where
contact-management packages can register a completion table. Now I'm
thinking there's no real need for a "contact" key at all, just offer
completion on to/from/recipient/etc. Anyway, I've already got the code
working, thanks again for the pointers.

Eric





  reply	other threads:[~2020-11-02 16:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 16:47 bug#44016: 28.0.50; Add new "gnus-search" search interface to Gnus Eric Abrahamsen
2020-10-16  5:08 ` Lars Ingebrigtsen
2020-10-16 15:49   ` Eric Abrahamsen
2020-11-01  5:32     ` Eric Abrahamsen
2020-11-01 18:10       ` Basil L. Contovounesios
2020-11-01 18:22         ` Eli Zaretskii
2020-11-01 21:19         ` Eric Abrahamsen
2020-11-01 21:38       ` Eric Abrahamsen
2020-11-01 23:50         ` Stefan Monnier
2020-11-02  3:43           ` Eric Abrahamsen
2020-11-02 14:24             ` Stefan Monnier
2020-11-02 16:16               ` Eric Abrahamsen [this message]
2020-11-02 20:11                 ` Eric Abrahamsen
2020-11-04  5:22                   ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87blgfbuof.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=44016@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).