Kram33r · 2022-04-02 07:51
I have recently been playing around a bit with helm for my personal use and, though helm per se is absolutely great, i have found the lack of documentation to be extremely annoying. Now I get it, its open source etc. and just read the source code, but I have been unable to figure out quite a few things from the source.
So, my first question: Can anybody point me towards some good helm documentation that is not the wiki([https://github.com/emacs-helm/helm/wiki](https://github.com/emacs-helm/helm/wiki)), which is extremely lacking if you want to write your own sources instead of just using helm and that is not outdated (like this [https://kitchingroup.cheme.cmu.edu/blog/2015/01/24/Anatomy-of-a-helm-source/](https://kitchingroup.cheme.cmu.edu/blog/2015/01/24/Anatomy-of-a-helm-source/)).
Then two more questions:
1. How can you do multiple columns in a helm source? For example, helm-mini shows file size,name, absolute path etc., all in different columns.
2. How can you show something, but not make it searchable. Say I have a special source for various user-defined commands, and I want to provide not only the name, but also a short description of it, or its keybindings etc, without including them in the filtering, like helm-M-x does.
​
EDIT:Here the answer by the current helm maintainer (I think) -> [https://github.com/emacs-helm/helm/discussions/2493](https://github.com/emacs-helm/helm/discussions/2493) (Summary: Use :match-part to only match against parts of the options). Thanks a lot for the extremely fast answer. Also, there **really** needs to be a better helm documentation. It is such a great tool, but anything other than the most basic extensions requires you to dive into the source code/ask the maintainer, which is less than ideal, I think.
BettaGeorge · 2022-04-02 08:36
I would also be very interested in this. If you do figure it out independently of this thread, would you mind shooting me a PM?
xenodium · 2022-04-02 11:41
For columns, I suspect it’s non-helm specific (create a string and fill/clip with space using width constraint). I’ve used `truncate-string-to-width`. Here’s a sample https://xenodium.com/emacs-fuzzy-search-apples-online-docs (uses ivy, but should also work for helm).
For the matching, it’s been a long time since I looked at helm but :match in helm-build-sync-source may enable to build your own matching logic.
As for docs, I’d go straight to helm’s doc strings and see what they say. For example M-x describe-function helm-build-sync-source.
BettaGeorge · 2022-04-02 11:47
The trouble with the helm doc strings is that they are in places written in very bad English and hard to understand.
Kram33r · 2022-04-02 12:28
So, for your first advice: Thanks. I will look at that
For the one concerning the docs: In theory, yeah. Problem is that this is what I get:
*helm-build-sync-source is a Lisp macro in ‘helm-source.el’.(helm-build-sync-source NAME &rest ARGS) Build a synchronous helm source with name NAME. ARGS are keywords provided by ‘helm-source-sync’.*
This is not very helpful, unfortunately.
I then looked into the source code, where I see that it uses helm-make-source under the hood, which then tells me that it builds a *helm* which I need some time to understand means building a source using the helm function, which, when looked up, tells me regarding other keywords than the absolute basic ones that
*Other keywords are interpreted as local variables of this Helmsession. The ‘helm-’ prefix can be omitted.*
and proceeds to give one example without even listing any other possible keywords.
Now if I want to use the match keyword: Well, its not listed in the docs for the helm function. What input does it take? One candidate? A list of candidates? Should it return bool or something else? I dont know, and I have no idea where I could find it.
I have for the last days been spending more time fighting with helm than actually writing the stuff I was trying to write, so if somebody could point out a) A place where I can find the info I need without crawling through thousands of lines of code or b) an alternative to helm with decent docs and support for what I asked I would be really grateful.
I should probably add that though this has become a bit of a rant I really appreciate the work these people are doing in their spare time and that I think that helm is a great piece of software. Its just that I am really frustrated rn because I can clearly see how useful it could be if I just could figure out how to use it properly.
Kram33r · 2022-04-02 13:02
Sure. But I dont have very high hopes as of rn
xenodium · 2022-04-02 13:09
You're right, had a quick look and there wasn't much in there...
`helm-source-sync` in helm-source.el is helpful to find args. Viewing via `M-x describe-symbol helm-source` is possibly nicer to browse.
Also this post may be handy to put things together [https://www.mattduck.com/emacs-fuzzy-launcher.html](https://www.mattduck.com/emacs-fuzzy-launcher.html)
I’ve written the odd helm utility years ago but these days I use ivy. Usually posted at https://xenodium.com.
ps. there's also M-x helm-documentation
edit: Added more things.
[deleted] · 2022-04-02 14:30
[deleted]
xenodium · 2022-04-02 20:58
I'm not very well-versed in helm, but pieced this together. Mostly by looking at `candidates` and `match-on-real` docs from `M-x describe-symbol helm-source` and `M-x describe-symbol helm-source-sync`.
# helm version
Looks like this [https://imgur.com/a/aHd8DAl](https://imgur.com/a/aHd8DAl)
(helm :sources
(helm-build-sync-source "Pick one of these"
:candidates
(list
;; Display string
(cons "one something not searchable 1 another column"
;; Matched string
"one")
(cons "two something not searchable 2 another column"
"two")
(cons "three something not searchable 3 another column"
"three"))
:match-on-real t ;; Tells helm to search using real part
:action (lambda (item)
(message "%s" item)))
:truncate-lines t)
I moved from helm to ivy some time ago (personal preference).
# ivy version
(ivy-read "Pick one of these: "
(list (propertize "one something not searchable 1 another column"
'searchable "one")
(propertize "two something not searchable 2 another column"
'searchable "two"))
:matcher
(lambda (regex candidates)
(seq-filter (lambda (item)
(string-match-p ivy-text
(get-text-property 0 'searchable item)))
candidates)))
One thing to note, if you don't need fancy display/filter features, `completing-read` can get ya very far and it works with any completion framework you have installed (ie. helm or ivy).
Good luck!
edit: typos