GNU bug report logs - #64351
probabe bug associated with “completion-regexp-list”

Previous Next

Package: emacs;

Reported by: Shynur Xie <one.last.kiss <at> outlook.com>

Date: Thu, 29 Jun 2023 18:59:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #38 received at 64351 <at> debbugs.gnu.org (full text, mbox):

From: Shynur Xie <one.last.kiss <at> outlook.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: "64351 <at> debbugs.gnu.org" <64351 <at> debbugs.gnu.org>
Subject: Re: bug#64351: probabe bug associated with “completion-regexp-list”
Date: Fri, 30 Jun 2023 19:36:44 +0000
> Stefan> I'd be interested to hear about your use-case, tho.

I tried to filter out internal variables “*--*” when typing “C-h v”
several days ago, so I wrote this:

(advice-add 'describe-variable :around ;“C-h v”
            (lambda (advice-added-function &rest arguments)
              (let ((completion-regexp-list
                     '("^\\([^-]*$\\|\\([^-]+\\(-[^-]+\\)-?\\)\\)$")))
                (apply advice-added-function arguments))))

It didn’t work.  I wanted to find out why, so to save time, I set its
value globally:

(setq completion-regexp-list
                      '("^\\([^-]*$\\|\\([^-]+\\(-[^-]+\\)-?\\)\\)$"))

Somehow, Emacs threw an error.  I guess this is a bug, so I tried to
narrow it down and then reported it.

> Stefan> Maybe I can provide a good alternative.

I think it would be nice if Emacs can provides an option, say,
“completions-filter-function” (or “completions-help-filter-function”
only for functions “describe-*”), which receives 2 arguments -- TYPE
and COMPLETION.  If I evaluate:

(setq completions-filter-function
        (lambda (type completion)
          (pcase type
            ('variable
             (not (string-match-p "--" (symbol-name completion)))))))

I can filter out “*--*” variables.  It’s also easier to add other
rules than the original “completion-regexp-list”.  Using regexp to
filter is not very convenient, say if I want to filter out
“*-internal”, I have to write this regexp:

"\\([^l]\\|[^a]l\\|[^n]al\\|[^r]nal\\|[^e]rnal\\|[^t]ernal\\|[^n]ternal\\|[^i]nternal\\|[^-]internal\\)$"

I don’t know whether “completions-filter-function” is a good idea, I’m
just making a suggestion.  Thanks.



This bug report was last modified 2 years and 18 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.