__________________
EMACS AND GOPHER
__________________
Table of Contents
_________________
1. Browsing
.. 1. Gopher browser in Emacs
.. 2. Using Lynx in a terminal buffer
2. Creating gopher optimized documents
.. 1. Org-mode
.. 2. Org-mode header
.. 3. Justify Text
.. 4. Big fat drawback
3. Gophermaps
1 Browsing
==========
1.1 Gopher browser in Emacs
~~~~~~~~~~~~~~~~~~~~~~~~~~
To browse the gopher space I use a gopher client for emacs called
elpher[1]. It's very stable and easy to use. It was a bit sluggish
in the past but now it works just fine. If you're using emacs there
is no way around elpher. I love how I can browse gopher holes within
my familiar environment and without context-switching[2]. Surely a
match made in heaven.
1.2 Using Lynx in a terminal buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another option is to run the lynx browser[3] in a terminal window
inside emacs. Emacs offers four(?) terminals: *shell*, *eshell*,
*term* and *ansi-term*. I prefer to use the last one (M-x
ansi-term). Now I can start lynx inside the terminal. If you want to
copy something from lynx to another buffer you have to activate
term-line-mode (C-c C-j). Now you can move the cursor around freely.
To switch back to term-char-mode press C-c C-k. This method is a bit
wonky but it works.
2 Creating gopher optimized documents
=====================================
2.1 Org-mode
~~~~~~~~~~~
I write all my articles in emacs org-mode[4]. If you don't know
org-mode already you seriosly should give it a try! It's basically a
way to structure documents in plain-text. Even if you don't use
emacs you can look at an org-file and read its content. A very
powerful feature of org-mode is the exporter. By default you can
export to text, html, LaTex and some other formats. When I create
documents for gopher I usually export to an ASCII file (C-c C-e t
a). You can also export to UTF8 which is prettier but some gopher
clients only support ASCII.
2.2 Org-mode header
~~~~~~~~~~~~~~~~~~
You can give org-mode some export options[5]. The head of the
org-document that was exported to this very file looks like this.
,----
| #+OPTIONS: author:nil toc:t
| #+LANGUAGE: en
| #+TITLE: Emacs and gopher
`----
2.3 Justify Text
~~~~~~~~~~~~~~~
In emacs there is a neat function to fill and justify paragraphs
(C-0 M-q). From the emacs documentation:
The command M-q (fill-paragraph) fills the current paragraph.
It redistributes the line breaks within the paragraph, and
deletes any excess space and tab characters occurring within
the paragraph, in such a way that the lines end up fitting
within a certain maximum width. [...] A numeric argument to
M-q tells it to justify the text as well as filling it. This
means that extra spaces are inserted to make the right margin
line up exactly at the fill column.[6]
The problem is after exporting I have to justify the paragraphs
again because the exporter ignores superfluous blanks. The following
script justifies only indented paragraphs that start with an
alphanumerical symbol. Therefore this does not apply to headings,
lists, code blocks, etc.
,----
| (defun gopher-justify ()
| (interactive)
| (beginning-of-buffer)
| (forward-line 4) ;; skip title
| (while (not (eobp))
| (progn
| (when (re-search-forward "^[[:blank:]]+[[:alnum:]]" nil t nil)
| (fill-paragraph 1 nil))
| (forward-paragraph 1))))
|
`----
It's not fool proof but most of the time it works. In some places I
have to insert an extra blank line in my org-file so that the next
text block doesn't get justified.
This was the final step. Now the document is ready for publishing.
2.4 Big fat drawback
~~~~~~~~~~~~~~~~~~~~
After a while I realised that this way of publishing gopher articles
is actually not that good. Here I create *two* documents where only
one should suffice. If I want to make changes to an article I first
have to change the org document and export it again. But what if the
org document is not at hand? Even worse, what if I change the
exported file directly on the server? I now have two versions of the
same article with slightly different content. Of course I could
store the org file on the server and abstain from making direct
changes. But this creates an extra barrier for something which
should be just so easy: simple plain text files.
I think I'll continue writing articles in org-mode but once the
first draft is finished I'll forget about the org-file and edit
upcoming changes by hand. I added this subsection manually and as
long as the changes to the structure of the document are minimal it
seems to work out just fine.
3 Gophermaps
============
A very useful emacs feature regarding gophermaps is whitespace-mode
(M-x whitespace-mode) which makes whitespace characters visible.
Footnotes
_________
[1] gopher://thelambdalab.xyz/1/projects/elpher/
[2] https://simpleprogrammer.com/context-switching/
[3] gopher://gopherpedia.com/0/Lynx%20(web%20browser)
[4] https://orgmode.org
[5] https://orgmode.org/manual/Export-Settings.html
[6] https://www.gnu.org/software/emacs/manual/html_node/emacs/Fill-Commands.html
Response:
text/plain