diff options
Diffstat (limited to '2025/captions/emacsconf-2025-completion--corfuyasnippet-easier-than-i-thought--pedro-a-aranda-gutirrez--main.vtt')
| -rw-r--r-- | 2025/captions/emacsconf-2025-completion--corfuyasnippet-easier-than-i-thought--pedro-a-aranda-gutirrez--main.vtt | 1507 |
1 files changed, 1507 insertions, 0 deletions
diff --git a/2025/captions/emacsconf-2025-completion--corfuyasnippet-easier-than-i-thought--pedro-a-aranda-gutirrez--main.vtt b/2025/captions/emacsconf-2025-completion--corfuyasnippet-easier-than-i-thought--pedro-a-aranda-gutirrez--main.vtt new file mode 100644 index 00000000..ba28468e --- /dev/null +++ b/2025/captions/emacsconf-2025-completion--corfuyasnippet-easier-than-i-thought--pedro-a-aranda-gutirrez--main.vtt @@ -0,0 +1,1507 @@ +WEBVTT + +NOTE Introduction + +00:00:00.000 --> 00:00:02.319 +Nice to have you here on this talk. + +00:00:02.320 --> 00:00:04.519 +This is my second talk this year. + +00:00:04.520 --> 00:00:09.919 +First one was on things that I've done to Org Mode. + +00:00:09.920 --> 00:00:13.799 +Just as a side note, this presentation + +00:00:13.800 --> 00:00:16.279 +that I'm going to share with you + +00:00:16.280 --> 00:00:19.879 +about my work on Corfu and Yasnippet. + +00:00:19.880 --> 00:00:21.839 +I've prepared that on Org Mode + +00:00:21.840 --> 00:00:25.079 +and exported that with a work I've been doing + +00:00:25.080 --> 00:00:26.839 +to the latest exporter. + +00:00:26.840 --> 00:00:31.959 +Anyhow, what is my talk going to be about? + +00:00:31.960 --> 00:00:34.599 +It's going to be about Corfu and Yasnippet, + +00:00:34.600 --> 00:00:36.599 +which I thought would be difficult to integrate, + +00:00:36.600 --> 00:00:42.799 +and it was much easier than I thought. + +00:00:42.800 --> 00:00:46.959 +So just a short outline, my motivation, + +00:00:46.960 --> 00:00:49.959 +step-by-step of the things that I've been investigating, + +00:00:49.960 --> 00:00:52.515 +and some takeaways. + +NOTE Motivation + +00:00:52.516 --> 00:00:55.919 +So my motivation, yasnippet is old. + +00:00:55.920 --> 00:00:59.599 +So I've tried another. I've tried Tempel + +00:00:59.600 --> 00:01:02.519 +and other template management packages, + +00:01:02.520 --> 00:01:08.159 +but it was really not my cup of tea. So mainly why? + +00:01:08.160 --> 00:01:10.919 +Mainly because I have a nice base of yasnippets + +00:01:10.920 --> 00:01:14.479 +I have generated for my needs. + +00:01:14.480 --> 00:01:17.799 +So it's not that I've been importing snippets + +00:01:17.800 --> 00:01:20.359 +from packages which are out there. + +00:01:20.360 --> 00:01:23.599 +No, they are my snippets. I'm used to them. + +00:01:23.600 --> 00:01:26.559 +And of course, migration counts as a cost. + +00:01:26.560 --> 00:01:32.639 +I've been using Company as my completion point function GUI for years, + +00:01:32.640 --> 00:01:38.167 +but with the time coming in features and so on, + +00:01:38.168 --> 00:01:44.359 +it was not as easy to set up as I wanted for my needs. + +00:01:44.360 --> 00:01:47.181 +So I had been working, + +00:01:47.182 --> 00:01:49.839 +I've been playing with Eglot already some time + +00:01:49.840 --> 00:01:53.119 +for a language server protocol. + +00:01:53.120 --> 00:01:57.039 +I had read about how easy it was to integrate with Corfu, + +00:01:57.040 --> 00:02:02.839 +which was really nice, and I had given it a try, + +00:02:02.840 --> 00:02:10.250 +but I'm using both graphical user interface mode in Emacs + +00:02:10.251 --> 00:02:11.000 +and text mode, + +00:02:11.001 --> 00:02:13.042 +and for text mode you need corfu-terminal, + +00:02:13.043 --> 00:02:16.399 +which was yet another package that I didn't download. + +00:02:16.400 --> 00:02:21.479 +Well, and I didn't really find a quick way + +00:02:21.480 --> 00:02:24.479 +to get rid of company to get yasnippet. + +00:02:24.480 --> 00:02:26.679 +So at the end, when, at the beginning, + +00:02:26.680 --> 00:02:30.107 +when I was using Corfu and Eglot, + +00:02:30.108 --> 00:02:33.959 +I also needed to load company + +00:02:33.960 --> 00:02:35.759 +to have yasnippet support, + +00:02:35.760 --> 00:02:37.639 +which was really like sort of weird + +00:02:37.640 --> 00:02:40.559 +because I wanted to get rid of yasnippet. + +00:02:40.560 --> 00:02:47.199 +Anyhow, while I try now, I'm following the mailing list, + +00:02:47.200 --> 00:02:48.559 +the development mailing list, + +00:02:48.560 --> 00:02:51.799 +and I got interested when I heard something about + +00:02:51.800 --> 00:02:57.119 +TTY child frames being announced for master. + +00:02:57.120 --> 00:02:59.599 +That would mean less packages to download + +00:02:59.600 --> 00:03:04.159 +because I thought I could get rid of Corfu, + +00:03:04.160 --> 00:03:07.359 +and I wanted to try if I could get rid of corfu-terminal + +00:03:07.360 --> 00:03:11.199 +and run Corfu without that. + +00:03:11.200 --> 00:03:18.799 +So, there were some hints there in that mailing list + +00:03:18.800 --> 00:03:21.879 +that made it interesting for me. + +00:03:21.880 --> 00:03:26.639 +And at the end, I'm also like a "why not try"ing man, + +00:03:26.640 --> 00:03:29.119 +so I said, let's give it a try. + +NOTE My requirements + +00:03:29.120 --> 00:03:33.479 +My requirements, I'm working always on a new Emacs, + +00:03:33.480 --> 00:03:36.759 +a decently new Emacs, normally from master, vanilla, + +00:03:36.760 --> 00:03:41.209 +completely vanilla, and I don't have any extras + +00:03:41.210 --> 00:03:42.559 +like Doom or things like that. + +00:03:42.560 --> 00:03:45.519 +So I'm only vanilla. And one of the things + +00:03:45.520 --> 00:03:50.279 +that I don't want is that on this vanilla recent Emacs, + +00:03:50.280 --> 00:03:55.719 +I don't want a corfu-terminal. I need yasnippet. + +00:03:55.720 --> 00:03:57.359 +I'm basically an old man. + +00:03:57.360 --> 00:04:02.479 +Old dog doesn't do new tricks and snippets must, + +00:04:02.480 --> 00:04:06.239 +in my way of working, must be easy and quick to configure, + +00:04:06.240 --> 00:04:10.479 +and tempel or others that I've seen are not. + +00:04:10.480 --> 00:04:13.919 +I don't want any reminiscence of company in my setup. + +00:04:13.920 --> 00:04:18.679 +And of course, don't forget that I've embraced + +00:04:18.680 --> 00:04:24.119 +the language protocol implementations and basically Eglot. + +00:04:24.120 --> 00:04:28.159 +My main focus now is Python and LaTeX, + +00:04:28.160 --> 00:04:31.719 +and I have pylsp and texlab. + +00:04:31.720 --> 00:04:37.599 +I don't want to have to stop using them. + +NOTE Basic setup: corfu + eglot + +00:04:37.600 --> 00:04:40.479 +So basic setup for Corfu and Eglot. + +00:04:40.480 --> 00:04:43.439 +You can find it everywhere you look for it. + +00:04:43.440 --> 00:04:46.559 +It's really easy. + +00:04:46.560 --> 00:04:51.119 +And actually, I also do something somehow naughty, + +00:04:51.120 --> 00:04:53.079 +which is to set this variable, + +00:04:53.080 --> 00:04:55.519 +the corfu-auto variable to true, + +00:04:55.520 --> 00:04:58.399 +although I know it's not recommended, blah, blah, blah. + +00:04:58.400 --> 00:05:02.959 +But I use that because I'm a bit lazy in that. + +NOTE Looking at completion-at-point functions + +00:05:02.960 --> 00:05:07.239 +So next step was looking at completion at point functions. + +00:05:07.240 --> 00:05:10.479 +So the information there, if you go through, is scattered + +00:05:10.480 --> 00:05:13.739 +and sometimes a bit cryptic. + +00:05:13.740 --> 00:05:16.599 +At the end I came up with something like the thing + +00:05:16.600 --> 00:05:18.399 +that you see there on the screen. + +00:05:18.400 --> 00:05:21.879 +It's a function for yas-completion-at-point. + +00:05:21.880 --> 00:05:24.639 +I need my list of keywords, + +00:05:24.640 --> 00:05:30.039 +so that I'm going to be talking later, + +00:05:30.040 --> 00:05:34.399 +and I have my bounds, which is normally a word, + +00:05:34.400 --> 00:05:37.119 +and from that, I get the start and the end + +00:05:37.120 --> 00:05:40.879 +of the thing that I want to + +00:05:40.880 --> 00:05:47.319 +be my seed for looking and bringing up Corfu, + +00:05:47.320 --> 00:05:52.599 +and of course, I need some completion properties here. + +00:05:52.600 --> 00:05:55.719 +This looked like this is what you need to do, + +00:05:55.720 --> 00:05:57.519 +but I had to dig quite deep + +00:05:57.520 --> 00:06:01.319 +to create a yasnippet keyword test + +00:06:01.320 --> 00:06:04.759 +and to understand the completion props. + +00:06:04.760 --> 00:06:11.759 +And as an update of what I've been doing in the last weeks, + +00:06:11.760 --> 00:06:17.606 +I've created a bound of things at point for me + +00:06:17.607 --> 00:06:18.679 +with a different thing + +00:06:18.680 --> 00:06:22.039 +that doesn't skip over non-blank characters, + +00:06:22.040 --> 00:06:25.039 +that only skips over non-blank characters. + +00:06:25.040 --> 00:06:28.999 +Why? Because 'word was confusing LaTeX, + +00:06:29.000 --> 00:06:30.759 +because the backslash, + +00:06:30.760 --> 00:06:34.999 +like in the example for the teletype text, + +00:06:35.000 --> 00:06:37.999 +was not taken into account by 'word. + +00:06:38.000 --> 00:06:39.959 +So I had to create my own one, + +00:06:39.960 --> 00:06:42.119 +which was a bounds-of-thing-at-point, + +00:06:42.120 --> 00:06:44.879 +and then my thing is non-blanks. + +NOTE Making my own (basic) c-a-p-f for yasnippet: the completion properties + +00:06:44.880 --> 00:06:51.179 +Completion at point properties, what are they? + +00:06:51.180 --> 00:06:56.039 +They allow Emacs to know how to handle the information + +00:06:56.040 --> 00:06:58.899 +for a specific completion time. + +00:06:58.900 --> 00:07:03.239 +So you normally will have an annotation, + +00:07:03.240 --> 00:07:08.519 +which then can disappear if you use nerd-icons-corfu, + +00:07:08.520 --> 00:07:11.839 +which is what I'm doing currently, + +00:07:11.840 --> 00:07:17.900 +but I keep it commented just in case I get tired of Corfu + +00:07:17.901 --> 00:07:20.000 +and I want to have my completion function. + +00:07:20.001 --> 00:07:24.959 +Then the :company-kind is actually not something + +00:07:24.960 --> 00:07:30.999 +that comes from the company package, but does not require. + +00:07:31.000 --> 00:07:39.439 +And that's going to allow nerd-icons-corfu to identify + +00:07:39.440 --> 00:07:44.839 +and put the right icon there in the completion list, + +00:07:44.840 --> 00:07:47.159 +as you will see in a couple of minutes. + +00:07:47.160 --> 00:07:50.439 +So it's a snippet key. + +00:07:50.440 --> 00:07:52.599 +So basically what this is telling you + +00:07:52.600 --> 00:07:54.319 +is that this is a snippet keyword. + +00:07:54.320 --> 00:07:56.799 +These two lines, either line, + +00:07:56.800 --> 00:07:59.999 +tell you that this is a snippet keyword, + +00:08:00.000 --> 00:08:05.279 +and that it should be added to the other completions + +00:08:05.280 --> 00:08:10.899 +that you already have in your list. + +NOTE Getting yas-kw-list right: What do I want? + +00:08:10.900 --> 00:08:15.479 +Problems. Looking... Now, next step, + +00:08:15.480 --> 00:08:18.479 +once I had the completion props + +00:08:18.480 --> 00:08:21.439 +which was relatively easy was to go + +00:08:21.440 --> 00:08:24.399 +and get the keyword list right. + +00:08:24.400 --> 00:08:27.199 +I've been looking at pre-existing solutions + +00:08:27.200 --> 00:08:29.319 +like, for example, how the menu + +00:08:29.320 --> 00:08:32.539 +is built in by yasnippet + +00:08:32.540 --> 00:08:34.399 +and it looked a bit like Mission Impossible, + +00:08:34.400 --> 00:08:40.439 +because the approach by all the things + +00:08:40.440 --> 00:08:43.199 +that I have seen and I have examined + +00:08:43.200 --> 00:08:48.659 +is to get the keys and the names + +00:08:48.660 --> 00:08:50.799 +and then further process them. + +00:08:50.800 --> 00:08:55.279 +My take was, do I really need both? + +00:08:55.280 --> 00:08:58.159 +At the end, if I use my own snippets, + +00:08:58.160 --> 00:09:00.439 +I'm going to be using something + +00:09:00.440 --> 00:09:02.559 +I would call meaningful keys for them, + +00:09:02.560 --> 00:09:06.359 +or at least meaningful for... These keys are meaningful for me, + +00:09:06.360 --> 00:09:07.679 +and I try not to repeat them, + +00:09:07.680 --> 00:09:09.959 +because it makes little sense to repeat a keyword. + +00:09:09.960 --> 00:09:13.919 +So why not center everything around the keys only, + +00:09:13.920 --> 00:09:18.879 +and can that help simplify my code? + +NOTE Diving in yasnippet + +00:09:18.880 --> 00:09:23.639 +So I started to dive into yasnippet + +00:09:23.640 --> 00:09:27.319 +and I found a lot of useful semi-hidden functions there. + +00:09:27.320 --> 00:09:30.679 +I discovered that getting the list, + +00:09:30.680 --> 00:09:34.959 +the list of keys for a given mode was not that difficult. + +00:09:34.960 --> 00:09:40.079 +And at the end, what I started doing + +00:09:40.080 --> 00:09:43.399 +is get all the snippet tables used by a major mode + +00:09:43.400 --> 00:09:47.999 +and get the lists of the keys that you have in each table. + +00:09:48.000 --> 00:09:50.375 +Sometimes the list is empty + +00:09:50.376 --> 00:09:54.319 +so it's going to return a nil and that you have to discard. + +00:09:54.320 --> 00:09:57.559 +When you're using structured snippets + +00:09:57.560 --> 00:10:02.479 +like snippets and submenus and so on + +00:10:02.480 --> 00:10:06.399 +to get a structured menu. + +00:10:06.400 --> 00:10:09.834 +You also get some non-strings that you need to filter out + +00:10:09.835 --> 00:10:15.039 +in order to get a workable keyword list. + +00:10:15.040 --> 00:10:21.799 +At the end of the day, what I had was something like this. + +00:10:21.800 --> 00:10:29.519 +I have, for a mode, I went through all modes. + +00:10:29.520 --> 00:10:38.799 +through all modes associated to that, and then I went, + +00:10:38.800 --> 00:10:42.480 +I got my results from all the tables that I had + +00:10:42.520 --> 00:10:45.279 +for a given time, for a given table. + +00:10:45.280 --> 00:10:48.079 +So what you do is you get the tables + +00:10:48.080 --> 00:10:53.119 +that are associated to a mode, because, surprise, surprise, + +00:10:53.120 --> 00:10:55.958 +some modes have more than one table. + +00:10:55.959 --> 00:11:00.917 +And then what you do is you filter out all non strings + +00:11:00.918 --> 00:11:07.719 +from each of the keys list that you have for each table. + +00:11:07.720 --> 00:11:12.379 +So as you see, it's a 1, 2, 3, 4, 5, 6, 7 liner, + +00:11:12.380 --> 00:11:14.319 +which was not too much. + +00:11:14.320 --> 00:11:20.039 +By the way, if someone from Yasnippet is around, + +00:11:20.040 --> 00:11:26.959 +I sent a pull request to include this + +00:11:26.960 --> 00:11:28.999 +as a public function in Yasnipit + +00:11:29.000 --> 00:11:32.319 +because it might be nice to have it in the package + +00:11:32.320 --> 00:11:33.840 +in order to do this kind of things. + +NOTE Fine-tuning: adding cape + +00:11:33.840 --> 00:11:41.239 +So fine-tuning. Just adding a yas completion + +00:11:41.240 --> 00:11:44.719 +to the completion point functions was not enough. + +00:11:44.720 --> 00:11:46.799 +I don't really know, + +00:11:46.800 --> 00:11:51.199 +but :exclusive no didn't seem to work how I wanted + +00:11:51.200 --> 00:11:54.549 +so I needed to escape... Sorry. Yeah. + +00:11:54.550 --> 00:11:57.399 +I was saying I was getting rid of packages, + +00:11:57.400 --> 00:12:00.279 +and I had to add one package + +00:12:00.280 --> 00:12:04.479 +in order to get a function, which is very, very, nice, + +00:12:04.480 --> 00:12:08.919 +and which is part of the cape function of the cape package, + +00:12:08.920 --> 00:12:12.799 +and that's cape-capf-super. + +00:12:12.800 --> 00:12:16.439 +So at the end, using that, you define an alias, + +00:12:16.440 --> 00:12:23.199 +which, for that, where you use cape-capf-super + +00:12:23.200 --> 00:12:25.799 +to have a list of what you want... + +00:12:25.800 --> 00:12:29.079 +So in this case, for example, for the demo + +00:12:29.080 --> 00:12:31.419 +I'm going to make, I'm using yas completion + +00:12:31.420 --> 00:12:36.172 +and then the elisp-completion-at-point function + +00:12:36.173 --> 00:12:37.719 +provided by Emacs. + +00:12:37.720 --> 00:12:43.999 +I combine them using cape-capf-super, + +00:12:44.000 --> 00:12:47.679 +and with that, I create a completion point, + +00:12:47.680 --> 00:12:53.159 +a new completion point function which I call cape-lisp-mode, + +00:12:53.160 --> 00:12:58.480 +and then I add this alias to the completion functions list, + +00:12:58.520 --> 00:13:03.803 +and with that, it is enough. + +NOTE Automatic snippet expansion + +00:13:03.804 --> 00:13:05.719 +Snippet expansion. + +00:13:05.720 --> 00:13:13.839 +If you want to have your snippets expanded automatically, + +00:13:13.840 --> 00:13:27.999 +you have to add an exit function to the, I'm sorry, + +00:13:28.000 --> 00:13:30.879 +to the completion properties. + +00:13:30.880 --> 00:13:34.119 +Yet another functionality you have to add. + +00:13:34.120 --> 00:13:39.199 +And to avoid this automatic selection to be too eager, + +00:13:39.200 --> 00:13:47.973 +you need to add this setq corfu-on-exact-match to nil + +00:13:47.974 --> 00:13:51.839 +because otherwise, you will always get the snippet expanded, + +00:13:51.840 --> 00:13:55.039 +even if you don't want it. Basically, why? + +00:13:55.040 --> 00:13:57.639 +Basically, because this would be suboptimal + +00:13:57.640 --> 00:14:05.359 +because the key can appear as part of a variable name. + +NOTE Themes + +00:14:05.360 --> 00:14:10.599 +Another nice thing, I'm also creating my own themes. + +00:14:10.600 --> 00:14:13.759 +I'm trying to have very sleek themes + +00:14:13.760 --> 00:14:16.839 +that only cover the modes that I use + +00:14:16.840 --> 00:14:22.959 +and for that I have my own theme creator fork + +00:14:22.960 --> 00:14:26.959 +from the original theme creator. + +00:14:26.960 --> 00:14:29.292 +In my personal fork that I'm running at home, + +00:14:29.293 --> 00:14:33.859 +I only have the faces for the modes I use. + +00:14:33.860 --> 00:14:38.159 +I don't want to overload the thing + +00:14:38.160 --> 00:14:41.839 +with too much different things. + +00:14:41.840 --> 00:14:45.999 +Looking at this, I really didn't need, as you will see now, + +00:14:46.000 --> 00:14:50.079 +I don't need to add anything to my themes, + +00:14:50.080 --> 00:14:53.279 +because the default faces for Corfu + +00:14:53.280 --> 00:14:58.319 +adapt quite well to most of the themes. + +NOTE My check-list + +00:14:58.320 --> 00:15:01.478 +So if I go back to my checklist, + +00:15:01.479 --> 00:15:02.839 +decently new Emacs, yes, + +00:15:02.840 --> 00:15:06.559 +compiled. The one you'll see + +00:15:06.560 --> 00:15:09.239 +in the demo I'm doing is a master + +00:15:09.240 --> 00:15:11.999 +compiled the day before yesterday + +00:15:12.000 --> 00:15:15.199 +and I don't need corfu-terminal there. + +00:15:15.200 --> 00:15:16.559 +I need yasnippet, + +00:15:16.560 --> 00:15:20.159 +and you're going to see that in a second + +00:15:20.160 --> 00:15:24.439 +with a couple of snippets that I can expand here. + +00:15:24.440 --> 00:15:27.479 +I don't want any reminiscence of a company in my setup, + +00:15:27.480 --> 00:15:32.119 +and there's none. Well, actually, :company-kind is there + +00:15:32.120 --> 00:15:33.719 +you see the company there, + +00:15:33.720 --> 00:15:39.559 +but it isn't defined by company strictly speaking, + +00:15:39.560 --> 00:15:44.679 +and for... I don't want... I need Eglot integration + +00:15:44.680 --> 00:15:48.583 +which I will also be showing you. + +NOTE Takeaways + +00:15:48.584 --> 00:15:50.400 +Takeaways from all this, + +00:15:50.440 --> 00:15:55.279 +if you accept the extra burden + +00:15:55.280 --> 00:16:02.239 +of corfu-terminal for Emacs 30 or earlier Emacs 30s, + +00:16:02.240 --> 00:16:07.559 +it's not too difficult to get this set up running. + +00:16:07.560 --> 00:16:11.759 +Corfu was easier to integrate and configure than Company, + +00:16:11.760 --> 00:16:13.799 +and it's much lighter in terms + +00:16:13.800 --> 00:16:20.039 +of number of lines, et cetera. I learned a lot. + +00:16:20.040 --> 00:16:25.159 +Well, actually, yes, with the help of Cape, + +00:16:25.160 --> 00:16:27.399 +but it is much lighter and much easier + +00:16:27.400 --> 00:16:30.119 +to integrate and configure. + +00:16:30.120 --> 00:16:34.879 +I've learned a lot about computational functions in the process, + +00:16:34.880 --> 00:16:40.439 +which is, something that is always nice to learn new things + +00:16:40.440 --> 00:16:45.039 +and the nerd-icons-corfu makes the... + +00:16:45.040 --> 00:16:48.319 +at least, at this point in time... I might get tired of it, + +00:16:48.320 --> 00:16:50.399 +but at this point in time, it makes + +00:16:50.400 --> 00:16:58.039 +a very nice overall look and feel for Emacs. + +NOTE Requests (to whom it may concern) + +00:16:58.040 --> 00:17:02.039 +Requests (to whom it may concern): cape has nice features + +00:17:02.040 --> 00:17:06.279 +that maybe could make their way into emacs. + +00:17:06.280 --> 00:17:08.064 +I'm thinking basically about + +00:17:08.065 --> 00:17:12.399 +this super cape functionality + +00:17:12.400 --> 00:17:18.799 +which is very nice, and overcomes the problem of linking, + +00:17:18.800 --> 00:17:22.239 +and this :exclusive and all this kind of things + +00:17:22.240 --> 00:17:26.479 +that we have currently in Corfu + +00:17:26.480 --> 00:17:28.439 +with the completion-at-point functions. + +00:17:28.440 --> 00:17:32.959 +Corfu is also really nice to have, and it's not too big. + +00:17:32.960 --> 00:17:35.559 +So is there any possibility + +00:17:35.560 --> 00:17:40.079 +that it makes its way into Emacs? + +00:17:40.080 --> 00:17:42.399 +Please keep yasnippet alive. + +00:17:42.400 --> 00:17:48.559 +I'm not saying here that my pull request should be there, + +00:17:48.560 --> 00:17:51.559 +but it would be nice if someone took a look + +00:17:51.560 --> 00:17:57.399 +and made it part of Yasnippet. + +00:17:57.400 --> 00:18:01.799 +And P.S., currently on master, + +00:18:01.800 --> 00:18:04.292 +there's a lot of semantic highlighting going on, + +00:18:04.293 --> 00:18:07.125 +which is very, very nice. No criticism on that. + +00:18:07.126 --> 00:18:12.417 +But you may need to add to your snippet hook + +00:18:12.418 --> 00:18:25.039 +this simple local value for elisp-fontify-semantically, + +00:18:25.040 --> 00:18:30.719 +because at least in my case, I felt that + +00:18:30.720 --> 00:18:32.439 +the faces were a bit too pushy, + +00:18:32.440 --> 00:18:37.280 +so I had to make the snippet mode + +00:18:37.334 --> 00:18:43.579 +use the old Emacs Lisp fontification. + +00:18:43.580 --> 00:18:46.279 +This would be my talk. + +00:18:46.280 --> 00:18:54.999 +Any initial reactions to this? There's a question here. + +NOTE Q: Did you try yasnippet-capf? If so, what did you miss from it that this approach has? Thanks! https://github.com/elken/yasnippet-capf + +00:18:55.000 --> 00:18:59.159 +Someone asked, did you try yasnippet-capf? + +00:18:59.160 --> 00:19:05.959 +If so, what did you miss from this approach? I tried that. + +00:19:05.960 --> 00:19:11.239 +And it's not that I missed anything. + +00:19:11.240 --> 00:19:15.839 +It was more or less that I wanted to do it myself. + +00:19:15.840 --> 00:19:24.159 +So I wanted to see what was behind it. That's my answer. + +00:19:24.160 --> 00:19:26.679 +There are lots of packages there, + +00:19:26.680 --> 00:19:31.719 +but I try to keep learning. So, this was a nice objective + +00:19:31.720 --> 00:19:40.159 +to learn a bit more about Emacs. And now, just a second. + +NOTE A small demo + +00:19:40.160 --> 00:19:44.879 +Now, a small demo. This is the interaction. + +00:19:44.880 --> 00:19:47.199 +And as you see, I have the snippet there. + +00:19:47.200 --> 00:19:52.879 +and I have a couple of snippets. + +00:19:52.880 --> 00:19:55.839 +So, for example, if I would like to say + +00:19:55.840 --> 00:19:58.879 +I want to define a function, I can go like this. + +00:19:58.880 --> 00:20:00.519 +And what you see here is that + +00:20:00.520 --> 00:20:04.319 +I have two snippets appearing and then some variables. + +00:20:04.320 --> 00:20:09.879 +So, I could go for defun or if I want a key map, for def-keymap, + +00:20:09.880 --> 00:20:11.479 +which would be something like this. + +00:20:11.480 --> 00:20:18.319 +And then when I press enter, I get directly into the map + +00:20:18.320 --> 00:20:26.719 +and I could say like, show off map. + +00:20:26.720 --> 00:20:30.079 +Then it sets out directly a :prefix t, + +00:20:30.080 --> 00:20:35.039 +which is something that I asked for in Emacs master. + +00:20:35.040 --> 00:20:39.479 +So with :prefix t, for those who prefix it true, + +00:20:39.480 --> 00:20:41.399 +for those who don't know it, + +00:20:41.400 --> 00:20:49.042 +it makes integrating this into keymaps + +00:20:49.043 --> 00:20:52.125 +in use-package much easier. + +00:20:52.126 --> 00:20:54.167 +So the next thing would be, + +00:20:54.168 --> 00:20:56.500 +I would like to write a description, + +00:20:56.501 --> 00:21:04.999 +like, for example, a cool show-off keymap, + +00:21:05.000 --> 00:21:08.599 +and then my keys are my functions, and that would be it. + +00:21:08.600 --> 00:21:15.839 +Of course, you also have like this define function. + +00:21:15.840 --> 00:21:21.679 +And of course you can say, that's nice, + +00:21:21.680 --> 00:21:23.799 +but you're not showing the integration + +00:21:23.800 --> 00:21:25.439 +with Eglot, and you're right. + +00:21:25.440 --> 00:21:30.279 +So I'm going just to open up a small program + +00:21:30.280 --> 00:21:33.319 +that I'm currently developing in Python. + +00:21:33.320 --> 00:21:38.239 +This is a tool to do things in MP3. + +00:21:38.240 --> 00:21:42.279 +And here I would have, like, all these things. + +00:21:42.280 --> 00:21:45.359 +As you see here in the bottom, + +00:21:45.360 --> 00:21:49.079 +server is running, file is local, eglot is active. + +00:21:49.080 --> 00:21:57.919 +So I have my eglot stop and then I go down. + +00:21:57.920 --> 00:22:00.519 +And I want to add a new argument here. + +00:22:00.520 --> 00:22:08.799 +I would go like for it. I would go like add flag. + +00:22:08.800 --> 00:22:13.759 +For example, I would add a flag + +00:22:13.760 --> 00:22:27.859 +and I would get a new flag to add here. + +00:22:27.860 --> 00:22:33.119 +Oops. Of course, this is integrated into Eglot, + +00:22:33.120 --> 00:22:42.759 +so I'm getting your information about what I have. + +00:22:42.760 --> 00:22:52.359 +I could... I don't have os, so I would need to import here, + +00:22:52.360 --> 00:22:59.279 +but I can go up just to see... + +00:22:59.280 --> 00:23:01.759 +If I would like to, for example, + +00:23:01.760 --> 00:23:11.879 +create a new regular expression, + +00:23:11.880 --> 00:23:15.439 +I'm getting this information that you see right now on call. + +00:23:15.440 --> 00:23:17.359 +I'm getting that from Eglot. + +00:23:17.360 --> 00:23:18.919 +So you see there's the integration + +00:23:18.920 --> 00:23:20.839 +with Eglot too in Python. + +00:23:20.840 --> 00:23:23.559 +I have Eglot, and as you've seen + +00:23:23.560 --> 00:23:30.239 +I also have the... and all these are snippets. Fine. + +00:23:30.240 --> 00:23:38.199 +More reactions and questions? + +00:23:38.200 --> 00:23:54.239 +Because that would be my show off here. + +00:23:54.240 --> 00:24:09.379 +Any questions? Any more questions on the pad? + +00:24:09.380 --> 00:24:11.479 +but anyhow I'm going to try, + +00:24:11.480 --> 00:24:13.239 +I'm going to try yasnippet too + +00:24:13.240 --> 00:24:16.279 +and I'm going to be answering this question more + +00:24:16.280 --> 00:24:21.079 +yeah time is good okay fine + +00:24:21.080 --> 00:24:30.039 +so I would be done if there's no more reactions... + +00:24:30.040 --> 00:24:33.239 +Thank you so much. You're welcome. + +00:24:33.240 --> 00:24:34.919 +If you have any other questions, folks, + +00:24:34.920 --> 00:24:37.079 +you can always follow up on the pad. + +00:24:37.080 --> 00:24:39.639 +That was a great demonstration, and I'm sure lots of people + +00:24:39.640 --> 00:24:43.519 +are looking forward to trying it out. + +00:24:43.520 --> 00:24:45.239 +Oh, I see some questions coming in now. + +00:24:45.240 --> 00:24:46.199 +You may go ahead if you like. + +00:24:46.200 --> 00:24:51.879 +Okay, fine. There's someone asking: + +NOTE Q: Do special characters in yasnippets work well too? example <FD ? + +00:24:51.880 --> 00:24:57.079 +Do special characters in your snippets work well too? + +00:24:57.080 --> 00:25:02.479 +what kind of... I don't use special characters in the key name, + +00:25:02.480 --> 00:25:05.199 +so in this case everything works quite nicely, + +00:25:05.200 --> 00:25:11.359 +and then I'm passing, I'm passing the control to yasnippet, + +00:25:11.360 --> 00:25:13.679 +so if there's any problem in yasnippet + +00:25:13.680 --> 00:25:15.359 +with special characters, + +00:25:15.360 --> 00:25:24.399 +that, I don't know. I don't use that as a key. + +00:25:24.400 --> 00:25:30.519 +I'm just using for key names. + +00:25:30.520 --> 00:25:38.399 +I normally use a... I only use letters, but that should work. + +00:25:38.400 --> 00:25:43.959 +I mean, let's, uh, let's give it a trial. + +00:25:43.960 --> 00:25:58.039 +Let's kill here. Yes. I don't want, I don't want to touch this. + +00:25:58.040 --> 00:26:01.039 +Ugh. Let's go into this one. + +00:26:01.040 --> 00:26:06.920 +Let's say I'm going to define this, for example, like this, + +00:26:06.959 --> 00:26:10.919 +and I'm going to create a new snippet. + +00:26:10.920 --> 00:26:15.359 +I'm going to create a new snippet + +00:26:15.360 --> 00:26:18.119 +and use this. For example, when you look at this, + +00:26:18.120 --> 00:26:31.042 +if you have the new way of the new Emacs + +00:26:31.043 --> 00:26:37.667 +semantical highlighting working, + +00:26:37.668 --> 00:26:40.625 +this would be quite cramped. This is why I'm using, + +00:26:40.626 --> 00:26:44.899 +this is why I said the snippet, the... + +00:26:44.900 --> 00:26:55.139 +So is this more or less what you're talking about? + +00:26:55.140 --> 00:27:12.579 +This is what you're talking about. Snippet. Save the snippet. + +00:27:12.580 --> 00:27:15.479 +Snippet, load and put window. + +00:27:15.480 --> 00:27:21.279 +Enable interaction mode. Yes, I'm going to save. + +00:27:21.280 --> 00:27:31.059 +And I'm going to save that as fd test in the file. + +00:27:31.060 --> 00:27:41.479 +No, I'm going to save this. Load. Load input window. + +00:27:41.480 --> 00:27:53.679 +I'm going to put this in Emacs Lisp mode. I want to save it. No. + +00:27:53.680 --> 00:28:27.359 +I'm going to write that directly into Emacs Lisp mode. + +00:28:27.360 --> 00:28:30.639 +Going to go back into scratch buffer, + +00:28:30.640 --> 00:28:43.079 +and here I have it. We have it here. But anyhow... + +00:28:43.080 --> 00:28:46.934 +And I'm just going to try to see, if I feel like... + +00:28:46.935 --> 00:28:52.663 +Empty? Of course, there's only one. + +00:28:52.664 --> 00:28:58.839 +It will not show in Corfu. + +00:28:58.840 --> 00:29:01.519 +but I mean, I don't have any problems + +00:29:01.520 --> 00:29:20.999 +with that, as you see. Was that what you were meaning? + +00:29:21.000 --> 00:29:24.839 +Yeah, I guess that works. Fine. + +00:29:24.840 --> 00:29:29.039 +All right, shall we wrap up here + +00:29:29.040 --> 00:29:31.279 +so that you can have supper + +00:29:31.280 --> 00:29:40.919 +and have lunch and other things? Okay, fine for me. + +00:29:40.920 --> 00:29:46.319 +I was hoping to see the drop down. Just a second. + +00:29:46.320 --> 00:29:49.959 +I think we can do that too. Two seconds. + +00:29:49.960 --> 00:29:52.559 +How can we do that with a drop down? + +00:29:52.560 --> 00:29:57.719 +Yeah, if I say something like this. + +00:29:57.720 --> 00:30:04.919 +And then I go and save it. + +00:30:04.920 --> 00:30:08.799 +And I'm going to go and write this + +00:30:08.800 --> 00:30:16.719 +into, with a second, fine. + +00:30:16.720 --> 00:30:18.179 +And now I need to quit here, sorry. + +00:30:18.180 --> 00:30:26.639 +And I'm going to come back in a second with another remark. + +00:30:26.640 --> 00:30:31.559 +Well, I'm bringing back and now let's see. + +00:30:31.560 --> 00:30:34.839 +Let's see what we have in yasnippet. + +00:30:34.840 --> 00:30:44.159 +It's not there. Why not? Just a second. Let's see if I go. + +00:30:44.160 --> 00:30:47.839 +I don't know if it matters that the name was + +00:30:47.840 --> 00:30:52.599 +that didn't have the characters in the beginning. + +00:30:52.600 --> 00:31:05.699 +Just a second. I think I know what is happening here. + +00:31:05.700 --> 00:31:21.439 +Do I have them? I'm going to clean. + +00:31:21.440 --> 00:31:28.879 +[Sacha]: Oh, you're back in your home directories is why. + +00:31:28.880 --> 00:31:35.004 +cd - to get back in. + +00:31:35.005 --> 00:31:35.879 +Yeah. That's right. + +00:31:35.880 --> 00:31:37.799 +So you see how the name also has... + +00:31:37.800 --> 00:31:39.319 +it doesn't have the same as the keys. + +00:31:39.320 --> 00:31:41.039 +I don't know if that affects what shows up. + +00:31:41.040 --> 00:31:44.880 +[Pedro]: Yeah, we we can try that. + +00:31:44.881 --> 00:31:49.999 +That's a quick one. This is my... + +00:31:50.000 --> 00:31:51.279 +Fine, now that I have this, + +00:31:51.280 --> 00:31:55.359 +which is going to be quicker, we check again. + +00:31:55.360 --> 00:31:57.919 +They both seem to be the same now + +00:31:57.920 --> 00:32:03.079 +and I don't know if that affects, but anyhow, let's try it. + +00:32:03.080 --> 00:32:07.679 +I go and then I look at the yasnippet, if it's there. + +00:32:07.680 --> 00:32:09.956 +Yes, it is. + +00:32:09.957 --> 00:32:11.879 +[Sacha]: Yeah, it's there. + +00:32:11.880 --> 00:32:18.559 +[Pedro]: And then if I say there, there you are. Oh, look at that. + +00:32:18.560 --> 00:32:22.167 +It doesn't seem to be affecting. + +00:32:22.168 --> 00:32:24.159 +[Sacha]: Fantastic. + +00:32:24.160 --> 00:32:32.119 +[Pedro]: And by the way, it is there. + +NOTE Emacs Lisp + +00:32:32.120 --> 00:32:33.999 +[Sacha]: Yeah, I really should spend time + +00:32:34.000 --> 00:32:36.599 +getting more templates set up with yasnippet. + +00:32:36.600 --> 00:32:37.639 +I really love the fact that + +00:32:37.640 --> 00:32:40.399 +you can evaluate Emacs Lisp in it too. + +00:32:40.400 --> 00:32:43.399 +[Pedro]: Yeah, I mean, just to make it bigger, + +00:32:43.400 --> 00:32:51.359 +try that because if I go into my, for example, + +00:32:51.360 --> 00:32:55.679 +into my org mode stuff + +00:32:55.680 --> 00:32:59.439 +and in my org mode, I go to the article, + +00:32:59.440 --> 00:33:03.319 +which is one of the big ones. + +00:33:03.320 --> 00:33:05.119 +I have things like, for example, + +00:33:05.120 --> 00:33:09.199 +I defined a couple of functions here to do if it's empty, + +00:33:09.200 --> 00:33:16.399 +if that is empty, just add a white space. + +00:33:16.400 --> 00:33:19.599 +If one is empty, add a white space. + +00:33:19.600 --> 00:33:23.319 +add a white space here so it becomes a comment. + +00:33:23.320 --> 00:33:27.279 +I have functions to do more things on that, + +00:33:27.280 --> 00:33:29.799 +and I also have menus to see + +00:33:29.800 --> 00:33:31.439 +what language I want to choose for + +00:33:31.440 --> 00:33:33.250 +my spell checking and so on. + +00:33:33.251 --> 00:33:35.480 +And that's all... As you see, + +00:33:35.481 --> 00:33:39.417 +this is Lisp being evaluated. + +00:33:39.418 --> 00:33:45.119 +So yes, do. I really encourage you + +00:33:45.120 --> 00:33:46.519 +[Sacha]: I've also heard people use it, + +00:33:46.520 --> 00:33:47.799 +like, especially if they're working + +00:33:47.800 --> 00:33:49.919 +in different programming languages, + +00:33:49.920 --> 00:33:52.399 +so they can just have the syntax + +00:33:52.400 --> 00:33:54.359 +for the different languages + +00:33:54.360 --> 00:33:58.239 +be condensed into a consistent abbreviation. + +00:33:58.240 --> 00:34:01.319 +[Pedro]: Yeah. And look, this is my article. I have another. + +00:34:01.320 --> 00:34:07.799 +This is when I'm writing articles. I have another one. + +00:34:07.800 --> 00:34:10.279 +I have another one for writing letters + +00:34:10.280 --> 00:34:14.399 +in org mode and so on. So, it's like letter, block, + +00:34:14.400 --> 00:34:16.559 +and you have the complete infrastructure + +00:34:16.560 --> 00:34:20.159 +and you don't have to type it by hand. + +00:34:20.160 --> 00:34:22.879 +So, it's really, really nice. + +00:34:22.880 --> 00:34:25.959 +[Sacha]: Hmm, I think it might be nice to have + +00:34:25.960 --> 00:34:28.079 +a future Emacs carnival, you know, + +00:34:28.080 --> 00:34:31.239 +shared blogging theme thing be around + +00:34:31.240 --> 00:34:33.359 +having people share their snippets. + +00:34:33.360 --> 00:34:39.359 +[Pedro]: Yasnippets and other things. Like for example, + +00:34:39.360 --> 00:34:41.319 +this is something stupid. + +00:34:41.320 --> 00:34:44.519 +I'm switching my themes. All right. + +00:34:44.520 --> 00:34:48.639 +And of course, there you see, + +00:34:48.640 --> 00:34:51.439 +I have also, this is also with, + +00:34:51.440 --> 00:34:55.792 +this is my way of switching buffers, + +00:34:55.793 --> 00:34:58.159 +which is with the shift control and tab, + +00:34:58.160 --> 00:35:00.559 +I can switch different families + +00:35:00.560 --> 00:35:02.519 +and then when I'm in a family, + +00:35:02.520 --> 00:35:06.999 +I can go and switch with control tab between the different, + +00:35:07.000 --> 00:35:13.659 +I'm using tab line by the way. I'm not using the other one. + +00:35:13.660 --> 00:35:20.839 +I'm using the old plain tab line with my themes. + +00:35:20.840 --> 00:35:23.519 +So that's more or less everything. + +00:35:23.520 --> 00:35:26.519 +[Sacha]: Thank you for the peek into your workflow. + +00:35:26.520 --> 00:35:30.759 +I will work on getting the recordings for the live talks + +00:35:30.760 --> 00:35:34.458 +sorted out at some point very soon. + +00:35:34.459 --> 00:35:37.084 +I might even be able to get them out next week. + +00:35:37.085 --> 00:35:43.667 +So thanks again. All right. Have a nice supper. + +00:35:43.668 --> 00:35:44.920 +[Pedro]: Same to you. |
