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 . 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.