bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#64351: probabe bug associated with “completion-regexp-list”


From: Shynur Xie
Subject: 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.




reply via email to

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