summaryrefslogtreecommitdiffstats
path: root/2022/captions/emacsconf-2022-buttons--linking-personal-info-with-hyperbole-implicit-buttons--mats-lidell--main.vtt
blob: e7e588795aeeafbe54074d5293317f42feed561d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
WEBVTT captioned by sachac

1
00:00:00.000 --> 00:00:06.280
Hi everyone! I'm Mats Liddell.

2
00:00:06.280 --> 00:00:07.320
In this talk, I will show

3
00:00:07.320 --> 00:00:09.040
how you can link to personal data

4
00:00:09.040 --> 00:00:13.960
using Hyperbole's support for implicit button types.

5
00:00:13.960 --> 00:00:16.040
Before starting, a few words about me.

6
00:00:16.040 --> 00:00:18.000
I work as a software engineer,

7
00:00:18.000 --> 00:00:19.200
and in my spare time

8
00:00:19.200 --> 00:00:21.280
I'm co-maintaining the Hyperbole package

9
00:00:21.280 --> 00:00:24.360
together with the package author Bob Weiner.

10
00:00:24.360 --> 00:00:27.240
Hyperbole dates back to 1993,

11
00:00:27.240 --> 00:00:29.680
and have had some inactive years in the past,

12
00:00:29.680 --> 00:00:31.680
but work is now active again.

13
00:00:31.680 --> 00:00:33.080
The package is available

14
00:00:33.080 --> 00:00:36.160
through the GNU ELPA package archive.

15
00:00:36.160 --> 00:00:37.960
The talk will focus on

16
00:00:37.960 --> 00:00:39.600
creation of implicit button types.

17
00:00:39.600 --> 00:00:41.480
For more info on Hyperbole,

18
00:00:41.480 --> 00:00:43.120
listen to other presentations

19
00:00:43.120 --> 00:00:46.360
and check out the package documentation.

20
00:00:46.360 --> 00:00:50.000
What I want you to take with you from this talk is

21
00:00:50.000 --> 00:00:51.640
that the implicit button types

22
00:00:51.640 --> 00:00:54.440
can make patterns in your files into buttons;

23
00:00:54.440 --> 00:00:56.600
and that new implicit button types

24
00:00:56.600 --> 00:00:58.480
can quickly be created by using

25
00:00:58.480 --> 00:01:01.760
the `defil` and the `defal` macros.

26
00:01:01.760 --> 00:01:05.160
So what is an implicit button type?

27
00:01:05.160 --> 00:01:06.800
I think of it as a text pattern

28
00:01:06.800 --> 00:01:08.920
that has some extended meaning.

29
00:01:08.920 --> 00:01:10.760
When you see the pattern in the text,

30
00:01:10.760 --> 00:01:12.800
you can think of it as a button type.

31
00:01:12.800 --> 00:01:13.880
When you press the button,

32
00:01:13.880 --> 00:01:16.880
something related to that meaning happens.

33
00:01:16.880 --> 00:01:19.000
It can be jumping to some place,

34
00:01:19.000 --> 00:01:22.440
opening an external tool, doing some computation.

35
00:01:22.440 --> 00:01:24.160
So there can be some action

36
00:01:24.160 --> 00:01:29.920
associated with the pattern.

37
00:01:29.920 --> 00:01:33.320
To make it clear, let's look at some examples.

38
00:01:33.320 --> 00:01:36.080
Let's start with something that is maybe so obvious

39
00:01:36.080 --> 00:01:39.600
that you don't even think of it as a pattern: a file name.

40
00:01:39.600 --> 00:01:41.360
When you see such a string in text,

41
00:01:41.360 --> 00:01:45.360
you will naturally associate it with a file on disk,

42
00:01:45.360 --> 00:01:46.720
and if you would click on it,

43
00:01:46.720 --> 00:01:52.680
you would probably expect that file to open.

44
00:01:52.680 --> 00:01:55.120
In the first sentence on the slide,

45
00:01:55.120 --> 00:01:56.840
you might recognize the file name

46
00:01:56.840 --> 00:02:01.760
for the bash initialization file, ~/.bashrc.

47
00:02:01.760 --> 00:02:03.840
Hyperbole comes with built-in support

48
00:02:03.840 --> 00:02:06.520
for recognizing files and directory path names

49
00:02:06.520 --> 00:02:08.680
as implicit button types in text.

50
00:02:08.680 --> 00:02:11.760
For Hyperbole to take action on the button type,

51
00:02:11.760 --> 00:02:13.440
you move the cursor within the button

52
00:02:13.440 --> 00:02:16.320
and press M-RET or use a mouse click.

53
00:02:16.320 --> 00:02:22.360
So let's try that.

54
00:02:22.360 --> 00:02:27.720
Similar for the path, /usr/local in the next sentence.

55
00:02:27.720 --> 00:02:29.520
That will open the corresponding

56
00:02:29.520 --> 00:02:37.080
directory using dired-mode.

57
00:02:37.080 --> 00:02:39.760
Other examples of built-in implicit button types

58
00:02:39.760 --> 00:02:43.720
that Hyperbole recognizes are email addresses,

59
00:02:43.720 --> 00:02:47.320
web addresses, requests for comment documents

60
00:02:47.320 --> 00:02:50.120
in the form of RFC followed by a number,

61
00:02:50.120 --> 00:02:53.040
GNU debbugs issues, plus many more.

62
00:02:53.040 --> 00:02:55.360
These are some examples

63
00:02:55.360 --> 00:02:58.080
of implicit button types with built-in support.

64
00:02:58.080 --> 00:02:59.920
I list them here to give you an idea

65
00:02:59.920 --> 00:03:02.480
how the text pattern in itself is enough

66
00:03:02.480 --> 00:03:03.960
for the system to recognize it

67
00:03:03.960 --> 00:03:10.120
as something actionable.

68
00:03:10.120 --> 00:03:12.480
So as shown, Hyperbole has built-in support

69
00:03:12.480 --> 00:03:14.040
for implicit buttons.

70
00:03:14.040 --> 00:03:16.120
There's only one problem here.

71
00:03:16.120 --> 00:03:17.920
The behavior is predefined.

72
00:03:17.920 --> 00:03:20.240
There is of course a trade off.

73
00:03:20.240 --> 00:03:21.560
It is convenient to get

74
00:03:21.560 --> 00:03:23.480
many button types out of the box

75
00:03:23.480 --> 00:03:25.520
with likely good standard behavior

76
00:03:25.520 --> 00:03:27.680
and that works in many places.

77
00:03:27.680 --> 00:03:29.360
But what if you would want to create

78
00:03:29.360 --> 00:03:31.160
your own completely new mapping,

79
00:03:31.160 --> 00:03:32.880
possibly to your own data?

80
00:03:32.880 --> 00:03:38.120
It is here that Hyperbole's support for creating

81
00:03:38.120 --> 00:03:41.280
new implicit button types comes in.

82
00:03:41.280 --> 00:03:43.360
For the full pattern matching button type,

83
00:03:43.360 --> 00:03:46.720
like for the filename and examples we just looked at,

84
00:03:46.720 --> 00:03:48.754
you need to define the implicit button

00:03:48.755 --> 00:03:50.920
using the macro, `defib`.

85
00:03:50.920 --> 00:03:53.280
The downside of that is

86
00:03:53.280 --> 00:03:54.920
you need to code at the elisp level.

87
00:03:54.920 --> 00:03:57.240
However, if you are creating a new pattern

88
00:03:57.240 --> 00:03:59.120
that has well-defined delimiters,

89
00:03:59.120 --> 00:04:01.360
there is support for that in an easier way.

90
00:04:01.360 --> 00:04:03.800
These support functions, or rather macros,

91
00:04:03.800 --> 00:04:06.240
are `defil` and `defal`.

92
00:04:06.240 --> 00:04:08.440
We will look at those macros soon,

93
00:04:08.440 --> 00:04:13.400
but first, my definition of personal data.

94
00:04:13.400 --> 00:04:18.200
I think of personal data as something

95
00:04:18.200 --> 00:04:19.680
that you would like to link to,

96
00:04:19.680 --> 00:04:21.440
but it's not necessarily in a form

97
00:04:21.440 --> 00:04:23.360
supported by any known tool.

98
00:04:23.360 --> 00:04:26.920
It might be stored on a web server, local storage,

99
00:04:26.920 --> 00:04:28.680
or could even be some computation

100
00:04:28.680 --> 00:04:29.400
rather than a link.

101
00:04:29.400 --> 00:04:32.200
What all these cases have in common is that

102
00:04:32.200 --> 00:04:34.240
you want to be able to reference it

103
00:04:34.240 --> 00:04:36.640
in a short, and for you, descriptive way.

104
00:04:36.640 --> 00:04:38.960
So when you write text, you can use

105
00:04:38.960 --> 00:04:44.480
a new implicit type to create the connection.

106
00:04:44.480 --> 00:04:46.600
This might be a bit abstract,

107
00:04:46.600 --> 00:04:48.080
so let's look at an example.

108
00:04:48.080 --> 00:04:51.000
Suppose you have a flat file structure

109
00:04:51.000 --> 00:04:52.760
with some notes in each file.

110
00:04:52.760 --> 00:04:54.520
It can look like this.

111
00:04:54.520 --> 00:04:57.400
In the data folder, we have two files

112
00:04:57.400 --> 00:05:00.200
that represents the notes we have taken.

113
00:05:00.200 --> 00:05:02.840
We now want to be able to link to these notes

114
00:05:02.840 --> 00:05:07.120
from outside of the data folder.

115
00:05:07.120 --> 00:05:08.960
Let's make an implicit button type

116
00:05:08.960 --> 00:05:10.920
that opens a file in this structure.

117
00:05:10.920 --> 00:05:13.520
To make the pattern stand out in text,

118
00:05:13.520 --> 00:05:16.640
we use double braces as start and stop delimiters.

119
00:05:16.640 --> 00:05:20.080
An implicit button instance

120
00:05:20.080 --> 00:05:22.760
would then look like this.

121
00:05:22.760 --> 00:05:27.680
We can create that using the `defil` macro like this.

122
00:05:27.680 --> 00:05:31.840
This invocation of the field

123
00:05:31.840 --> 00:05:34.480
creates a button type "demo-link-to-file"

124
00:05:34.480 --> 00:05:37.280
with the start delimiter of "{{"

125
00:05:37.280 --> 00:05:40.560
and then delimiters of "}}",

126
00:05:40.560 --> 00:05:43.320
the regular expression ".*" pattern

127
00:05:43.320 --> 00:05:45.640
to match everything between the delimiters,

128
00:05:45.640 --> 00:05:48.800
and finally, the action defined by the link expression.

129
00:05:48.800 --> 00:05:52.160
Pattern substitution is performed

130
00:05:52.160 --> 00:05:54.440
on the link expression before evaluation

131
00:05:54.440 --> 00:05:57.920
so that the text that is in between the delimiters

132
00:05:57.920 --> 00:06:02.360
is inserted where the "\\&" is in the link expression.

134
00:06:02.360 --> 00:06:07.560
So all in all, implicit type instance will result in

135
00:06:07.560 --> 00:06:11.760
the link expression of "~/data/FileA",

136
00:06:11.760 --> 00:06:14.520
which we recognize as a file path.

137
00:06:14.520 --> 00:06:18.040
With a single-line expression,

138
00:06:18.040 --> 00:06:21.040
we have created our own hyperbutton syntax

139
00:06:21.040 --> 00:06:23.080
that we can use in any Emacs buffer

140
00:06:23.080 --> 00:06:25.560
to link to this custom set of data.

141
00:06:25.560 --> 00:06:30.960
So let's evaluate the defil and use it.

142
00:06:30.960 --> 00:06:33.760
I have prepared the files so that they already

143
00:06:33.760 --> 00:06:36.400
contain some text and implicit links.

144
00:06:36.400 --> 00:06:43.760
So from the presentation, we can go to FileA,

145
00:06:43.760 --> 00:06:48.720
and from there to fileB.

146
00:06:48.720 --> 00:06:51.040
Since the Hyperbole path expression

147
00:06:51.040 --> 00:06:53.640
supports outline structures, we can,

148
00:06:53.640 --> 00:06:55.960
as an extra bonus, reference directly

149
00:06:55.960 --> 00:06:57.560
the headers in the files,

150
00:06:57.560 --> 00:07:00.160
so we can, for example, link directly

151
00:07:00.160 --> 00:07:02.600
to "More Notes" in FileB.

152
00:07:02.600 --> 00:07:10.720
We have now created a simple info system.

154
00:07:10.720 --> 00:07:16.440
Looking deeper at the link expression,

155
00:07:16.440 --> 00:07:19.840
it can be of four different types:

156
00:07:19.840 --> 00:07:22.040
A file path expression,

157
00:07:22.040 --> 00:07:23.520
as we have already looked at;

158
00:07:23.520 --> 00:07:25.960
a brace-delimited key series,

159
00:07:25.960 --> 00:07:27.960
that is, a series of command keys

160
00:07:27.960 --> 00:07:29.480
for performing some action,

161
00:07:29.480 --> 00:07:30.960
much like a keyboard macro;

162
00:07:30.960 --> 00:07:36.240
An URL; or a function that takes one argument,

163
00:07:36.240 --> 00:07:38.640
which will be given the button text as input.

164
00:07:38.640 --> 00:07:42.880
The URL link expression allows you

165
00:07:42.880 --> 00:07:44.480
to link to web pages.

166
00:07:44.480 --> 00:07:46.560
So if the data you want to link to

167
00:07:46.560 --> 00:07:48.640
is accessible through the Web

168
00:07:48.640 --> 00:07:50.880
and the URL can be constructed

169
00:07:50.880 --> 00:07:53.000
from the button text in a meaningful way,

170
00:07:53.000 --> 00:07:54.520
it is possible to do that.

171
00:07:54.520 --> 00:07:56.160
Let's create the button type

172
00:07:56.160 --> 00:07:57.720
that links to GNU software.

173
00:07:57.720 --> 00:08:01.088
The URL to the GNU software catalog

00:08:01.089 --> 00:08:04.680
is www.gnu.org/software,

174
00:08:04.680 --> 00:08:07.440
and with what we know about the field,

175
00:08:07.440 --> 00:08:09.640
it is easy to create the button type for that.

176
00:08:09.640 --> 00:08:11.000
It can look like this.

177
00:08:11.000 --> 00:08:16.200
And here are two possible buttons

178
00:08:16.200 --> 00:08:19.320
linking to Emacs and Hyperbole.

179
00:08:19.320 --> 00:08:24.200
So let's again evaluate the defil and use it.

180
00:08:24.200 --> 00:08:28.120
Please note that not all GNU software

181
00:08:28.120 --> 00:08:29.000
is under that URL,

182
00:08:29.000 --> 00:08:31.000
so this simple definition will not work

183
00:08:31.000 --> 00:08:32.200
to link to everything.

184
00:08:32.200 --> 00:08:37.280
To highlight the fact that the button action

185
00:08:37.280 --> 00:08:39.080
does not have to be a link,

186
00:08:39.080 --> 00:08:40.600
but can be any action,

187
00:08:40.600 --> 00:08:42.200
let's look at a math example.

188
00:08:42.200 --> 00:08:44.800
Here is the button type that does some math

189
00:08:44.800 --> 00:08:47.480
and writes the result in the message area.

190
00:08:47.480 --> 00:08:57.160
Let's evaluate and use it.

191
00:08:57.160 --> 00:08:59.760
Before ending, I would like to mention

192
00:08:59.760 --> 00:09:00.760
the defal macro.

193
00:09:00.760 --> 00:09:02.920
It is similar to the defil macro,

194
00:09:02.920 --> 00:09:04.880
but simpler, since it uses a form

195
00:09:04.880 --> 00:09:07.880
of the implicit button type with no delimiters.

196
00:09:07.880 --> 00:09:14.800
It is simply <TYPE LINK-EXPR>.

197
00:09:14.800 --> 00:09:17.920
So the implicit button type contains the link type

198
00:09:17.920 --> 00:09:18.960
in clear text.

199
00:09:18.960 --> 00:09:23.120
Our recent FSF software button

200
00:09:23.120 --> 00:09:24.854
would be created like this.

00:09:24.855 --> 00:09:29.760
And it would be instantiated in text like this.

202
00:09:29.760 --> 00:09:34.960
I have shown how you,

203
00:09:34.960 --> 00:09:37.840
with the help of the defil macro in Hyperbole,

204
00:09:37.840 --> 00:09:40.240
quickly can create implicit buttons.

205
00:09:40.240 --> 00:09:41.480
With those buttons, you can link

206
00:09:41.480 --> 00:09:43.160
to your personal information

207
00:09:43.160 --> 00:09:44.160
in the form it may have.

208
00:09:44.160 --> 00:09:47.200
By the nature of the implicit buttons,

209
00:09:47.200 --> 00:09:49.880
those can be used from any file in Emacs.

210
00:09:49.880 --> 00:09:52.640
The button types can be

211
00:09:52.640 --> 00:09:54.640
created to be used long term,

212
00:09:54.640 --> 00:09:57.680
but even short term use within the session is possible,

213
00:09:57.680 --> 00:09:59.880
since the creation is simple and quick.

214
00:09:59.880 --> 00:10:03.400
Inspired by this, I hope you will find ways

215
00:10:03.400 --> 00:10:04.760
to create implicit buttons

216
00:10:04.760 --> 00:10:07.360
that will support you getting to your information.

217
00:10:07.360 --> 00:10:09.240
For the simplest cases,

218
00:10:09.240 --> 00:10:11.400
the field and the file macros might be enough.

219
00:10:11.400 --> 00:10:13.360
For more complicated cases,

220
00:10:13.360 --> 00:10:15.760
using a tailor-made function can be an option.

221
00:10:15.760 --> 00:10:19.480
If you know Elisp, use the defib macro

222
00:10:19.480 --> 00:10:22.240
which gives you full control over the button type.

223
00:10:22.240 --> 00:10:32.000
Thank you.