Closed gnusupport closed 3 years ago
I think we already figured that out in #227. As discussed there you need to adjust selectrum-refine-candidates-function
to configure the filtering you want.
Selectrum uses strict substring matching by default, as mentioned in the README. As the README recommends, you can use prescient.el
to improve this behavior (eww m
will match eww-mode
).
Not that I want to have this, but couldn't a key mapping from be added to selectrum-minibuffer-map
?
Well... one could certainly add a binding, but it's unclear to me what should happen when said binding is triggered. I guess it could insert a hyphen instead. But really I think the way to get the desired behavior is by configuring selectrum-refine-candidates-function
to an appropriate value that does with spaces what is wanted.
It sounds like @gnusupport is using the default selectrum-refine-candidates-function
which is very basic. You should try prescient or orderless which give you much nicer matching behaviour.
It sounds like @gnusupport is using the default
selectrum-refine-candidates-function
which is very basic. You should try prescient or orderless which give you much nicer matching behaviour.
OK, I know orderless but I do not wish to include extra package.
For now, selectrum is not working well for me, I do not know why.
(defun rcd-completing-read-sql-hash (prompt sql &optional history) (let ((hash (rcd-sql-hash sql cf*)) (completion-ignore-case t) (choice (completing-read prompt hash nil t nil history)) (choice (string-trim choice)) (id (gethash choice hash))) (if id id (when (string-match "^>" choice) ;; disregard this choice))))
(rcd-completing-read-sql-hash "People: " "SELECT people_id, get_full_contacts_name(people_id) FROM people LIMIT 30")
then I can use the above function with ivy-mode and helm-mode, fido-mode, but I cannot use it with selectrum-mode, as I see: 0 People
What type are the keys/values of this hash table? Keys that are strings or symbols should be offered as completions as per all-completions docstring.
What are the keys/values of this hash table?
I hope this helps:
(defun rcd-sql-hash (sql pg) "Returns hash with key TEXT [ID] and value ID from SQL result in the form ID, TEXT" (let ((hash (make-hash-table :test 'equal)) (res (rcd-sql sql pg))) (dolist (i res hash) (cond ((eq (type-of i) 'vector) (puthash (format "%s [%s]" (elt i 1) (elt i 0)) (elt i 0) hash))))))
The keys are strings so this should work fine:
(completing-read "Test: "
(let ((table (make-hash-table :test #'equal)))
(puthash "test1" "res1" table)
(puthash "test2" "res2" table)
table))
Can you create test case to reproduce?
The keys are strings so this should work fine:
(completing-read "Test: " (let ((table (make-hash-table :test #'equal))) (puthash "test1" "res1" table) (puthash "test2" "res2" table) table))
Can you create test case to reproduce?
The function above does not give good result in selectrum. It does not work. It gives 0 completion candidates or nothing to select from.
Okay, that is good because it tells us there is probably something wrong with your configuration, it works with emacs -Q
and fresh installed Selectrum with no settings. Could you check what part of your setup could cause this or post it here so we can have a look?
Okay, that is good because it tells us there is probably something wrong with your configuration, it works with
emacs -Q
and fresh installed Selectrum with no settings. Could you check what part of your setup could cause this or post it here so we can have a look?
If I start with emacs -Q
and then evaluate all my init.el I do not
see any problem yet, so that means that function works well after
evaluating init.el manually
I have this line related to selectrum in init.el '(selectrum-extend-current-candidate-highlight t)
And if I set it to nil, it does not help.
Also note that other completing read replacement packages work well, only selectrum does not work. If that is the case it is better to assume that selectrum is not handling something.
When I have changed the theme, then the function started working again. I use only built-in themes, and I used dark one.
(emacs-version) "GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.14.8, Xaw3d scroll bars) of 2020-11-25"
It is hard for me to know why, when it is sensitive and not works then I use other means to get the result.
It works with emacs-sandbox so I assume it is something in your configuration, though it might be the case that you have some setting unrelated to Selectrum which we don't handle correctly and that introduces the issue, in that case we should better figure out the underlying reason. Do you use the latest version of Selectrum?
It works with emacs-sandbox so I assume it is something in your configuration, though it might be the case that you have some setting unrelated to Selectrum which we don't handle correctly and that introduces the issue, in that case we should better figure out the underlying reason. Do you use the latest version of Selectrum?
I have now updated to this commit:
commit bb176a151959fb321e904deac8e0e3a90ffe276f Author: Clemens Radermacher clemera@posteo.net Date: Sat Nov 28 11:48:34 2020 +0100 he Spelling and docs
And it still does not work. After change of theme it worked for short time, then again not.
Because it sees 0 completion candidates (that is known)
(defun selectrum-completing-read
(prompt collection &optional
predicate require-match initial-input
hist def inherit-input-method)
"Read choice using Selectrum. Can be used as completing-read-function'. For PROMPT, COLLECTION, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF, and INHERIT-INPUT-METHOD, see
completing-read'."
(message "%s" collection)
(ignore initial-input inherit-input-method)
(selectrum-read
prompt nil
;; Don't pass initial-input'. We use it internally but it's ;; deprecated in
completing-read' and doesn't work well with the
;; Selectrum paradigm except in specific cases that we control.
:default-candidate (or (car-safe def) def)
:require-match (eq require-match t)
:history hist
:may-modify-candidates t
:minibuffer-completion-table collection
:minibuffer-completion-predicate predicate))
It shows me:
But it shows zero completion candidates when I run function.
Indeed back then it did not work, there was a bug in the hash table normalization please update to latest version where this is fixed.
Indeed back then it did not work, there was a bug in the hash table normalization please update to latest version where this is fixed.
I did update now, but I lost some other things, now it seem to work well. Thank you.
For filtering you should really consider using an additional package, it's much nicer with prescient or orderless. Maybe we could also provide an improved default filtering function but for now it is pretty basic. We can close this issue I guess?
Maybe we could also provide an improved default filtering function but for now it is pretty basic.
Please don't. If someone wants to use a better sorting/filtering - use an additional package. @gnusupport can also write their own small package doing filtering/sorting according to their taste. If not - orderless and prescient fit the bill. But there could very well be an alternative package.
For filtering you should really consider using an additional package, it's much nicer with prescient or orderless. Maybe we could also provide an improved default filtering function but for now it is pretty basic. We can close this issue I guess?
It probable was not my issue, I do not remember complaining about spaces, but for me is most of time faster using built-in completion.
When I need completion is when there is need for relevance search. If completion package does not offer relevance search is for 10 points down. That is what you mean with orderless.
Maybe we could also provide an improved default filtering function but for now it is pretty basic.
Please don't. If someone wants to use a better sorting/filtering - use an additional package. @gnusupport can also write their own small package doing filtering/sorting according to their taste. If not orderless and prescient fit the bill.
Think of your users. Now it is less usable then ivy so you decide.
For me is hard and not useful to look into selectrum. It is not in GNU ELPA, I need extra measures to install it and users of software would need to. Explaining to many people is tedious. I work with teams of people on distance and I have to minimalize their installations. For me personally I have no problems.
When there is need for relevance search I use ivy as that is easiest to fetch straight form Emacs and GNU ELPA, it does not need MELPA. Ideally person would just load one file without any external packages.
Filtering and sorting was never my problem with any completion. I do that in tabulated list mode to handle databases. It took me while to understand how to express myself, but still did not get it well.
I need relevance search in completion packages. That is very well expressed. So far I use relevance search features from the PostgreSQL database as database entries are mostly that I need to complete. Then one simple function can replace all the numerous completing read functions that I would be using only for reason of relevance search. I can as well display results in tabulated-list-mode as that is best where such huge stuff better belongs.
Example is that I can discover true source of income by just doing various intersections and grouping of information from database. Discovering the number of interactions per organization, number of interactions per person and sorting so, helped me gain new income with those people that I already know, but I have lost focus on some of them. It requires sorting and reviewing by the sum of interactions upside down, by country, by organization, and that is where tabulated-list-mode is good.
@minad
Please don't. If someone wants to use a better sorting/filtering - use an additional package.
I was talking about out simple out of order matching on space, I see no harm providing that by default and it helps people for which that is already enough.
@clemera
I was talking about out simple out of order matching on space, I see no harm providing that by default and it helps people for which that is already enough.
If it can replace the existing matching style without adding significantly more code, I am not totally opposed to such a change.
Generally, I would try to boil down the feature set of Selectrum - but I stated that opinion before. In particular if there are excellent external packages and in particular if the feature can naturally be provided externally, like completion styles. But obviously, this works only for features which are not highly Selectrum-dependent.
If Selectrum aims to be the freestanding solution for everything, then everything should be put here, but this does not seem the goal. And then we would just end up with another helm or ivy. I think the strong point is really the separation into components and the minimalism.
If Selectrum aims to be the freestanding solution for everything, then everything should be put here, but this does not seem the goal. And then we would just end up with another helm or ivy. I think the strong point is really the separation into components and the minimalism.
Just guessing that you made selectrum for programmers, not for users.
For me as user, selectrum would not be a choice at all. I have just tried to accommodate my program that it can be used by any completion package and for that reason I am testing selectrum. Not that I would recommend to user to use it. I would recommend ivy.
@gnusupport Which program are you talking about?
If Selectrum aims to be the freestanding solution for everything, then everything should be put here, but this does not seem the goal. And then we would just end up with another helm or ivy. I think the strong point is really the separation into components and the minimalism.
No I agree that is not the goal, My interest is to make Selectrum a flexible solution for completions and provide a reasonable default experience out of the box. I think the current refinement default is a bit annoying and we can fix that without much change, I think.
@gnusupport Which program are you talking about?
Programs like website revision system, customer relationship management, accounting, enterprise resources planning, dynamic knowledge repository like by Doug Engelbart. Those programs manage database. I am using many times completion per day and I basically remove all hard coded completion so that later myself, my staff members and maybe other users may decide which completion to use.
If Selectrum aims to be the freestanding solution for everything, then everything should be put here, but this does not seem the goal. And then we would just end up with another helm or ivy. I think the strong point is really the separation into components and the minimalism.
No I agree that is not the goal, My interest is to make Selectrum a flexible solution for completions and provide a reasonable default experience out of the box. I think the current refinement default is a bit annoying and we can fix that without much change, I think.
I think that developers of selectrum do not give favor to users and it could be all to misunderstandings.
I see the situation for any completion package including Selectrum that it should give to user:
Let me give you comparison:
I know that I am searching for 2 words among 19942 entries, and when I know that one word comes first there is second word after that word. In this case it is not ordered. But some words, numbers, could come before the FIRST, and some words could come between FIRST and SECOND, and after. So in built-in completion I use:
golank* with TAB to come to the selection.
in ivy-mode I use:
gol ank
to come to selection, it is obviously little easier, and additionally I get more visual selection as there are other similar entries.
in Selectrum what I do?
I write "gol" but in this case I could see huge amount of results as second part of the word is missing, but then I CANNOT write the second word because as soon as I write the space then ALL completion vanish.
I am not using full words in completions like selectrum, helm, ivy.
ivy clearly removes the necessity to use joker * chars to complete as I can use space instead of a joker and it is easier.
helm does the same, I need not use joker, I just write "gol ank" and I get the result
with Selectrum:
as soon as I use space, completions will disappear because it does not any way replace the joker function from built-in completion with space. I find that wrong.
both ivy and helm, give me option to use reverse words with spaces, selectrum does not. You even ask me to install other package to get that feature.
If the goal is to make something useful for users, then what does Selectrum upgrade or make more useful?
Maybe it does something technically better, but the value of it is null if I cannot use it in the manner to upgrade the built-in completion, find candidates faster, or minimize typing, or make anything easier.
Dynamic Menu Launcher: dmenu_run -fn "DejaVu:pixelsize=30" -l 10 -i -b -p "Launch: " -nb "dark goldenrod" -nb black
Major expectation is that I may put words in any order and by using spaces. That is what makes the basic relevance search feature.
By demanding from user to use exclusively one space how Selectrum does or otherwise to deny the selection is making selectrum not usable, not accessible piece of software.
By deviating from what other software does and denying user to use space to replace the wildcard * (joker) from built-in completion is another pitfall.
It looks like you want to achieve something, but it does not look it is upgrading anything, it rather looks like regression compared to other software.
dmenu, fzf, ivy, helm all do what I explained, only selectrum does not.
@gnusupport can you link to your program? Is it free software?
@gnusupport can you link to your program? Is it free software?
It is unpublished free software due to its complexities and not being ready for public. I am using it actively. It uses PostgreSQL database. You may write me by email and tell me your specific need. bugs AT gnu.support
@gnusupport I think you are right that Selectrum in its current form is more like a component to build something like helm. Maybe some kind of meta package should compose the available packages, define default keybindings, configurations and such for end users. Maybe this should be the path we should take instead of handling it by Selectrum itself as proposed in #174. What do you think @minad @raxod502?
@clemera I am going all-in with the component-based approach! I think, @oantolin agrees too. We try to avoid overlap between Consult, Embark and Marginalia and try to ensure that these work well together. And everything should also work well together with Selectrum or Icomplete-vertical.
Maybe this should be the path we should take instead of handling it by Selectrum itself as proposed in #174
Yeah, that makes a lot of sense. Another key advantage is we get a new package to come up with a clever name for ;)
It should give selection when using space.
Example is when searching for
eww-mode
function:It will not select when entering: eww m
It will select when entering: eww-m
Maybe it intentionally uses space for selections. It is more useful if space is ignored.