Emacs

The pages where I write about Emacs. It doesn’t happen very often. I think you’re probably best off following Planet Emacsen.

2018-08-30 Learning to Type

OK, so I want to practice typing using the Workman Keyboard Layout. But how to practice?

Atreus keyboard

Recently, codesections@fosstodon.org had a post about typing lessons for programmers using GNU Typist. I also found that my distro also offers Speedpad, a sort of game. And that reminded me of Typing of the Dead, which inspired The Typing of Emacs, a game I once wrote.

 T h e   T y p i n g   O f   E m a c s . . .
 
 LEVEL 1: 3 SECONDS PER WORD!  YOU HAVE 3 LIVES LEFT.
 elt - Wow!
 any - Hit!
 but - Go ahead!
 own - You can do it!
 nil - That's it!
 Done - done? - Desist! - 2 LIVES LEFT!
 such - You can do it!
 sort - Hit!
 made - Amazing!
 used - OK!
 which - yes!
 words - Hit!
 write - Excellent.
 parse - Wow!
 takes - Wow!
 format - Hit!
 Upcase - Updcase? - Nooooo! - 1 LIVES LEFT!
 random - YES!
 giving - gibuing? - Shame on you! - 0 LIVES LEFT!
 You have reached 180 characters per minute in 26 seconds by typing 18 words.

OK, but now I want to start working on the new Workman layout. Let’s see... I need a “ranking” so that I can start with some “easy” keys and make it progressively harder. Let’s take another look at the basic layer.

the basic layer

Here’s the plan:

  1. start with the home row: just words containing ashtgyneoi
  2. add some easy to reach keys, for example the three most easily reachable above the left and the right: adding drwfup
  3. add the three most easily reachable below the left and the right: adding xmcl (ignoring the comma and dot for the moment)
  4. all the letters

OK, so let’s prepare a file! Let’s use -i to ignore case. Use that Shift key!

grep -i '^[ashtgyneoi]*$' < /etc/dictionaries-common/words > workman-1.txt
grep -i '^[ashtgyneoidrwfup]*$' < /etc/dictionaries-common/words > workman-2.txt
grep -i '^[ashtgyneoidrwxmcfupl]*$' < /etc/dictionaries-common/words > workman-3.txt
grep -i '^[a-z]*$' < /etc/dictionaries-common/words > workman-4.txt

And since this is so new, I also need to change something in my setup:

(setq toe-starting-time-per-word 10)

The default is 3s per word and I basically can’t type anything in the time required.

That should give you a quick selection of difficulty levels. Feel free to introduce keys more gradually.

Here’s how to combine two words from the first file:

sort --random-sort workman-one.txt | paste -d ' ' workman-1.txt - > workman-1b.txt

The result:

A gaits
Aegean assigning
Aeneas ah
Ag Se
Agassi ignition
Agatha ginning
Aggie gayest
Agnes hoot
Agni geneses
Aisha ING
...

Yet another interesting take would be to use the 2000 most common words from the Brown corpus... And so on! :)

Well, back to the workman-1.txt file for me!

T h e   T y p i n g   O f   E m a c s . . .

LEVEL 1: 10 SECONDS PER WORD!  YOU HAVE 3 LIVES LEFT.
hie - Wow!
tie - OK!
shy - Amazing!
Noh - You can do it!
GTE - Done!
sags - Wonderful!
goes - OK!
oats - Amazing!
test - You can do it!
heat - Great!
goose - Go ahead!
hoots - That's it!
shoon - Amazing!
gains - Excellent.
tangs - You can do it!
ninths - Hit!
Athena - You can do it!
testis - Hit!
giants - Done!
sanity - Timeout! - Desist! - 2 LIVES LEFT!
hatting - Wonderful!
assigns - Hit!
entente - Timeout! - Nooooo! - 1 LIVES LEFT!
hyaenas - ? - No! - 0 LIVES LEFT!
You have reached 47 characters per minute in 140 seconds by typing 23 words.

Hall Of Fame

  1. Alex Schroeder    45 cpm    157 sec     24 words  2018-08-30 00:43
  2. Alex Schroeder    47 cpm    140 sec     23 words  2018-08-30 14:53
  3. Alex Schroeder    12 cpm     30 sec      2 words  2018-08-30 14:51
  4. Alex Schroeder    13 cpm     26 sec      2 words  2018-08-30 14:50
  5. Alex Schroeder    40 cpm      9 sec      2 words  2018-08-30 00:40

Tags:

Add Comment

2018-08-27 Mastodon and rcirc

If you use rcirc (one of the two Emacs IRC clients) and the Bitlbee Mastodon plugin to communicate with a Mastodon instance via Bitlbee, and you want to “dim” the notifications of follows, boosts and favourites:

(eval-after-load 'rcirc
  '(add-to-list 'rcirc-markup-text-functions 'asc:rcirc-dim-keywords))

(defvar asc:rcirc-dim-keywords
  '("favourited your status: "
    "boosted your status: "
    " followed you")
  "Keywords which result in the entire message being dimmed.")

(defun asc:rcirc-dim-keywords (_senders _response)
  "Dim message if it contains particular phrases.
Phrases to take are from `asc:rcirc-dim-keywords'.
Each function takes two arguments, SENDER, and RESPONSE.  The
buffer is narrowed with the text to be printed and the point is
at the beginning of the ‘rcirc-text’ propertized text."
  (dolist (str asc:rcirc-dim-keywords)
    (goto-char (point-min))
    (when (search-forward str nil t)
      (rcirc-add-face (point-min) (point-max) 'rcirc-dim-nick))))

(Mastodon is a free, open-source, decentralized microblogging network. Bitlbee is an IRC server connecting to various other text messaging services. You run Bitlbee and connect to it using an IRC client, then configure Bitlbee to connect to other services, such as a Mastodon instance where you already have an account. The benefit is that you can now use any IRC client you want to connect to Mastodon.)

Tags:

Add Comment

2018-08-02 Why Emacs?

I found this great section in the README to remacs, a “community-driven port of Emacs to Rust.” I had never heard of this effort before, probably because I’m so disconnected from everything.

The entire project uses the GPLv3 so that holds for this section, too. Users who have contributed to the README.md file: Wilfred shaleh jaccarmac birkenfeld mrwacky42 jeandudey db48× brotzeit vic setupminimal pnkfelix necto yqrashawn mjfeller andrewmcveigh Fuco1 spacecowboy dk87 c-nixon gitter-badger.

Anyway, on to the text:

Why Emacs?

Emacs will change how you think about programming.

Emacs is totally introspectable. You can always find out ‘what code runs when I press this button?’.

Emacs is an incremental programming environment. There’s no edit-compile-run cycle. There isn’t even an edit-run cycle. You can execute snippets of code and gradually turn them into a finished project. There’s no distinction between your editor and your interpreter.

Emacs is a mutable environment. You can set variables, tweak functions with advice, or redefine entire functions. Nothing is off-limits.

Emacs provides functionality without applications. Rather than separate applications, functionality is all integrated into your Emacs instance. Amazingly, this works. Ever wanted to use the same snippet tool for writing C++ classes as well as emails?

Emacs is full of incredible software concepts that haven’t hit the mainstream yet. For example:

  • Many platforms have a single item clipboard. Emacs has an infinite clipboard.
  • If you undo a change, and then continue editing, you can’t redo the original change. Emacs allows undoing to any historical state, even allowing tree-based exploration of history.
  • Emacs supports a reverse variable search: you can find variables with a given value.
  • You can perform structural editing of code, allowing you to make changes without breaking syntax. This works for lisps (paredit) and non-lisps (smartparens).
  • Many applications use a modal GUI: for example, you can’t do other edits during a find-and-replace operation. Emacs provides recursive editing that allow you to suspend what you’re currently doing, perform other edits, then continue the original task.

Emacs has a documentation culture. Emacs includes a usage manual, a lisp programming manual, pervasive docstrings and even an interactive tutorial.

Emacs has a broad ecosystem. If you want to edit code in a niche language, there’s probably an Emacs package for it.

Emacs doesn’t have a monopoly on good ideas, and there are other great tools out there. Nonetheless, we believe the Emacs learning curve pays off.

Also check out the post by Per Abrahamsen from 2000, what's so fun about emacs? but keep in mind that it was also posted to the newsgroup alt.religion.emacs.

Tags:

Add Comment

2018-02-27 Emacs Packages

My Emacs setup is on GitHub but I might have to finally get rid of my special package handling code and move to something else instead.

How about using straight together with use-package?

One of these days!

Tags:

Comments on 2018-02-27 Emacs Packages

I’m having the same questions. The functional approach of straight is very appealing. Would this approach be able to increase the security ? With security, I mean the fact that the melpa is vulnerable to attacks, much more than a debian/any-other-distro repo or github for example.

– JeanMichel 2018-02-28 12:07 UTC


[of course you keep my email adress for you ;-) ]

– JeanMichel 2018-02-28 12:08 UTC


To be honest, I have never thought much about the security of MELPA and friends. I suspect it is terrible, but then again, perhaps it is not if HTTPS is enabled and certificates are checked and all that, perhaps it is good enough? Debian doesn’t have HTTPS for its repos but has signature checking. We don’t have signatures but HTTPS? Fair? 🤷 I have no idea.

– Alex Schroeder 2018-02-28 13:54 UTC


Well, I started to worry about security in emacs after this discussion : https://www.reddit.com/r/emacs/comments/63e8hu/are_emacs_package_repositories_a_security_risk/?st=jejp9fmz&sh=a7ade519

Since then, there have been other discussions, which I have not followed accurately. I’m not a specialist, but for those who use emace for everything like notes, mail etc, the possibility of an infected package should be a concern, and i’d love if there would be an approach to solve this.

But ... that is not your point in this post ! ;-)

– JeanMichel 2018-03-09 08:55 UTC


https://glyph.twistedmatrix.com/2015/11/editor-malware.html

I found this a while ago, which says you have to do extra work to get Emacs to actually verify https.

– jpkotta 2018-03-09 17:03 UTC


Thank you both! Very interesting.

– Alex Schroeder 2018-03-11 21:17 UTC


straight.el uses hashes and a lockfile

https://github.com/raxod502/straight.el#lockfile-management

– straight user 2018-04-12 23:27 UTC

Add Comment

2018-02-12 Buttery Smooth Emacs

This is the best blog post about Emacs in a long time. I’m still laughing. Buttery Smooth Emacs, Friday, October 28, 2016.

«GNU Emacs is an old-school C program emulating a 1980s Symbolics Lisp Machine emulating an old-fashioned Motif-style Xt toolkit emulating a 1970s text terminal emulating a 1960s teletype.»

«Emacs organizes its view of the outside world into frames (what the rest of the world calls “windows”), windows (which the rest of the world calls “panes”), and buffers (which the rest of the world calls “documents”).»

«Did Emacs just adapt to whatever these non-Xt toolkits did? Did Emacs adopt modern best practices? GTK+ is a modern GUI library. Emacs supports GTK+. Is Emacs a well-behaved GTK+ program now?»

«What’s particularly hilarious is that SIGIO can happen in the middle of redisplay. The REPL loop (in the Emacs case, not Read Eval Print, but Read Eval WTF) can be recursive.»

No, really. This blog post just keeps on giving.

(I don’t get why people use Facebook as their blog but whatever, this blog post is great.)

Tags:

Comments on 2018-02-12 Buttery Smooth Emacs

It’s a great write-up, but this isn’t right: “...a 1980s Symbolics Lisp Machine emulating an old-fashioned Motif-style Xt toolkit....” Symbolics certainly didn’t get its window system ideas from Xt.

Arthur A. Gleckler 2018-02-13 01:25 UTC


I’d be surprised if everything else is right! :)

– Alex Schroeder 2018-02-13 07:08 UTC


More tales from redisplay.

AlokSingh 2018-02-14 06:39 UTC


The joy of CTRL S and CTRL Q! «It is also a great tragedy that you don’t get DSR/DTR lines on these “modern” serial ports, which means you have to use inline XON/XOFF flow control. Like an animal.»

Good stuff, thanks Alok!

– Alex Schroeder 2018-02-14 13:12 UTC

Add Comment

2018-01-03 Gopher Mode

Yeah, I’ve been working on Gopher stuff over the holidays.

  1. a Gopher server wrapper around Oddmuse wiki (and this site is running it, see gopher://alexschroeder.ch)
  2. a proposal of a new item type to write to a Gopher server with examples based on netcat, i.e. nc
  3. improvements to the Emacs Gopher client with support for HTML and the new item type (see this branch on GitHub)

Isn’t that amazing.

Tags:

Add Comment

2017-12-27 Fonts

What fonts should I use on my new laptop?

On the Apple PowerBook Pro I used Fira Code. I liked those ligatures for Javascript!

But now I’m thinking perhaps Noto is better? Specially since there are packages for it: sudo apt install fonts-noto fonts-noto-color-emoji and you’re good to go. Except that Emacs doesn’t show me any orange flames when I use 🔥. Sad!

Still, in my Emacs config now: (set-face-attribute 'default nil :family "Noto Mono" :height 140).

Firefox Purebrowser renders the flame in blue and uses a lineheight of an estimated 600%. This looks very ugly.

installing fonts-symbola gives me the black flames back. Not cool, but also not bad.

Tags:

Comments on 2017-12-27 Fonts

i really <3 fantasque sans mono https://github.com/belluzj/fantasque-sans

idk abt emojis. there are melpa packages aren’t there? i gave up after trying a few tho. plain text does the trick.

– Anonymous 2017-12-28 00:34 UTC


We’ll see. :)

– Alex 2017-12-28 19:51 UTC


Hi Alex, I find Noto Mono to have issues with reading the numeral zero “0” and uppercase alpha o “O”. Not sure how you feel about that. Thats why I prefer using Hack.

– Darryl Hebbes 2017-12-28 21:48 UTC


Good point. We’ll see about that. These things haven’t been an issue for me in many years. Perhaps they will resurface with a new font, haha.

– Alex 2017-12-29 13:39 UTC

Add Comment

2017-12-13 In Memory Diff

New: In Memory Diff

in-memory-diff takes two source buffers and treats their content as a set of unordered lines, as one would expect for a file like ~/.authinfo.gpg, for example. We don’t use diff(1) to diff the buffers and thus we don’t write temporary files to disk. The result is two buffers, *A* and *B*. Each contains the lines the other buffer does not contain. These files are in a major mode with the following interesting keys bindings:

  • c – copy the current line to the other source buffer
  • k - kill the current line from this source buffer
  • RET - visit the current line in this source buffer

In theory, using c and k on all the lines should result in the two source containing the same lines a subsequent call of in-memory-diff showing two empty buffers.

Alternatively, a way to use ediff with process substitution such that ediff reads from two pipes would have been nice. Does anybody know how to do this?

Tags:

Comments on 2017-12-13 In Memory Diff

I don’t think Emacs can do the equivalent of process substitution, because Lisp code cannot see the fd numbers of process objects produced by make-pipe-process.

Hacking around this using fifos seems possible: https://github.com/kensanata/in-memory-diff/compare/master...npostavs:diff-fifo

– npostavs 2017-12-14 14:22 UTC


Wow, this is super cool! I wondered whether I’d be able to get ediff to do just that and had given up. Thanks!

– Alex Schroeder 2017-12-14 19:03 UTC


Have a look at this item on stackexchange:

https://emacs.stackexchange.com/questions/27382/diff-of-two-buffers-without-creating-temporary-files

But do note that in-memory doesn’t necessarily prevent other processes from accessing the pipes as they are file system objects (at least that’s my understanding).

– Titus von der Malsburg 2017-12-19 11:15 UTC


That’s correct. I’m mostly worrying about temp files being left behind, or deleted temp files being resurrected. Assuming that the main attack vector I’m fearing is people stealing the disk where my encrypted file and decrypted temp files are on, I think pipes are good enough.

– Alex 2017-12-19 12:47 UTC

Add Comment

2017-12-06 Emacs on Windows

Getting M-x eww to work:

  1. get libxml2-2.7.8-w32-bin.zip from https://sourceforge.net/projects/ezwinports/files/
  2. put the dll files from the bin subdirectory into the Emacs bin subdirectory
  3. add the Emacs bin directory to your PATH environment variable

That’s what they say. But it doesn’t work.

The Emacs Wiki agrees.

Suspiciously, the names differ: libiconv-2.dll, libxml2-2.dll, and zlib1.dll.

Tags:

Comments on 2017-12-06 Emacs on Windows

I suggest building them all; that’s what I did for my Emacs on Windows – and it works; that is, eww works.

For differing names, the following may prove a solution:

;; explicitrly specify names of dlls for libjpeg and gnutls
(defun krv/sublist_append (listvar sym newel)
  "Append newel to the sublist of listvar that starts with sym"
  (let ((elem (find sym listvar :key 'car)))
    (if elem
        (setcdr (last elem)
                (list newel)))))

(krv/sublist_append dynamic-library-alist 'jpeg "libjpeg-62.dll")
(krv/sublist_append dynamic-library-alist 'gnutls "libgnutls-30.dll")

Use it to redefine names of the libraries to ones you have, as needed. I do not quite remember - but probably library names are somewhat hardcoded into Emacs, which is not quite right.

kurvivor 2017-12-20 15:38 UTC


Ah, I had forgotten all about dynamic-library-alist. I’ll have to check what it says right there.

– Alex 2017-12-20 16:23 UTC

Add Comment

2017-08-10 Rcirc Menu

I use Emacs as a glorified IRC client but with Bitlbee, the number of IRC channels I’m in has exploded. So many Discord channels. And some Mastodon channels. And my Twitter accounts. It’s crazy. The Emacs modeline is no longer enough to display IRC activity. I wrote a little Rcirc Menu mode to handle it for me.

This has also revived my interest in submitting packages to ELPA. I still have write access. In order to test the waters, I submitted Rcirc Menu and Rcirc Color to emacs-devel. We’ll see how it goes!

Tags:

Comments on 2017-08-10 Rcirc Menu

Both are now available from ELPA.

– Alex 2017-08-16 07:26 UTC

Add Comment

More...

Comments


Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.