pragmat1c1 · 2022-05-12 19:48
- `org-ql` creates buffers that have search results that I can click.
- Same is true for `occur`. The results can be clicked.
I know that there is hidden infos in those buffers, put in text properties. But that's all I know.
Where do I look for to replicate that? How to I read text properties of clickable lines in buffers? How do I add links to my own buffers via text properties? What are the keywords that I need to search for to learn more about it?
dpoggio · 2022-05-13 02:11
I think this is what you are looking for: https://www.gnu.org/software/emacs/manual/html_node/elisp/Buttons.html
_viz_ · 2022-05-13 02:39
C-u C-x = is generally useful for these kind of things. But what you are looking for is buttons, see insert-text-button.
pragmat1c1 · 2022-05-13 09:59
Great tip! Thank you.
But it does not show me buttons in the current line? Do you know how to get button info for the current line? I tried `(button-at (point))` but I get `nil`. Apparently `org-ql-search` result buffers contain no buttons? But then, how does the buffer allow me to hit RET when I am on a search result line and go to the original buffer?
pragmat1c1 · 2022-05-13 10:02
I am not sure if `org-ql` search results contain buttons? As I have described in my answer to the the comment below, trying to show the button at `point` results in `nil`?
_viz_ · 2022-05-13 10:10
I don't have org-ql installed so I can't tell what it does but looking at occur: it sets follow-link to a non-nil value and has mouse-2 bound to occur-mouse-goto (there's magic that happens that makes mouse-1 execute that command too!). I guess you have to look for the elisp manual's index for follow-link.
[deleted] · 2022-05-13 10:21
[deleted]
pragmat1c1 · 2022-05-13 11:13
Inspecting the text properties via `(text-properties-at (point))` I see a deeply nested list that has neither `follow-link` nor something that contains `button`s.
I have pasted the structure here:
https://www.reddit.com/r/emacs/comments/uop9vk/using_pcaselet_to_get_elements_from_nested/?utm_source=share&utm_medium=web2x&context=3
I see some markers though:
`:org-marker #<marker at 795 in prm.org> :org-hd-marker #<marker at 795 in prm.org> `
Are these responsible for making the lines "clickable"?
dpoggio · 2022-05-13 13:01
I've read your other answer. The thing is, actually, you don't need any "property" to make some text "clickable", you just need to change the behaviour of RET, TAB, the mouse buttons or whatever, so it searches something in the buffer.
You can see this briefly mentioned in the key binding conventions: [https://www.gnu.org/software/emacs/manual/html\_node/elisp/Key-Binding-Conventions.html](https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html)
You could check `C-h k RET` to see if it was remapped. I don't use org-ql, so instead I just made a fast search for you in the org-ql's github repo: [https://github.com/alphapapa/org-ql/search?q=ret](https://github.com/alphapapa/org-ql/search?q=ret). As you can see, \``org-ql` remaps RET.
This is a way of doing it, but back to my comment, buttons are the "Emacs way".
pragmat1c1 · 2022-05-13 13:15
Thank you very much! You saved me hours!
Hitting `C-h k RET` indeed I see that RET is bound to `(org-agenda-switch-to &optional DELETE-OTHER-WINDOWS)` in `org-ql-serch` results.
Going into the function `org-agenda-switch-to` (see [1] below), I see that it runs (among others) this `(org-get-at-bol 'org-marker)` to get the marker embedded in the text properties. This marker contains a pointer to the target file. And the rest of that function jumps to that marker.
[1] https://github.com/tkf/org-mode/blob/c2ebeea6f68f2ef804d387c238e4acccf655dc64/lisp/org-agenda.el#L7978
BunnyLushington · 2022-05-13 16:35
You might also want to examine the source for goto-addr. It's pretty straightforward.
rswgnu · 2022-05-15 02:24
With the GNU Hyperbole package installed, you dom’t have to learn any of this. Simply describe your button pattern using the defal or defil macro and Hyperbole automatically recognizes your buttons/links wherever they occur and a tivates them either with a keybourd or mouse key.
This also simplifies things if you ever want to override the behavior.