Replace Elpher bookmarks with Emacs bookmarks
[elpher.git] / elpher.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @setfilename elpher.info
4 @settitle Elpher Manual v2.11.0
5
6 @dircategory Emacs
7 @direntry
8 * Elpher: (elpher). A gopher and gemini client for Emacs.
9 @end direntry
10
11 @copying
12 This manual documents Elpher, a gopher and gemini client for Emacs.
13
14 Copyright @copyright{} 2019, 2020 Tim Vaughan
15
16 @quotation
17 The source and documentation of Elpher is free software.  You can
18 redistribute it and/or modify it under the terms of the GNU General
19 Public License as published by the Free Software Foundation; either
20 version 3, or (at your option) any later version.
21
22 Elpher is distributed in the hope that it will be useful, but WITHOUT
23 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNElpher FOR A PARTICULAR PURPOSE. See the GNU General Public License in
25 the file COPYING in the same directory as this file for more details.
26 @end quotation
27 @end copying
28
29 @titlepage
30 @title Elpher Gopher and Gemini Client Manual
31 @author Tim Vaughan
32
33 @page
34 @vskip 0pt plus 1filll
35 @insertcopying
36 @end titlepage
37
38 @contents
39
40 @ifnottex
41 @node Top, Introduction, (dir), (dir)
42 @top Elpher
43
44 @insertcopying
45
46 @menu
47 * Introduction::                Elpher Overview: what's this all about?
48 * Installation::                Installing Elpher
49 * Quick Start::                 Get up and running quickly
50 * Navigation::                  Fundamentals of Elpher navigation
51 * Bookmarks::                   How to record and visit bookmarks
52 * Gopher character encodings::  How Elpher selects encodings for gopher pages
53 * Encrypted gopher connections::       How and when TLS is enabled for gopher
54 * Gemini support::              Support for the Gemini protocol
55 * Finger support::              Support for the Finger protocol
56 * Customization::               How to customize various aspects of Elpher
57 * Command Index::
58
59 @detailmenu
60  --- The Detailed Node Listing ---
61
62 Navigation
63
64 * Within-page navigation::      Moving about within a page
65 * Between-page navigation::     Commands for moving between pages
66 * History and Caching::         Explanation of how Elpher represents history
67
68 @end detailmenu
69 @end menu
70 @end ifnottex
71
72 @macro keycmd{key,cmd}
73 @item \key\  (@code{\cmd\})
74 @findex \cmd\
75 @end macro
76
77 @node Introduction, Installation, Top, Top
78 @chapter Introduction
79
80 Elpher aims to be a capable and practical gopher and gemini client for
81 Emacs.  Its focus is on easy keyboard-driven navigation based on
82 sensible default bindings (with out-of-the-box support for Evil).  It is
83 intended to be robust and behave in non-surprising ways at all times.
84 Additionally, Elpher provides the following bells and whistles:
85
86 @itemize
87 @item
88 followable web and gopher links in plain text,
89
90 @item
91 an easily navigable history, sporting caching of visited pages (both
92 content and cursor position),
93
94 @item
95 auto-completing menu item navigation,
96
97 @item
98 direct visualization of image files where supported (no writing to
99 disk),
100
101 @item
102 basic support for the new ``heavier than gopher, lighter than the web'' Gemini protocol,
103
104 @item
105 support for the Finger protocol.
106
107 @end itemize
108
109 Elpher is still under active development.  Although we try very hard to
110 ensure that releases are bug-free, this cannot be guaranteed.  However,
111 this also means that any usability features that you feel are missing
112 can likely by incorporated quickly, so please get in touch if you
113 have some ideas.
114
115 @node Installation, Quick Start, Introduction, Top
116 @chapter Installation
117
118 Elpher is available from the MELPA package repository.  If you have
119 never installed packages from this repository before, you'll need
120 to follow the instructions at @url{https://melpa.org/#/getting-started}.
121
122 @noindent To install Elpher, enter the following:
123
124 @example
125 @kbd{M-x package-install @key{RET} elpher @key{RET}}
126 @end example
127
128 @noindent To uninstall, use
129
130 @example
131 @kbd{M-x package-delete @key{RET} elpher @key{RET}}.
132 @end example
133
134 While not recommended, it is also possible to install Elpher directly
135 by downloading the file @file{elpher.el} from
136 @url{https://alexschroeder.ch/cgit/elpher}, adding it to a directory
137 in your @code{load-path}, and then adding
138
139 @example
140 (require 'elpher)
141 @end example
142
143 @noindent to your Emacs initialization file.
144
145 @node Quick Start, Navigation, Installation, Top
146 @chapter Quick Start
147
148 Before diving into the minutiae of the different commands available,
149 we will quickly describe how to get up and running with Elpher.
150
151 Once installed, you can launch Elpher using
152
153 @example
154 @kbd{M-x elpher @key{RET}}
155 @end example
156
157 @noindent This will switch to the *Elpher* buffer and display a start
158 page, with information on each of the default keyboard bindings.
159
160 From here you can move point between links (which may be menu items or
161 inline URLs in text files) by using @key{TAB} and @kbd{S-@key{TAB}},
162 as in Info.  You can also jump directly to a menu item using @key{m}, or
163 use the standard Emacs or Evil motion and search commands to find your
164 way around.  To open a link, press @key{RET}.  (Where a mouse is
165 available, Clicking on a link with the mouse cursor has the same
166 effect.)
167
168 To return to the page you just followed the link from, press @key{u}.
169
170 Elpher caches (for the duration of an Emacs session) both page contents
171 and the position of point on each of the pages (gopher menus, gemini
172 pages, query results, or text pages) you visit, restoring these when you
173 next visit the same page.  Thus, pressing @key{u} displays the previous
174 page in exactly the same state as when you left, meaning that you can
175 quickly and visually explore the different documents in a menu without
176 having to wait for anything to reload.
177
178 Of course, sometimes you'll @emph{want} to reload the current page
179 rather than stick with the cached version.  To do this use @key{R}.
180 (This is particularly useful for search query results, where this
181 allows you to perform a different search.)
182
183 That's more-or-less it. Elpher supports a number of other features, such
184 as bookmarking, support for different coding schemes and TLS encryption,
185 and a variety of customization options, all of which are explained in
186 the rest of this document.  However the emphasis is on keeping the basic
187 navigation experience as intuitive and responsive as possible.
188
189 @node Navigation, Bookmarks, Quick Start, Top
190 @chapter Navigation
191 Throughout this manual, we use the word ``page'' to refer to any
192 visualization of a response from a gopher or gemini server, be it a
193 menu/directory, query result, text file or image.  We use
194
195 Elpher's navigation interface is inspired by the Emacs Info mode.
196 Movement within a page is essentially the same as moving
197 around any other text file in Emacs, but with special keys
198 for quickly jumping between menu items and URLs in text files.
199 Movement between pages is facilitated by a simple linear history
200 coupled with caching of pages and cursor position.
201
202 @menu
203 * Within-page navigation::      Moving about within a page
204 * Between-page navigation::     Commands for moving between pages
205 * History and Caching::         Explanation of how Elpher represents history
206 @end menu
207
208
209 @node Within-page navigation, Between-page navigation, Navigation, Navigation
210 @section Within-page navigation
211
212 To move about within a page, you should be able use the same keys you usually
213 use to browse files in Emacs.  This is even true when Evil mode is
214 enabled. Paragraph hopping, searching etc should work as usual.
215
216 In addition, the following commands are provided for quickly moving between
217 links and menu items.
218
219 @table @asis
220 @keycmd{@key{TAB}, elpher-next-link}
221 Move to the next link or menu item in the file.
222
223 @item @kbd{Shift-@key{TAB}} or @key{BACKTAB} (@code{elpher-prev-link})
224 @findex elpher-prev-link
225 Move to the previous link or menu item in the file.
226
227 @keycmd{@key{m}, elpher-jump}
228 Jump directly to a link within a file by specifying its display string
229 or link text.  (Unlike the previous two commands, this immediately opens
230 the selected link.
231 @end table
232
233 The following commands can be used to retrieve information about the
234 current page, or the address of the link at point:
235
236 @table @asis
237 @keycmd{@key{i}, elpher-info-link}
238 Display host, port and selector information for the link at point.
239
240 @keycmd{@key{I}, elpher-info-current}
241 Display host, port and selector information for the current page.
242
243 @keycmd{@key{c}, elpher-copy-link-url}
244 Add URL representing address of link at point to the kill-ring and the
245 system clipboard (if available).
246
247 @keycmd{@key{C}, elpher-copy-current-url}
248 Add URL representing address of the current page to the kill-ring and
249 the system clipboard (if available).
250
251 @keycmd{@key{d}, elpher-download}
252 Download link at point and save the result as a file.  The minibuffer
253 will prompt for the name of the file to write, with the default name being
254 the display string (if available) associated with the link.
255
256 @keycmd{@key{D}, elpher-download-current}
257 This is similar to @code{elpher-download}, but instead applies to the
258 current page rather than a link.
259
260 @keycmd{@key{.}, elpher-view-raw}
261 This displays the raw server response for the current page.  While not
262 useful for general browsing, it is useful for debugging incorrect rendering
263 or out-of-spec server responses.
264 @end table
265
266 @node Between-page navigation, History and Caching, Within-page navigation, Navigation
267 @section Between-page navigation
268
269 Moving to a different page can be accomplished in several ways,
270 described by the following command:
271
272 @table @asis
273 @keycmd{@key{RET}\, @kbd{mouse-1}, elpher-follow-link}
274 Follow the menu item or link at point (or selected with the mouse).
275
276 Exactly what is meant by ``follow'' depends on the kind of item selected:
277
278 @itemize
279 @item
280 For text or menu type items or links, the current page text is replaced
281 by the text of this item.  Unless the customization variable
282 @code{elpher-use-header} (@pxref{Customization}) is 
283 @code{nil}, the display string of the link is displayed in the buffer header.
284 Links to images behave similarly on Emacs systems supporting the display of
285 bitmap graphics, however their content is not cached in memory by default.
286
287 @item
288 When followed, links to search/query items (type 7) prompt for input in
289 the minibuffer then display the results in the same way as for text and menu
290 items.
291
292 @item
293 Following links to binary files (and image files on unsupported systems)
294 causes Elpher to prompt for a filename in which to save the content.
295
296 @item
297 Following links of type `h' with a selector having the `URL:' prefix, or
298 unsuported URLs in text files, will result in Elpher using an external
299 programme to open the URL.  This will be either the default system browser
300 or, if the @code{elpher-open-urls-with-eww} customization variable is non-nil,
301 Emacs' own EWW browser. (See @pxref{Customization}.) 
302
303 @end itemize
304
305 Once a text, menu or query response page has been displayed, its contents are
306 cached for the duration of the Emacs session. 
307
308 @keycmd{@key{g}, elpher-go}
309 Open a particular page by specifying either its full URL or just entering
310 a gopher host name. (The protocol defaults to gopher, so gemini links must include the @code{gemini://} prefix.
311
312 If a unsupported protocol is used in the URL the result will be the same
313 as following a URL link of the same type from a link in a page.
314
315 @keycmd{@key{o}, elpher-go-current}
316 Prompts for a URL similar to @code{elpher-go}, but initialized to the URL
317 of the current page.  This allows you to easily try other selectors for the
318 same server.
319
320 Remember however, that the Gopher RFC 1436 provides @emph{no} guarantees about the
321 structure of selectors.
322
323 @keycmd{@key{O}, elpher-root-dir}
324 Open the root page (empty selector) on the current host.
325
326 @keycmd{@key{u}\, @kbd{mouse-3}, elpher-back}
327 Return to the previous page, where ``previous'' means the page where the
328 page which was displayed immediately before the current page.
329 @end table
330
331
332 @node History and Caching,  , Between-page navigation, Navigation
333 @section History and Caching 
334
335 The history and caching strategy in Elpher is extremely simple, but
336 may be confusing without a good mental model of how it works.  That
337 is what this section attempts to provide.
338
339 Essentially, @strong{every} time you navigate to a new page, either
340 by clicking or pressing @key{RET} on a link, using @key{g} to jump
341 to a new page by its address, or using @key{O} to open the root selector,
342 the following two things occur:
343
344 @enumerate
345 @item
346 the cursor position and content for the original page are recorded in an
347 in-memory cache, and
348
349 @item
350 the original page is set as the ``parent'' of the new page.
351 @end enumerate
352
353 The only way to return to pages in this history is by using @key{u},
354 which returns to the previous of the current page.  @footnote{The
355 addition of the new page to the history happens even if the new page is
356 one that has been seen before. This is mostly the desired behaviour.
357 However, opening an explicit ``back'' link provided by a gopher menu or
358 gemini page will also add a new entry to the history.  Unless you
359 haven't yet visited that menu, it's therefore better to use @key{u} to
360 go back in this case.}
361
362 One aspect that may seem peculiar is that Elpher lacks a corresponding ``next'' or
363 ``forward'' command.  However, since Elpher caches the position of point,
364 this will be automatically positioned on the link that was most recently followed
365 from a given page.  This means that, at least for links followed from menus
366 and text files, the inverse of @key{u} is actually just @key{RET}.
367
368
369 @node Bookmarks, Gopher character encodings, Navigation, Top
370 @chapter Bookmarks
371
372 Elpher makes use of standard Emacs bookmarks. @xref{Bookmarks, , ,
373 emacs, The Emacs Editor}. The following commands are perhaps the most
374 useful ones:
375
376 @table @asis
377 @keycmd{@key{a}, elpher-set-bookmark-no-overwrite}
378 Add a bookmark for the link at point.  The minibuffer will prompt for
379 a name for the bookmark, which defaults to the display string.
380
381 @keycmd{@key{A}, bookmark-set-no-overwrite}
382 Add a bookmark for the current page.  The minibuffer will prompt for
383 a name for the bookmark, defaulting to the display string associated
384 with the link that was followed to reach the current page.
385
386 @keycmd{@key{B}, bookmark-bmenu-list}
387 Open a page displaying all current bookmarks. This is where you can
388 delete and search bookmarks, for example.
389
390 @end table
391
392 If all your bookmarks disappeared in an upgrade from 2.10 to 2.11, you
393 need to import the old Elpher bookmarks into your Emacs bookmarks
394 using
395
396 @example
397 @kbd{M-x elpher-bookmark-import @key{RET}}
398 @end example
399
400 Once this is done, you can delete the file with the Elpher bookmarks.
401
402 @node Gopher character encodings, Encrypted gopher connections, Bookmarks, Top
403 @chapter Gopher character encodings
404
405 Responses Elpher retrieves from servers are initially read as pure
406 binary data.  When the data is intended to be interpreted as textual (as
407 determined by the type parameter of the gopher menu item or the gopher
408 URL), this data needs to be @emph{decoded} into a sequence of
409 characters.  To do this properly requires knowledge of the encoding
410 system used by whoever authored the document.
411
412 Unfortunately gopher lacks a systematic way of acquiring this necessary
413 information. Thus, the details of the coding system must be either inferred from the binary data,
414 or must be specified by the user.
415
416 By default, Elpher applies Emacs' built-in character encoding detection
417 system to the full (undecoded) response data and uses this to attempt to
418 convert it into a character string.
419 (See @pxref{Recognize coding, Recognizing coding systems, ,emacs}.) While
420 this approach can be okay, it is important to realize that its inference
421 algorithm is extremely primitive and depends heavily on assumptions based
422 on the language settings of your emacs system.
423
424 The alternative is to explicitly set the coding system used for decoding
425 using the following command:
426
427 @table @asis
428 @keycmd{@key{S},elpher-set-coding-system}
429 Causes a elpher to prompt for a coding system to use for decoding
430 future gopher text.  The @key{TAB} key can be used at this prompt to display a
431 list of alternatives (which is extensive) and to auto-complete.  An empty
432 response will cause Elpher to return to its default auto-detection
433 behaviour.
434 @end table
435
436 Note that changing the coding system only affects newly loaded text.
437 Thus, if text has already been decoded using an incorrect system, you
438 will need to select the correct coding and then reload the text using
439 @key{R}.
440
441
442 @node Encrypted gopher connections, Gemini support, Gopher character encodings, Top
443 @chapter Encrypted gopher connections
444
445 While RFC 1436 does not broach the topic of encryption at all, several
446 modern gopher servers can serve content over encrypted connections,
447 and a common choice for this is TLS.
448
449 Elpher can retrieve selectors using Emacs' built-in TLS support which
450 uses the GnuTLS library. (It is possible to build emacs without
451 GnuTLS, in which case encryption is not supported.)
452
453 To retrieve documents using TLS, Elpher's TLS mode must be enabled.
454 This can be directly toggled using @key{T}, but note that just as with
455 the character encoding, changing this mode only affects subsequent
456 connections.
457
458 Alternatively, TLS mode is @emph{automatically} enabled whenever
459 gopher URLs starting with @code{gophers://} are followed.
460
461 The mode is sticky, so it remains active until switched off.
462 It can also be automatically switched off when a TLS connection fails.
463 In this case Elpher will prompt for your confirmation to ensure that
464 you can't accidentally make a non-TLS connection.
465
466 @node Gemini support, Finger support, Encrypted gopher connections, Top
467 @chapter Gemini support
468
469 @uref{gopher://gemini.circumlunar.space, Gemini}
470 is a new protocol being developed by several members of
471 gopherspace.  It aims to solve some of the long-standing technical
472 issues associated with gopher as a protocol, while keeping the major benefits.
473 For instance, it _requires_ encrypted connections, it does away with
474 the selector type, and allows servers to explicitly specify the
475 character coding scheme used for text documents.
476
477 The latest versions of Elpher aim to provide seamless transitions between
478 gemini and gopher documents.  Basically you should be able to open,
479 bookmark, download and otherwise interact with gemini pages in exactly
480 the same way as you do with other non-gemini pages.  The only major
481 difference from your perspective as a user is that you should no longer
482 have to worry about manually toggling TLS on or off (for gemini it's
483 always on), and you should never have to manually set a character coding
484 scheme.
485
486 The gemini protocol specification recommends a Trust on First Use (TOFU)
487 behaviour when validating gemini server TLS certificates.  This is
488 because many gemini servers rely on self-signed certificates rather
489 than certificates signed by a CA. Sadly however, this TOFU behaviour is
490 far from straight-forward to configure using Emacs' existing Network
491 Security Manager.  For this reason, elpher defaults to performing no
492 certificate verification by default.  This behaviour can be easily
493 customized by setting the @code{elpher-gemini-TLS-cert-checks}
494 customization variable to non-nil.
495
496 The gemini specification concerns both the protocol and a simple text
497 document format (mimetype text/gemini) which is like a mixture between
498 gophermap files and markdown-formatted files but simpler than both.
499 Elpher renders gemini responses which are provided in this format in
500 line with the rules in the spec.  This includes wrapping long lines at
501 word boundaries.  The specific column at which this text is wrapped is
502 defined by the customization variable
503 @code{elpher-gemini-max-fill-width}, which is set to 80 columns by
504 default. (This is slightly wider than Emacs' default fill width of 70
505 columns due to the fact that there are a significant amount of older
506 gemini content which, against the advice of the current spec, hard wraps
507 at <80 columns.  The larger default allows this to still look okay,
508 while still keeping content without hard wraps looking pleasant.)
509
510 The text/gemini format also possesses a section header syntax similar to
511 markdown.  Elpher allows different header levels to be drawn with
512 different, customizable, faces.  By default, on graphically-capable
513 emacs systems, these faces are given different heights to distinguish
514 among levels.  On terminal systems, the level is indicated by the
515 number of preceding # symbols.
516
517 I should emphasize however that, while it is definitely functional,
518 Elpher's gemini support is still experimental, and various aspects will
519 change as the protocol develops further.
520
521 @section Client Certificates for Gemini
522
523 Gemini makes explicit use of the client certificate mechanism that TLS
524 provides for allowing clients to authenticate themselves with servers.
525 The Gemini specification suggests two distinct classes of client
526 certificates: short-lived certificates used to identify you for a single
527 session, and more permanent certificates used to identify you over a
528 longer time period.
529
530 When Elpher receives a request for a client certificate from a server,
531 it will present you with the option to create and use a single-use
532 ``throwaway'' certificate, or to use a ``persistent''
533 certificate (optionally creating it or installing pre-existing key and
534 certificate files).
535
536 Certificate creation in Elpher requires an installation of OpenSSL, and
537 ---in particular---that Elpher be able to run the @command{openssl} command-line
538 utility.  By default, Elpher assumes that the @command{openssl} is on the
539 system path, but the precise location can be set by customizing the
540 @code{elpher-openssl-command} variable.
541
542 Each generated certificate results in the creation of a .key file and
543 a .crt file.  In the case of a throwaway certificate, these files are
544 stored in the temporary directory indicated by the Emacs variable
545 @code{temporary-file-directory} and are deleted when ``forgotten''
546 (as described below).
547
548 In the case of persistent certificates, these files are stored in the
549 folder defined by the Elpher variable
550 @code{elpher-certificate-directory}, and are never deleted by Elpher.
551 (Of course you can delete them yourself whenever you like.)
552 The base name of the files (i.e. sans extension) is what Elpher uses
553 to identify the certificate.
554
555 Using throwaway certificates is as simple as pressing the @key{t} 
556 key at the prompt which appears following a certificate request from
557 a server.  There is nothing more to do.
558
559 Using a persistent certificate requires instead selecting @key{p} from the same
560 menu.  This will result in Elpher asking you for the name identifying
561 the certificate.  This entry autocompletes to the list of known certificate
562 names, so you can use @key{TAB} to display the list.
563
564 In the case that you choose a name that does not belong to the list of
565 known certificates, Elpher will offer to create one for you or to
566 ``install'' one from existing key and certificate files.
567 Pressing the @key{n} key will cause Elpher to begin the process of
568 creating a new persistent certificate, using some additional
569 details for which you will be prompted.
570 Alternatively, pressing the @key{i} key will cause Elpher to ask for the
571 locations of edisting key and certificate files to add to
572 @code{elpher-certificate-directory} under the chosen name.
573
574 Once a certificate is selected, it will be used for all subsequent TLS
575 transactions to the host for which the certificate was created.
576 It is immediately ``forgotten'' when a TLS connection to another host
577 is attempted, or the following command is issued:
578
579 @table @asis
580 @keycmd{@key{F},elpher-forget-certificate}
581 Causes Elpher to immediately forget any currently-loaded client certificate.
582 @end table
583
584 In either case, ``forgetting'' means that the details of the key and
585 certificate file pair are erased from memory.  Furthermore, in the case
586 of throw-away certificates, the corresponding files are deleted.
587
588
589 @node Finger support, Customization, Gemini support, Top
590 @chapter Finger support
591
592 Incidentally, Elpher has native support for querying finger servers.
593 Of course, one could argue that this functionality is more easily
594 provided by one's local telnet client.  However finger URLs do appear
595 on occasion in gopherspace, and it's nice to be able to open them
596 in place.
597
598 Elpher interprets @code{finger://} URLs as follows:
599
600 @itemize
601
602 @item
603 The host is determined by the host name portion of the URL.
604
605 @item
606 In the case that the @emph{file name} portion of the URL is non-empty (besides
607 the leading slash), this is interpreted as the user to finger.
608
609 @item
610 Otherwise, the @emph{user} portion of the URL is interpreted as the user to finger.
611
612 @item
613 If no user is provided, the root directory of the finger server is requested.
614
615 @end itemize
616
617 Thus @code{finger://user@@hostname} and @code{finger://hostname/user} are both equivalent.
618
619 (The precedence of the /user notation over the user@ notation reflects a
620 preference of the community.)
621
622 @node Customization, Command Index, Finger support, Top
623 @chapter Customization
624
625 Various parts of Elpher can be customized via the 
626 variables belonging to the elpher customization group, accessible
627 using
628
629 @example
630 @kbd{M-x customize-group elpher @key{RET}}
631 @end example
632
633 @noindent This group contains a number of faces that can be modified to change
634 the appearance of Elpher, including one face per menu item type.
635
636 The group also contains variables for customizing the behaviour of
637 Elpher.  This includes how to open arbitrary (non-gopher) URLs, whether
638 to display buffer headers, how to deal with ANSI escape sequences in
639 text, the timeout to impose on network connections, and whether to
640 prompt for confirmation when switching away from TLS.
641
642 See the customization group itself for details.
643
644 @node Command Index,  , Customization, Top
645 @unnumbered Command Index
646
647 @printindex fn
648
649 @bye