programming musings
09 Jul 2020

this is shakespeare

this-is-shakespeare.jpg

This Is Shakespeare: How to Read the World’s Greatest Playwright by Emma Smith

Emma Smith's tour through some of Shakespeare plays was a really interesting read. Her main thesis is that Shakespeare rarely provides answers, he just asks questions and plagues his plays with ambiguity: that's why every age finds works so modern, the key to their eternal relevance. We pick the interpretation that suits our times best, the genious being, of course, in writing something so malleable and covering so many facets of human experience.

One of the ways of being this wide is by a paucity of stage directions. For instance, in the final monologue of The taming of the shrew, there's no indication about the attitude and body language of Kate while she delivers her surrender, so one can imagine her kneeling and make it the misoginistic piece, or standing with a sneer, a stalwart of feminism (when i am feeling cynic, i suspect that Shakespeare was just being lazy, and the meaning was so obvious to everyone at the time, that no directions were needed).

Another funny example is discovering how A midsummer's night dream, our children and Christmas favourite, can very easily be read in a rather more lewd way.

I was also a bit surprised by how often Shakespeare reused and adapted plays and histories by other authors, most of them now forgotten. His genious here was of course writting them better and twisting their plots almost invariably to improve them; but it's funny to imagine what would have become of him in modern times, where the social media crowd would have immediatedly cried wolf, pointing their fingers to the plagiarist (and god knows what else) and asking to #CancelShakespeare.

Anyway, a very entertaining and highly recommended book!

Tags: books
07 Jul 2020

in no particular order (viii)

Interesting bits elsewhere:

Tags: sundry
02 Jul 2020

the mode lines i have not seen

i don't dislike emacs' mode line, i just wish (possibly out of a fetish for simplicity and minimalistic user interfaces) sometimes it wasn't there.

There are lots of packages out there "modding" the content and looks of the mode line, but in general it's not looks that bother me and i've seen a tendency among them of not being good at covering all the bases: when using any of these packages, i've always found myself having to write extra code to bring back some bit of information or another.

What i really wanted was the ability to hide the mode line for inactive buffers (and, every now and then, the active one too), and, ideally, to do that on a per frame basis (as frames double as my workspaces, and they're thematic, i want, for instance, mode lines in all my w3m inactive buffers, and usually no mode line for my active PDF document).

Sometimes, one's wishes just come effortlessly true:

(defun jao-toggle--face-height (face &optional all-frames)
  (let* ((h (face-attribute face :height (window-frame)))
         (nh (if (eq 'unspecified h) 1 'unspecified)))
    (set-face-attribute face (when (not all-frames) (window-frame)) :height nh)))

(defun jao-toggle-mode-line (&optional all-frames)
  (interactive)
  (jao-toggle--face-height 'mode-line all-frames))

(defun jao-toggle-inactive-mode-line (&optional all-frames)
  (interactive)
  (jao-toggle--face-height 'mode-line-inactive all-frames))

(defun jao-echo-mode-line ()
  (interactive)
  (message "%s" (format-mode-line mode-line-format)))

That's it: all the requirements above fullfilled in a dozen lines of elisp. As you see, the trick is very simple: one can set the height of the mode line's face to 1, making it display as a line, and faces are frame-local entities.

In my init file, i then call (jao-toggle-inactive-mode-line t), turn it back on some functions initialising my dedicated frames. jao-echo-mode-line comes in handy when i just want to see my active mode line's contents momentarily. i even found a good place in the thinkpad keyboard for shortcuts, with keys i literally never use for anything:

(global-set-key (kbd "<home>") #'jao-toggle-inactive-mode-line)
(global-set-key (kbd "<end>") #'jao-toggle-mode-line)
(global-set-key (kbd "<insert>") #'jao-echo-mode-line)
Tags: emacs
03 Jun 2020

in no particular order (vii)

Interesting bits elsewhere:

Tags: sundry
25 May 2020

in no particular order (vi)

Interesting bits elsewhere:

Tags: sundry
18 May 2020

in no particular order (v)

Interesting bits elsewhere:

Tags: sundry
13 May 2020

unlearn

For years, i've been using C-x p, C-x o and C-c <n> to move to other windows, but with ace window i am substituting all of them with M-o. Problem is, muscle memory interferes and i find myself clumsily moving around (and often lost) with the former ones. Or i did, before i followed an advice from Stefan Monnier in emacs-devel: unbind those keys you want to forget, and you'll get an error when you relapse.

In my case, that was just

(global-set-key (kbd "C-x o") nil)

together with commeting out the other one's definitions. For the record, in Stefan's case, he was trying to remember to use the newer C-h o (symbol help) instead of C-h f (function help) or C-h v (variable help), so he unbound the last two.

After a while, when one's muscles have forgotten, one can re-enable the old bindings, for the few cases where they're justified.

Tags: emacs programming
12 May 2020

ace window

As i've mentioned in a previous post, i organise my emacs sessions in workspaces, a.k.a. frames, a.k.a. a thematic tiling of windows. It is therefore important to have quick ways of jumping from a window to another. Until very recently, i used a home-cooked collection of shortcuts (C-c 1, C-c 2C-c n) that would move my point to the nth window in the workspace (i trained myself to count them quick enough, i suppose), and used that together with the stock C-x o and with C-x p bound to (other-window -1), for something similar to "previous window", to move around. But i've discovered a better way.

It's called ace-window, and it's so easy to use that i'll just give you my configuration below:

(use-package ace-window
  :ensure t
  :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
              aw-char-position 'left
              aw-ignore-current nil
              aw-leading-char-style 'char
              aw-scope 'frame)
  :bind (("M-o" . ace-window)
         ("M-O" . ace-swap-window)))

With exwm, i also bind s-o and s-O, so i can jump when focus is on an X buffer. My only complain is that the character overlay is not visible for X buffers, but i use so few of them that it's nothing to worry about.

Tags: emacs
08 May 2020

a gnus enters a side-bar

gnus-side-bar.png

i typically organize my computing sessions around workspaces, which in emacs are simply glorified default window configurations, sometimes in a one-to-one relationship with emacs frames1. That's specially natural if you use exwm, where there's a concept of workspace essentially equivalent to emacs frame. So here too i'll have a "coding" workspace with programming buffers, a "browsing" one inhabited by emacs-w3m buffers in a two-pane layout, an "X" for the few non-emacs applications i use, and one devoted to "email/calendar/agenda", where Gnus plays a central role.

Until recently, my "Gnus" workspace consisted only of Gnus-related windows (the group, summary, message triumvirate, basically) and i would open my org agenda, or visit the calendar in that workspace as needed. But the thing is, a 1920x1080 frame (or 272x70 columns one, with my current default font) is a lot of space for browsing email alone, and it'd be nice to have there a "side bar" of sorts always displaying (say, on a right column occupying a third of the horizontal space) my "inbox.org", agenda and calendar, while browsing emails and news with Gnus' three usual panes sharing the other two thirds on the left of the screen.

Enter Gnus window configurations, which can fulfill my desires with the following configuration:

(let ((side-bar '(vertical 1.0
                           ("inbox.org" 0.4)
                           ("*Org Agenda*" 1.0)
                           ("*Calendar*" 8))))
  (gnus-add-configuration
   `(article
     (horizontal 1.0
                 (vertical 63 (group 1.0))
                 (vertical 120
                           (summary 0.25 point)
                           (article 1.0))
                 ,side-bar)))

  (gnus-add-configuration
   `(group (horizontal 1.0 (group 183 point) ,side-bar)))

  (gnus-add-configuration
   `(message (horizontal 1.0 (message 183 point) ,side-bar)))

  (gnus-add-configuration
   `(reply-yank (horizontal 1.0 (message 183 point) ,side-bar)))

  (gnus-add-configuration
   `(summary
     (horizontal 1.0
                 (vertical 63 (group 1.0))
                 (vertical 120 (summary 1.0 point))
                 ,side-bar)))

  (gnus-add-configuration
   `(reply
     (horizontal 1.0
                 (message 90 point)
                 (article 100)
                 ,side-bar))))

You can see the "side bar" with the three buffers there, which one can change for whatever others are useful, and how we define layouts for the basic Gnus views: one for the group view, another for seeing the summary and messages (in a 3-pane configuration), and we also keep the side-bar visible when composing and replying to email.

All that i needed besides that in my gnus.org was a function to initialize the workspace calling calendar and org-agenda-list and visiting my inbox.org file and this hook:

  (defun jao-gnus--summary-done ()
    (save-window-excursion
      (org-agenda-list)))

(add-hook 'gnus-summary-prepared-hook #'jao-gnus--summary-done)

which updates my agenda view in the side-bar every time i enter an email or news group (which is often enough to keep it fresh). As a nice side-effect of this arrangement, i've managed to pay more attention to my Org agenda: i kept forgetting looking at it, but i never forget to check my email :)

Footnotes:

1

But not necessarily; all one needs is a way to store the current window configuration in a register and give it a name, and then creating a bunch of shortcuts to recover those configurations by name.

Tags: emacs
06 May 2020

in no particular order (iv)

Interesting bits elsewhere:

Tags: sundry
Other posts
Creative Commons License
jao.io by jao is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.