unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Spencer Baugh <sbaugh@janestreet.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 70217@debbugs.gnu.org
Subject: bug#70217: [PATCH] Add substring-partial-completion style
Date: Thu, 18 Apr 2024 11:19:04 -0400	[thread overview]
Message-ID: <ieril0ebswn.fsf@janestreet.com> (raw)
In-Reply-To: <jwvplv3acwc.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 05 Apr 2024 14:35:24 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> It's preferable for this to be a separate style from partial-completion
>> rather than a customization for partial-completion, because completing
>> with a leading glob is inefficient: it doesn't allow the completion
>> table to do any filtering at all.  So, for example, one might want the
>> regular partial-completion style to run first, and if it doesn't find
>> anything then the substring-partial-completion style can run.
>
> FWIW, I think the "language of completion styles" would benefit from
> being a bit richer.  I.e. instead of a completion style (i.e. an entry
> in `completion-styles`) being limited to a symbol, we could
> extend it so a style can take arguments.
>
> E.g. the `substring` style could take an argument which when set to the
> symbol `pcm` would cause it to behave like your "substring-partial-completion":
>
>     (setq completion-styles '(basic (substring pcm) emacs22))
>
> Alternatively, it could be an argument to `partial-completion`, e.g.:
>
>     (setq completion-styles '(basic (partial-completion notanchored) emacs22))

This is a good point, because I think there's a few things I want which
fit neatly with this:

- '(substring pcm) (i.e. the behavior added in this feature)

- '(emacs22 pcm)  (i.e. ignoring the suffix after point, but using pcm
  for what's before point)

- '(emacs22 pcm substring) (i.e. ignoring the suffix after point, but
  also globbing at the start of the completion like substring, and using
  pcm for it)

But, also, I realized that I basically always want PCM for both the
substring and emacs22 completion styles.  So what about having two
customizations, defaulting to nil?

completion-substring-use-pcm
completion-emacs22-use-pcm

These customization will affect all usage of those styles.  Without this
approach, I'd have to use completion-category-overrides to override the
completion styles for every single category, just to make the styles use
PCM.  (which IMO should be the default anyway)

This doesn't give me the substring-emacs22 style that I want, but maybe
that should actually be a separate style, since its behavior would be
fairly different from both emacs22 and substring, and so probably
doesn't make sense as an option.





  parent reply	other threads:[~2024-04-18 15:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 12:41 bug#70217: [PATCH] Add substring-partial-completion style Spencer Baugh
2024-04-05 18:35 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-05 19:46   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-06  8:10     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-18 15:19   ` Spencer Baugh [this message]
2024-05-08 16:46     ` Spencer Baugh
2024-05-08 17:14       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=ieril0ebswn.fsf@janestreet.com \
    --to=sbaugh@janestreet.com \
    --cc=70217@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).