James Dyer: Transitioning RAlt to Ctrl - Enhancing Emacs Keybindings

In the midst of adjusting my Emacs keybindings for a more ergonomic workflow, I’ve experimented with various configurations. For example, I duplicated the right Alt key (RAlt) to function as an additional Alt key allowing for versatile key presses across the keyboard based on command keybinding locations.

The RAlt key is certainly accessible with a little curl under of the right thumb and a modifier key activator I hadn’t even considered before.

For instance, I found combinations like M-n and M-p already comfortable with a left hand / right hand split, but with RAlt for activating Meta/Alt a right hand / left hand split became possible for certain commands, notably M-f and M-w which I often use. This theoretically already felt a more comfortable setup.

However, after a few months, I realized I couldn’t quite find a way to transition to the RAlt remapping; I simply wasn’t using it. Yet, the initial experiment hinted at the potential of shifting modifier load to the right hand, especially leveraging the strong thumb for ergonomic advantages.

Then it struck me: what if I map RAlt to Ctrl?, I immediately questioned why I hadn’t tried it earlier!

The transition so far has unveiled the following (note: I may have got carried away with the detail here, but in a way its fun to weigh up the pros and cons!):

Benefits

  • Splitting common prefixes like C-x and C-c between hands.
  • Enhanced comfort in isearch with split hand C-r and C-s.
  • Improved buffer window navigation, with RLR (Right Left Right) pattern for C-x o.
  • Simplified buffer window splits with C-x <num>. Although there are typically two consecutive left hand key activations, sticky keys allows just two individual key taps of x then <num>.
  • Streamlined actions like the common C-c C-c, with the option of holding RAlt allowing easy left-hand tapping of c, c
  • Reassigned C-o (never used) to the (other-window) so I can replace my ever fluctuating window keybinding navigation to something more simple using just one hand, plus I can hold down the Ralt and tap through the windows.
  • C-g was always a bit of stretch - especially before sticky keys, but now I have a RL combination.
  • Simplified Emacs exit with C-x C-c (although why would I ever need this?!) holding RAlt for x,c tap tap.
  • A locked sticky key Ctrl double tap now doesn’t activate a double whammy of left hand pinky lateral movement.
  • Saving can be easier, C-x C-s again is a right hand modifier hold with an x,s tap
  • Another common command (which in fact I had to rebind as it was too taxing on my left hand) is now much more comfortable, namely C-x C-e (eval-last-sexp) in the same way as saving mentioned above.
  • I am finding myself instinctively using C-j a lot more as naturally my right thumb is now very close to RAlt and my right index finger is always on j
  • Reverting buffers is much easier, It is bound to C-x x g (revert-buffer-quick)
  • I am finding myself starting to revert back to the vanilla Emacs keybindings rather than my adapted ones mainly I suspect that C-x and C-c is much easier now to access.

Negatives

  • I will have to adjust to the new position of the keybindings, and some like the undo with C-/ feed a bit strange due to the close proximity between Ralt and /
  • Keyboard configuration is required to map Ralt to Control.

I’ll evaluate this setup’s efficacy over the next few months and I may contemplate not just the possibility of minimizing Ctrl key usage on the left hand but potentially eliminating it altogether! My left hand pinky would then never have to attempt lateral movement again!

-1:-- Transitioning RAlt to Ctrl - Enhancing Emacs Keybindings (Post James Dyer)--L0--C0--April 20, 2024 09:12 AM

Magnus: Update to Hackage revisions in Nix

A few days after I published Hackage revisions in Nix I got a comment from Wolfgang W that the next release of Nix will have a callHackageDirect with support for specifying revisions.

The code in PR #284490 makes callHackageDirect accept a rev argument. Like this:

haskellPackages.callHackageDirect {
  pkg = "openapi3";
  ver = "3.2.3";
  sha256 = "sha256-0F16o3oqOB5ri6KBdPFEFHB4dv1z+Pw6E5f1rwkqwi8=";
  rev = {
    revision = "4";
    sha256 = "sha256-a5C58iYrL7eAEHCzinICiJpbNTGwiOFFAYik28et7fI=";
  };
} { }

That's a lot better than using overrideCabal!

-1:-- Update to Hackage revisions in Nix (Post)--L0--C0--April 20, 2024 09:04 AM

Charles Choi: Writing Better Elisp Docstrings

Emacs has a lot of tools to help you write better documentation strings (docstrings). And if a tool you want doesn’t exist, Emacs can let you make your own. As of late I’ve been writing a lot of Elisp docstrings, so this post covers what's still fresh in my mind. While Elisp-centric, much of this post can apply to other languages as well (I see you Python and Swift).

Previewing Docstrings

A common task in writing an Elisp docstring is to preview it in Emacs Help. When you are still composing the docstring, this process is cumbersome as the point (cursor) is still in the docstring section. To preview the docstring in Emacs Help, one must:

  1. Run eval-defun (C-M-x) to evaluate the function the point is in.
  2. Move the point to the name of the function.
  3. Run M-x describe-function which will default populate with the function name because of where the point is currently.
  4. Move the point back to previous position (optional).

Repeating all these steps gets old fast. A more ideal workflow is to have an Elisp function that automates the above steps. This function can then be assigned a keybinding for convenient access.

The function cc/describe-function-point-is-in below does just that. For separation of concerns, evaluating the function (eval-defun) is kept separate from the steps that show the docstring (steps 2-4).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(defun cc/describe-function-point-is-in ()
  "Describe enclosing Elisp function at point.
\nInvoke `describe-function' on the enclosing Elisp function the point is in.

Thanks to mwnaylor and PropagandaOfTheDude for helping write this
function."
  (interactive)
  (save-excursion
    (let ((interned (intern-soft (which-function))))
      (if interned
          (describe-function interned)))))

Amendment 2024-04-19: On Reddit, PropagandaOfTheDude remarked that which-function can get the name of the enclosing function, simplifying my prior implementation. I've amended cc/describe-function-point-is-in to use it.

I leave it to the reader to assign their preferred keybinding to cc/describe-function-point-is-in. For yours truly, I’ve bound it to <f6> in emacs-lisp-mode-map.

1
(define-key emacs-lisp-mode-map (kbd "<f6>") #'cc/describe-function-point-is-in)

Filling Paragraphs and Sentence Spacing

Writing descriptive docstrings typically entails writing paragraphs. The function fill-paragraph will ensure that the paragraph you write is formatted with respect to the column length (fill-column). For single-spaced sentences, fill-paragraph works swimmingly. More problematic is when the desire is to enforce double-spaced sentences. If the variable sentence-end-double-space is non-nil, fill-paragraph will not adjust single-spaced sentences to double-spaced ones. To enforce double-spaced sentences, a different command is needed: repunctuate-sentences. This command honors sentence-end-double-space, so if you want single-spaced sentences, it will do the right thing.

In a docstring the workflow for refilling a paragraph while ensuring double-spaced sentences is:

  1. Mark paragraph as region.
  2. Run M-x repunctuate-sentences.
  3. Run M-x fill-paragraph.

Note that the design of repunctuate-sentences presumes that the buffer is all prose text if no mark is active. As docstrings are in code, this necessitates the step (1) to mark a region/paragraph. It’s left as an exercise to a more sophisticated Elisp developer to write a function that combines the above steps that is robust enough to know when it is in a docstring.

Documentation Tips

In the GNU Elisp Reference there is a section on documentation tips. I highly recommend a deep reading of it. Among the guidance it provides is linking to different document types such as commands/functions, variables, Info docs, man pages, and URLs.

Writing Tools

Emacs is rich with tools for writing. Among them to consider:

Closing Thoughts

Count me as one who finds great value to a well-written docstring. It is an opportunity to communicate intent from the writer/developer to the reader/user, and frequently for the developer it goes hand-in-hand with writing better code. Emacs provides a robust set of tools to help you write good docstrings with the added capability to make your own if what you need is lacking.

References

-1:-- Writing Better Elisp Docstrings (Post Charles Choi)--L0--C0--April 19, 2024 03:20 AM

Tory Anderson: stop freezes: disable global undo-tree

global-undo-tree-mode Dramatic freezes on routine “undo” I was experiencing freezes of sometimes up to 30 seconds about 3/4 of the the time when I used my muscle memory to hit undo (C-/), which I do as part of my regular “kill-line undo” combo (C-k C-/). Something must have changed recently because I started to have show-stopping freezes of my emacs thread when I tried a routine “undo.” I finally managed to squeeze a toggle-debug-on-quit and, with a bit of patience, got a C-g in during the freeze.
-1:-- stop freezes: disable global undo-tree (Post)--L0--C0--April 19, 2024 12:00 AM

Irreal: Beautifying Org Mode

As you all know, I’m not much for editor bling even though I care immensely what my finished text looks like. Still, I did take to heart Charles Choi’s recommendation to use proportional fonts for prose. The idea is that it’s easier to read and edit prose when it’s in a proportional font. That aside, the only other “beautification” I make to my Org buffers is to use the previous default of a larger font and different color for the title. Org did away with that some time ago but I resurrected it with

(set-face-attribute 'org-document-title nil :foreground "midnight blue"
                      :weight 'bold :height 1.44))

If you adhere to a less austere style in your Emacs buffers, you should take a look at Diego Zamboni’s recent post on Beautifying Org Mode in Emacs. He’s got a lot of nice ideas for customizing the look of your org buffers without resorting to a wholesale theme change.

His changes mainly consist of changing the font faces and sizes for the various headline levels and for ensuring that code fragments were still rendered in a monospace font. He also sets visual-line-mode on to make things look better in proportional fonts. I do that too but to solve formatting problems when exporting to HTML.

He hides the emphasis markup, which I definitely don’t like but he also made a simple change to make list bullets appear as actual bullets (•) rather than the default -. He makes some other suggestions, as well, so it’s well worth taking a look at his post if you’re interested in gussying up your Org buffers.

-1:-- Beautifying Org Mode (Post jcs)--L0--C0--April 18, 2024 03:41 PM

Irreal: An Interview With Daniel Semyonov

Those of you who have been around for a while will remember Sacha Chua’s video interviews with various Emacs luminaries. Those were before the birth of her daughter and as any parent will tell you, young children can gobble up whatever discretionary time you have so it’s little wonder she hasn’t done any interviews lately.

Sadly, she hasn’t reinstituted her interviews but she does this have this offering from Emanuel Berg with an interview of Daniel Semyonov. It’s not a video and it’s a bit shorter than Sacha’s old interviews but it’s still interesting.

Semyonov is a young programmer from a remote area without a lot of resources yet he was able to bootstrap his knowledge and has contributed to several open source projects. Most recently he has worked on the Gnus backend for Atom feeds.

One of the things I liked most about the interview was Semyonov’s discussion of how Emacs and learning Elisp kickstarted his programming in general and his open source contributions in particular.

It’s a short interview and worth a couple minutes of your time. Perhaps others will share their interviews with Sacha, and she with us.

-1:-- An Interview With Daniel Semyonov (Post jcs)--L0--C0--April 17, 2024 03:00 PM

Do you mean `switch-to-minibuffer'? Alternativly, you can always select it using other-window.

-1:--  (Post)--L0--C0--April 17, 2024 08:52 AM

Anand Tamariya: Circle Packing Animation in GNU Emacs


 

Here's an implementation of circle packing algorithm by Wang et. el. in Elisp. Front chain is the set of circles on the periphery. These are shown as connected by red line in the animation.

(require 'graph-pack)
(defstruct point x y r)
 
;; Define a point
(setq p (make-point :x 17 :y 0 :r 16))
 
;; Define a list of points
(setq points (list p1 p2))
 
;; Image is an SVG image. This is used for drawing the animation (optional). The return value is the front chain. This can be further used to generate a circumscribing circle.
(graph-pack points image) 

;; Get circumscribing circle
(setq p (graph-enclose (graph-pack children)))

 

Bubble Graph

 

You can pass a hierarchical tree of points to generate a bubble graph. Only radii of leaf nodes are mandatory. title and fill parameters are used if provided.

;; For drawing additional point attributes are required. Hence this definition is different from above. Properties old-x and old-y are used internally.
(defstruct point x y r old-x old-y fill title)
 
;; Image is an SVG image.
(graph-pack-tree root image)
 

Background

I don't have access to the research paper. The link to paper in D3js documentation wasn't very helpful either. Hence the code didn't make much sense to me. It only struck me when I saw the following image.

Important: My implementation doesn't use scores at each step. On the surface, that doesn't seem to be a drawback though.

Code

  1. https://github.com/atamariya/tumblesocks/blob/dev/graph-pack.el
  2. https://github.com/atamariya/tumblesocks/blob/dev/graph-enclose.el
  3. https://github.com/atamariya/tumblesocks/blob/dev/graph-draw.el
 

References

  1. Visualization of large hierarchical data by circle packing (Research paper) 
  2. D3.js implementation
  3. Python implementation
  4. Useful circle packing application ideas  

 

https://t.ly/E9Ene

-1:-- Circle Packing Animation in GNU Emacs (Post Anand Tamariya (noreply@blogger.com))--L0--C0--April 17, 2024 04:01 AM

Irreal: Emacs Nerd Porn

For all you Emacs nerds out there here’s a bit of porn. It’s almost like those joke pictures you see of Emacs setups but this one appears to be real.

As much as I like the idea of this environment, I’m not sure that I’d want to use it. As some of the commenters noted, it’s going to make your neck sore but for me the question is why you need to see all that information? Sure, it’s useful to be able to see two or even three files at the same time when you’re working but I’m not sure why you need to see eight or nine at once. It seems like lurking distraction to me.

I get that you might want to have, say, an email buffer and maybe even a text message buffer open but I’m at a loss of what to do with nine visible buffers. Of course, it’s different strokes for different folks so whatever works for you is okay with me.

And I gotta admit it looks really cool and is sure to give you nerd creds from just about everybody.

-1:-- Emacs Nerd Porn (Post jcs)--L0--C0--April 16, 2024 04:12 PM

Protesilaos Stavrou: Emacs: fontaine version 2.0.0

Fontaine allows the user to define detailed font configurations and set them on demand. For example, one can have a regular-editing preset and another for presentation-mode (these are arbitrary, user-defined symbols): the former uses small fonts which are optimised for writing, while the latter applies typefaces that are pleasant to read at comfortable point sizes.


Control the fonts of more faces

This version brings a major expansion to the scope of the user option fontaine-presets. It can now control the font family and concomitant attributes of more Emacs faces. In particular, it covers the following additional faces:

  • mode-line-active and mode-line-inactive.
  • header-line.
  • line-number (from the display-line-numbers-mode or its global variant).
  • tab-bar (from the tab-bar-mode).
  • tab-line (from the tab-line-mode).

All the supported faces are stored as the value of the variable fontaine-faces. This is the complete list:

  • default
  • fixed-pitch
  • fixed-pitch-serif
  • variable-pitch
  • mode-line-active
  • mode-line-inactive
  • line-number
  • tab-bar
  • tab-line
  • bold
  • italic

Existing users do not need to update their configuration, as (i) the old values will still work and (ii) undefined values fall back to reliable known values.

This change empowers users to further configure their setup, such as:

  • Make the mode lines smaller than the main text.
  • Use a proportionately spaced font for the tabs, while retaining a monospaced font for editing.
  • Use a different font family for line numbers to differentiate them from the main body of text.

These are some possibilities. Then consider that different presets can change specify different configurations. For example, a coding preset can be all about small, monospaced fonts, while a reading preset may increase the font sizes and apply proportionately spaced fonts.

The doc string of fontaine-presets covers the technicalities, as does the official manual (shipped with the package or available on my website: https://protesilaos.com/emacs/fontaine).

Thanks to Ashlin Eldridge for suggesting the inclusion of mode line and line number faces. This was done in issue 4: https://github.com/protesilaos/fontaine/issues/4.

Use the fontaine-mode to persist presets

The new fontaine-mode provides a convenience toggle to do the following:

  1. Store the current Fontaine preset before closing Emacs.
  2. Store the latest preset after using the command fontaine-set-preset.
  3. Persist font configurations while changing themes.

The purpose of storing the latest preset is to restore it easily, such as when starting Emacs. In the manual, we mention this in the sample configuration:

;; Set the last preset or fall back to desired style from `fontaine-presets'
;; (the `regular' in this case).
(fontaine-set-preset (or (fontaine-restore-latest-preset) 'regular))

This takes effect while starting up Emacs. So if, say, the user had selected a reading preset with fontaine-set-preset and then closed Emacs while fontaine-mode was enabled, the reading preset will be restored on startup.

Thanks to Adam Porter (alphapapa) for suggesting this in issue 2: https://github.com/protesilaos/fontaine/issues/2.

We used to provide code in the sample configuration which was doing what fontaine-mode does, though this is easier to set up (plus it is a toggle).

Deprecated the command fontaine-set-face-font

This command was used to interactively set the attributes of a face. It was not consistent with the rest of Fontaine’s functionality, plus it was not faster than setting face attributes directly from Lisp (such as to test them, while experimenting in the *scratch* buffer).

The fontaine-set-preset-hook provides more options

The functions added to this hook are called after fontaine-set-preset. For example, users of my pulsar package can highlight the current line to not lose track of the cursor:

(add-hook 'fontaine-set-preset-hook #'pulsar-pulse-line)

I had thought about defining what Emacs terms “abnormal hooks”, which are hooks that pass arguments to their functions. This hook would pass the selected preset, but I ultimately opted for the normal hook that run their functions without arguments. If advanced users have a good reason for such a feature, they are welcome to discuss it with me.

Fontaine now works with Emacs 29+

Emacs 29 is the current stable version and has been out for almost a year now. I do not have the resources to test/support older versions, sorry!

Miscellaneous

  • Updated the manual in light of all the aforementioned.
  • Simplified large parts of the code base.
-1:-- Emacs: fontaine version 2.0.0 (Post)--L0--C0--April 16, 2024 12:00 AM

Marcin Borkowski: Improving recenter-top-bottom and reposition-window

If one can be a fan of an Emacs command, then I am a huge fan of recenter-top-bottom (C-l) and reposition-window (C-M-l). I use them all the time to see the context of what I’m editing at the moment. However, they are not always that useful. They are rather crude – recenter-top-bottom only has three “settings”, as the name suggests, and reposition-window has only two (it either puts the first line of a function, or the first line of a comment preceding the function at the top). As I mentioned a few weeks ago, I sometimes work with rather long functions – and sometimes I am in the second of two shorter ones, but I want to see the first one, too. Also, I don’t only edit code – I edit prose, too, where paragraph play the role of functions, and Org files, where there are even other structural elements – headlines, tables and source blocks in addition to paragraphs, for example. I decided to write a variation on the theme of reposition-window, which – instead of putting the first line of the function I’m in at the top, it tries to put the first line of a “section” I’m in at the top.
-1:-- Improving recenter-top-bottom and reposition-window (Post)--L0--C0--April 15, 2024 05:23 PM

Irreal: A Comparison Of Markdown Editors

Although I find it hard to believe, the Minions assure me that there are still people who prefer writing in Markdown rather than Org-mode. I don’t want to relitigate that issue here. If you’re interested in why no right thinking person would prefer Markdown to Org—even without Emacs—I refer you to Karl Voit’s detailed analysis of Org’s superiority. Objectively, it’s just a better markup language and that’s before we get to Babel.

Regardless, there are those who use Markup either because they have to or because they really do prefer it. That leads to the question of which editor is best for writing in Markdown. (That issue doesn’t come up with Org-mode, of course.) Needless to say, we Emacs partisans dismiss this as a silly question because we think all editing tasks are best done with Emacs. Less biased folks may demur.

Franco Pasut is one such person and he analyzes the four editors

  • Vim
  • Emacs
  • Sublime Text
  • VS Code

all of which have facilities for helping you edit Markdown. He looks at each editor both out-of-the-box and with Markdown specific add-ons.

I’ll let you read his post for the details but as a spoiler, I’ll tell you that Emacs is not his first choice even though he is an Emacs user.

-1:-- A Comparison Of Markdown Editors (Post jcs)--L0--C0--April 15, 2024 04:53 PM

Sacha Chua: 2024-04-15 Emacs news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, lobste.rs, kbin, programming.dev, lemmy, communick.news, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, and emacs-devel. Thanks to Andrés Ramírez for emacs-devel links. Do you have an Emacs-related link or announcement? Please e-mail me at sacha@sachachua.com. Thank you!

-1:-- 2024-04-15 Emacs news (Post Sacha Chua)--L0--C0--April 15, 2024 01:07 PM

Evan Moses: No I don't want 2, Emacs

This blog, and the vast majority of the code I write, is written in Emacs withevil (a vim emulation mode). I have a nasty habit of mashing :w2<ret> when I really was trying to save the current buffer with :w<ret>. :w2 writes the current buffer to a new file called 2, which I don’t believe I have ever done on purpose.

So, I added this little gem to my .emacs, and it’s saved me any number of times:

(defun my:evil-write (&rest args)  "I constantly hit :w2<ret> and save a file named 2.  Verify that I want to do that"  (if (equal "2" (nth 3 args))      (y-or-n-p "Did you really mean to save a file named 2?")    t))(advice-add #'evil-write :before-while #'my:evil-write)

The :before-while advice lets you run a function that gets the same arguments as the advised function. If it returnsa truthy value, the advised function is run as usual, but if it returns nil, the original function is never run.

Share and enjoy.

Update Apr 16, 2024

To be clear: I’m not criticizing Emacs or evil here. To the contrary, I’ve got a personal problem, and thanks to theinfinite flexibility of Emacs I was able to craft a personal solution in 6 lines. I wish the rest of my software were soflexible.

-1:-- No I don't want 2, Emacs (Post Evan Moses (webmaster@emoses.org))--L0--C0--April 15, 2024 12:00 AM

Irreal: Sparse Trees

Emacs Elements has a short video on sparse trees. The TL;DR is that sparse trees give you a method of filtering an Org file to show only the information that you’re interested in. The information can be random text, a tag, a property, deadlines, dates, or date ranges.

Unfortunately, the video doesn’t capture the full power of sparse trees. It makes it seem as if all it does is highlight the matches in the visible buffer but sparse trees are actually much more powerful. If you have a large file, it will hide any non-relevant data except for context. The rules for what constitutes “context” are slightly complex so you should take a look at the documentation for the full story.

My only complaint is that I can’t find a way to restore the original buffer after invoking a sparse tree filtering other than reloading or rebuilding the file. You can turn off the highlighting but I can’t figure out how to get the original buffer back. This is Emacs so I’m sure there’s a way but I haven’t found it1.

Another nice feature of sparse trees is that you can “stack them”. That is, after forming a sparse tree representation of the buffer you can refine that representation with further filtering.

The video is only 5 minutes, 12 seconds so it’s easy to find time for it. It will give you a good overview but you really need to check the documentation for the complete story.

UPDATE [2024-04-14 Sun 19:27]:

I just noticed that the fix for restoring the previous buffer state no longer works so we’re back to no solution to this problem.

Footnotes:

1

According to this Stack Overflow entry, there is no good way of doing this. One responder does give some code that appears to do the job.

-1:-- Sparse Trees (Post jcs)--L0--C0--April 14, 2024 04:08 PM

James Dyer: Waybar Toggling Sticky Key Keymaps

For my previous post I was talking about a software visual indicator to discern which key has been locked in a sticky key situation. For example there are typically two modes of stickiness, being latched and locked, by default I had set up the locked variant as I thought it would be more useful for Emacs and in fact I have found this to be the case. For example, double tapping the Control key allows nice easy single key navigation via ’n’ ‘p’ ‘f’ and ‘b’, possible page down with ‘v’ and to delete lines I can use ‘k’ .e.t.c.

I’m sure I will find more bonuses in Emacs with this key locking mechanism and of course I can always tweak my keybindings, for example maybe a page up could be a Ctrl-<key> so I can have even more power navigating with a single <key>.

But how does a locked key setup work in a different program? and especially the software I use for my digital art, namely Krita. I have a USB numpad peripheral in which I map each key to a Krita shortcut, for example common actions such as colour picking, brush resize, canvas flip, undo / redo e.t.c. I have found this to actually be a nice cheaper option than one of the more specialised digital art controllers and more flexible as I will always be able to use it on linux with keymapping software like kmonad or kanata.

It didn’t take long to find out that I was running into difficulties with Krita and the locked sticky setup. For example colour picking is quite a common activity in digital art and it just so happens that for Krita it is bound by default to the Ctrl key! In addition Shift resizes the brush too. I found that quite often I was tapping the Ctrl and or Shift consecutively which was locking the modifier key which would have some unwanted side effects and would start to get frustrating as I fumble around to unlock the relevant modifier thus disrupting my flow. I quickly came to the conclusion that a locked sticky was not viable for my use within Krita.

So how could I craft a solution to this problem?

In my previous post, I might have unintentionally already laid the groundwork as I have created both a latched and a locked sticky key variant in the xkb file format. Perhaps I could develop a toggling mechanism between the locked and latched states, switching to latched state when I use Krita.

Just like before, I think Waybar would be ideal to perform the toggle with a click (which could also be a stylus click from a pen) and to then display the current status.

Initially I created the following bash script to perform the toggling of the keymaps :

#!/bin/bash

# Define the paths to your keymap files
KEYMAP_SWAY=~/.config/keymap_sway.xkb
KEYMAP_LOCKED=~/.config/keymap_with_locked_modifiers.xkb
KEYMAP_STICKY=~/.config/keymap_with_sticky_modifiers.xkb
CURRENT_KEYMAP_PATH=~/.config/keymap_current

# Check if the current keymap is set, if not use the sway keymap
if [[ ! -f "$CURRENT_KEYMAP_PATH" ]]; then
   echo "$KEYMAP_SWAY" > "$CURRENT_KEYMAP_PATH"
fi

CURRENT_KEYMAP=$(cat "$CURRENT_KEYMAP_PATH")

# Swap the keymaps
if [[ "$CURRENT_KEYMAP" = "$KEYMAP_LOCKED" ]]; then
   cp -f "$KEYMAP_STICKY" "$KEYMAP_SWAY"
   echo "$KEYMAP_STICKY" > "$CURRENT_KEYMAP_PATH"
else
   cp -f "$KEYMAP_LOCKED" "$KEYMAP_SWAY"
   echo "$KEYMAP_LOCKED" > "$CURRENT_KEYMAP_PATH"
fi

# Reload Sway configuration
swaymsg reload

Note that at first I tried to use the xkbcomp command but by all accounts only works on X11 so with wayland and in particular Sway I had to find a workaround to reload a toggled keymap - which is where swaymsg reload comes in. The solution is a little hacky but will work and involves swapping around files on disk and then forcing a reload of the sway configuration file.

As always with toggling, the key is usually working out the current toggle state in order to know what to toggle to. I decided to use the old fashioned method of a file on disk containing the path to the current keymap!

In the sway configuration file I can now attach a keybinding to the new toggle script :

bindsym $mod+y exec keymap-toggle.sh

‘y’ for sticky seems appropriate methinks.

Now for updating waybar to reflect the status. In this case as in the modifier LEDs of my last post I will have to create some custom modules and link it to a content producing bash script.

A keymap_monitor.sh script is as follows:

#!/bin/bash

CURRENT_KEYMAP_PATH=~/.config/keymap_current

CURRENT_KEYMAP=$(cat "$CURRENT_KEYMAP_PATH" | grep "sticky")

if [[ $CURRENT_KEYMAP ]]; then
   echo "{\"text\": \"STICKY\", \"class\": \"active\"}"
else
   echo "{\"text\": \"LOCKED\", \"class\": \"inactive\"}"
fi

and the waybar module :

"custom/togglesticky": {
    "exec": "keymap-monitor.sh",
    "interval": 1,
    "return-type": "json",
    "on-click": "keymap-toggle.sh",
}

Note the return-type type is json and the echo statements in the keymap_monitor.sh script have formatted the return data in the json format meaning the waybar module can process the string effectively. Note also a css class is set up which will link to the associated waybar css style sheet and potentially offer a nice flexible look for each mode if desired.

“on-click”: “keymap-toggle.sh” will allow the toggle to be actioned and the monitor script will be called every second as per the interval setting to poll the current toggle state.

Well that should be about it!, when I now open up Krita I can just tap on the LOCKED indicator on waybar which will then display STICKY (I decided to go with STICKY rather than LATCHED) This now indicates that I have changed the keymap, at which point double tapping any modifier keys as part of my arting shenanigans will now not lock the associated modifier and cause annoyance down the line.

I might even eventually find some icons or my preferred method emojis to make things look more graphically pleasing, but with all these things I always initially look to get most of the way there and in a working state before I start polishing it.

-1:-- Waybar Toggling Sticky Key Keymaps (Post James Dyer)--L0--C0--April 14, 2024 10:55 AM

Anand Tamariya: SVG Animation in GNU Emacs

 


Synchronized Multimedia Integration Language (SMIL) is an SVG extension which allows one to create simple animation without Javascript. Here is a basic implementation for <animate> tag.

(require 'svg)
 
(svg-animation-run) 
 
;; Exiting the image-mode will cancel the animation. 
;; Following command will also cancel the animation.
(svg-animation-cancel)
 

Code

https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/svg.el
 

References

 

-1:-- SVG Animation in GNU Emacs (Post Anand Tamariya (noreply@blogger.com))--L0--C0--April 14, 2024 07:42 AM

Irreal: Left Hand Quick Commands

Emacs elements has another interesting video, this time on some commands that he’s rebound for quick invocation. Those commands are (roughly):

  • kill-buffer
  • set-mark-command (Push mark)
  • set-mark-command (Pop mark)
  • exchange-point-and-mark
  • jump-out-of-pair (A custom command)

He begins the video with some praise for the IBM Model M keyboard that he uses. I can relate. As I’ve written before, it’s the greatest keyboard every made. It’s layout is pretty standard so whatever “standard” keyboard you’re using probably has a very similar layout.

Emacs customization, of course, is all about making it as frictionless as possible for your workflow so it makes no sense to criticize someone else’s bindings but it’s interesting how different his choices are from mine.

He uses Ctrl+1, Meta+1, and Meta+2 for some of those commands. He says re realizes that theese are prefix keys but says he never uses them. I, on the other hand, use them all the time. If I want to delete 2 words, I do it with Meta+2 Meta+d. Similarly, if I want to delete 3 characters, it’s Ctrl+3 Ctrl+d. These are all burned into my muscle memory and I’d never give them up.

There’s more to his customization than just rebinding the keys. Most of the above commands also activate the mark and result in highlighting regions. That’s almost never what I want and neither does he. He has a bit of custom code to deactivate the mark so that doesn’t happen. Even if, like me, you don’t care for his rebindings, you may want to grab his code to eliminate the mark activation.

This is a short video and worth a few minutes of your time.

-1:-- Left Hand Quick Commands (Post jcs)--L0--C0--April 13, 2024 04:08 PM

I cut a new release of "setup", my configuration macro package: elpa.gnu.org/packages/setup.ht. You can find a changelog on elpa.gnu.org.

-1:--  (Post)--L0--C0--April 13, 2024 09:07 AM

Emacs APAC: Announcing Emacs Asia-Pacific (APAC) virtual meetup, Saturday, April 27, 2024

This month’s Emacs Asia-Pacific (APAC) virtual meetup is scheduled for Saturday, April 27, 2024 with BigBlueButton and #emacs on Libera Chat IRC. The timing will be 1400 to 1500 IST. The meetup might get extended by 30 minutes if there is any talk, this page will be updated accordingly. If you would like to give a demo or talk (maximum 20 minutes) on GNU Emacs or any variant, please contact bhavin192 on Libera Chat with your talk details:
-1:-- Announcing Emacs Asia-Pacific (APAC) virtual meetup, Saturday, April 27, 2024 (Post)--L0--C0--April 13, 2024 12:01 AM

Irreal: 🥩 Red Meat Friday: That’s Not Vim…

Just a quickie today but it’s really, really red meat. If you’re an Emacs partisan, it will give you a reason to chuckle all day. If you worship at the Church of Vim, you’ll be less amused.

As I’ve said before, I never enlisted in the Editor wars and I certainly never took them seriously but it’s indisputable that they can be the source of fun and humor. Sometimes, as with this item, Vim takes the hit. Other times Emacs does. In either case, the trick is to think of them as humor, not tablets from Mt. Sinai.

-1:-- 🥩 Red Meat Friday: That’s Not Vim… (Post jcs)--L0--C0--April 12, 2024 04:13 PM

Eric MacAdie: 2024-04 Austin Emacs Meeting

There was another meeting a week ago of EmacsATX, the Austin Emacs Meetup group. For this month we had no predetermined topics. As always, there were mentions of many modes, packages, technologies and websites, some of which I had never heard of before, and some of this may be of interest to you as well. ... Read more
-1:-- 2024-04 Austin Emacs Meeting (Post Eric MacAdie)--L0--C0--April 12, 2024 08:22 AM

Emacs TIL: The Night Before A Coding Interview

Ah, the night before a coding interview. It’s like the night before Christmas, if instead of presents, Santa was bringing a whiteboard full of algorithms and data structures for you to solve while someone watches over your shoulder. The anticipation is palpable, the anxiety is through the roof, and your brain decides it’s the perfect time to replay every piece of code you’ve ever written, questioning if any of it was ever good.

Let’s set the scene: The clock strikes midnight, and there you are, lying in bed, eyes wide open, staring at the ceiling. Your mind races faster than Usain Bolt, zipping from one programming concept to another. Binary trees, linked lists, recursion… Oh, my! You try counting sheep, but your brain automatically starts sorting them using QuickSort, which, let’s be honest, is not the most relaxing algorithm.

You think to yourself, “Maybe I should get up and study some more.” So, you roll out of bed, fire up your laptop, and the glow of the screen in the dark room feels like the opening scene of a hacker movie—except, instead of hacking into the mainframe, you’re watching “Crash Course in Data Structures” for the hundredth time.

As the night drags on, every tick of the clock feels like a taunt. “Tick, tock, your interview’s a mock,” it seems to say. You try every trick in the book to fall asleep. Warm milk? Check. Counting backwards from 100? Check. Listening to whale sounds? Check. But nothing works. Your brain is like a web browser with 50 tabs open, and you can’t find which one is playing that annoying music.

Finally, after what feels like an eternity, you see the first light of dawn creeping through the curtains. Birds are chirping as if to say, “Good morning! Ready to fail that interview?” Thanks, birds. Really helpful.

You arrive at the interview, running on fumes and caffeine, looking like a character from “The Walking Dead.” The interviewer asks, “How are you today?” And with a caffeine-induced grin, you respond, “Great! I spent the night embracing the complexity of computational problems instead of sleeping. So, I’m ready for anything!” The interviewer, slightly taken aback, proceeds with the questions.

But here’s the twist: Despite the sleepless night, the gallons of coffee, and the nervousness that feels like it’s going to make you implode, you start solving the problems. One by one, your sleep-deprived brain digs deep and finds the answers. It turns out, the night of panic was like a hardcore training session, and you’re now in the zone, unstoppable.

In the end, you walk out of the interview feeling like a gladiator who just won a battle in the arena. You might not remember your own name at this point, but darn it, you solved those problems. And then, as you step outside, you think to yourself, “Maybe next time, I’ll try sleeping. Just to see if it’s any easier.”

So, my friend, if you’re feeling bad about that sleepless night before your coding interview, just remember: you’re not alone. It’s like a rite of passage in the tech world. And who knows? It might just be your brain’s way of saying, “We got this.”

(Edited with ChatGPT)

-1:-- The Night Before A Coding Interview (Post Junji Zhi)--L0--C0--April 12, 2024 03:23 AM

Susam Pal: Emacs Info Expressions

On #emacs IRC or Matrix channels, we often share references to the built-in Emacs documentation as Elisp expressions that look like this:

(info "(emacs) Basic Undo")

Here is another example:

(info "(emacs) Word Search")

This is a common practice in the Emacs channels even though all of the Emacs manual is available on the world wide web too. For example, the section referred to in the above expression is available here: GNU Emacs Manual: Word Search. The reason for sharing Elisp expressions like this is likely partly tradition and partly convenience. Many Emacs users are logged into IRC networks via Emacs itself, so once the recipient sees an Elisp expression like the above one in their chat buffer, visiting the corresponding manual page is a simple matter of placing the cursor right after the closing parenthesis and typing C-x C-e.

But isn't it clumsy for the sender to type Elisp expressions like this merely to share a pointer to a section of a manual with others? Turns out, it is not. This is Emacs! So of course there are key-bindings to do this.

Copy Info Node Name

Say, while helping another Emacs user we type M-x info-apropos RET version control RET and land on the section "Branches" and realise that this is the section that the person we are trying to help should read. Now when we are on this section, we can simply type c and Emacs will copy the name of the current Info node to the kill ring. This name looks like this:

(emacs) Branches

Now we can go to the *scratch* buffer (or any buffer), copy the node name, and complete the info expression manually. For example, we could type the following key sequence on a fresh new line to create the Elisp expression and copy it to the kill ring:

" " C-b C-y C-a C-SPC C-e M-( info C-a C-k C-/

On vanilla Emacs, the above rather long key sequence first types two double-quotes next to each other (" "), then moves the cursor back to go within the double-quotes (C-b), then pastes the text (emacs) Branches from the kill ring (C-y), then selects the pasted text (C-a C-SPC C-e), then surrounds it within parentheses (M-(), then inserts the text info just after the opening parentheses, and finally copies the resulting expression to the kill ring (C-a C-k C-/). The expression copied to the kill ring looks like this:

(info "(emacs) Branches")

Can we avoid constructing the info expression manually and have Emacs do it for us? Turns out we can as we see in the next section.

Copy Info Expression

I recently learnt from Karthink and Mekeor Melire that we can ask Emacs to create the entire info expression automatically for us. All we need to do is use the zero prefix argument with the c key. So when we are on section "Branches", if we type C-0 c, the following expression is copied to the kill ring:

(info "(emacs) Branches")

I should have known this because indeed while we are in the Info documentation browser, if we type C-h k c to describe the key sequence c, we see the following documentation:

c runs the command Info-copy-current-node-name (found in
Info-mode-map), which is an interactive byte-compiled Lisp function in
‘info.el’.

It is bound to c, w, <menu-bar> <info> <Copy Node Name>.

(Info-copy-current-node-name &optional ARG)

Put the name of the current Info node into the kill ring.
The name of the Info file is prepended to the node name in parentheses.
With a zero prefix arg, put the name inside a function call to ‘info’.

  Probably introduced at or before Emacs version 22.1.

[back]

So indeed Emacs has a convenient key sequence to create the complete info expression for the current Info node. The person who receives this info expression can visit the corresponding section of the manual simply by evaluating it. For example, after copying the expression in Emacs, they could simply type C-y C-x C-e to paste the expression into a buffer and evaluate it immediately. Alternatively, they might want to type M-: C-y RET to bring the eval-expression minibuffer, paste the expression, and evaluate it.

Read on website | #emacs | #technology

-1:-- Emacs Info Expressions (Post)--L0--C0--April 12, 2024 12:00 AM

D.V.F.P.: Markdown with Vim, Emacs, Sublime Text 4 and Visual Studio Code

Abstract:

How are four generalist editors, i.e., designed to be used with a wide range of programming languages and text files, performing when writing documents in Markdown language? This is the subject of this article based on my personal experiences in using Vim, Emacs, Sublime Text 4 and Visual Studio Code both directly and with extensions dedicated to the above mentioned markup language.

1. Introduction.

Markdown is a simple markup language that is within anyone’s reach, compatible with HTML, and allows very elegant, well-formatted text to be written for both web and print publication.

This article, however, is not about the language itself, which, moreover, has been described extensively on the Web, but about how various command-line editors allow one to write in Markdown.

A feature of both markdown and programming languages is, in fact, the usability of any plain-text editor to write related code.

The article in based on my personal experience with Vim, Emacs, Sublime Text and Visual Studio Code, on three main points:

  1. Editor behavior without plugins or extensions installed.
  2. Behavior with Markdown language-specific plugins or extensions.
  3. Preview handling.

2. Vim and Markdown.

Vim can be a powerful writing tool for Markdown as well, as for any other language, provided the initial hurdle of the learning phase is passed.

2.1. Vim without plugins.

Without plugin the .md files are handled as simple text documents without any dedicated function.

In practice: the “added value” of Vim is Vim itself, with its own original modal writing.

The Vim user community has, however, developed some very useful extensions for writing in Markdown, including "vim-markdown and "UltiSnips.

2.2. Vim with the plugin vim-markdown.

The plugin vim-markdown is useful for many functions including: folding, concealing, moving between section names, TOC (Table Of Contents).

In the programmer’s page the features made available by the plugin are analytically described.

I report, in this article, only the part related to TOC:

:Toc: create a quickfix vertical window navigable table of contents with the headers.

Hit on a line to jump to the corresponding line of the markdown file.

:Toch: Same as :Toc but in an horizontal window.

:Toct: Same as :Toc but in a new tab.

:Tocv: Same as :Toc for symmetry with :Toch and :Tocv.

:InsertToc: Insert table of contents at the current line.

2.3. Vim with the plugin UltiSnips.

An excellent plugin for Vim is UltiSnips.

Collections of snippets dedicated to that plugin can be found at honza/vim-snippets.

On the subject I refer to my following two articles:

The first article is on handling snippets in Vim with the UnltiSnip while the second contains a custom snippet that I find very useful for creating hyperlinks when descriptive text is already present in documents.

2.4. Vim and Markdown preview.

Regarding preview handling I recall two others of mine:

3. Emacs and Markdown.

Emacs is another highly customizable and extensible editor with a very large base of additional programs.

3.1. Emacs without plugins.

Opening a “.md” file with Emacs without additional packages activates the “Fundamental” mode, that is, the basic mode of the editor.

In this mode there is no dedicated Markdown functionality and you can use the editor with its native features as if for any text document.

3.2. Emacs with markdown-mode.

To add specific functionality to documents written in Markdown, the markdown-mode package must be installed.

I reproduce the screenshot taken from the actual start page of the plugin:

markdown_mode

The installation string with the Melpa library is as follows: M-x package-install RET markdown-mode RET .

For Straight with use-package, which is my current configuration, the following configuration needs to be entered in .emacs:

(use-package markdown-mode
 :straight t
 :mode ("README\.md\" . gfm-mode)
 :init (setq markdown-command "markdown"))

A remark: on the net you can find the use-package configuration associated with the multimarkdown command. I preferred to modify that configuration and associate it with the markdown command for ease of installation.

The multimarkdown command, in fact, must be compiled from source, as indicated on the dedicated page on GitHub.

With the markdown-mode package, a menu indicating the main operations is also installed in the top bar:

Emacs Markdown-Mode Menu

The menu is very useful for having at your hand the main key combinations of the plugin.

By using this package, document structuring management is similar to Org-mode, with Tab key to expand or collapse single headings and Shift-Tab to expand or collapse all headings simultaneously.

Also the basic commands for moving between paragraphs are the same as in Org-mode:

  • C-c C-n to jump to the next header of any level.
  • C-c C-p to jump to the previous header of any level.
  • C-c C-f to jump to the next header of the same level.
  • C-c C-b to jump to the previous header of the same level.
  • C-c C-u to move up a level.

These combinations, like many others, are also given in the menu dedicated to Markdown.

You can also find che analytical description of the commands at package page.

3.3. Emacs and preview in Markdown.

Among the commands added by the plugin there is also, as can be seen in the previous image, the Preview & Export item to launch both the preview on browser (C-c C-c p) and the Live Export (C-c C-c l) on separate Emacs window.

Emacs uses its own configuration for the preview browser, independent of the “default” operating system browser.

In the following examples, the customization allows Opera to be launched instead of Firefox.

To change the configuration with Melpa package system, the following snippet in .emacs is used:

(setq browse-url-browser-function 'browse-url-generic
 browse-url-generic-program "opera")

With the use-package system with straight.el you can add a fragment to the configuration already given above.

The fragment dedicated to the browser starts from the line containing the :config command:

(use-package markdown-mode
 :mode ("README\\.md\\'" . gfm-mode)
 :init (setq markdown-command "markdown")
 :config
 (setq browse-url-browser-function 'browse-url-generic
 browse-url-generic-program "opera"))

4. Sublime Text 4 and Markdown.

One of the main new features introduced by Sublime Text compared to previous editors is the Command Palette.

Thanks to the Command Palette you only need to remember one key combination, typically ctrl + shift + p (Windows, Linux) or ⌘ + ⇧ + p (on Mac), for all commands.

This makes it much easier to memorize specific combinations, which can also be typed directly to avoid the intermediate step of the Command Palette itself.

4.1. Sublime Text 4 without plugins.

In basic mode, Sublime Text 4 has a very interesting behavior: even natively, the editor recognizes the language from the extension of the document name and inserts the label “Markdown” in the lower right corner, with activation the Ctrl-r key combination to jump between paragraphs.

4.2. Sublime Text 4 with the plugin “MarkdownEditing”.

A great plugin is Markdown Editing.

markdown_editing

After the plugin is installed, you can activate its functions via the Palette.

It is enough, therefore, to open the Command Palette with ctrl + shift + p (Windows, Linux) or ⌘ + ⇧ + p (on Mac) and press the required command, e.g. fold or link, and run the command that results next to the name MarkdownEditing.

sublime fold palette

Typing in the Command Palette the string MarkdownEditing: will give you the full list of commands available with the plugin.

4.3. Sublime Text 4 and preview in Markdown.

For previewing you can install the “Markdown Preview” plugin, activate the command list with ctrl + shift + p, run the command Markdown Preview: Preview in browser and select markdown.

sublime preview

5. Visual Studio Code and Markdown.

Finally: Visual Studio Code, hereafter VSCode for short.

It is the most recent editor of those mentioned in this article.

VSCode also has the Command Palette, already described for Sublime Text, which can be activated with the Ctrl + Shift + P command.

5.1. VSCode without plugins

Even without any additions, VSCode allows you to view the preview for documents written in Markdown.

The built-in preview must be activated by the combination Ctr+K V to open a side-by-side window or Ctrl+Shift V to open it a separate tab.

A very useful feature: the preview automatically follows the position of the cursor in the document and automatically responds to mouse scrolling.

Another built-in feature is the lateral Outline based on the paragraph header at the various levels. It is located in the Explorer window on the left side of the screen.

The Outline can also be generated with the Ctrl+Shift O command to quickly jump to any paragraph in the document.

In addition, VSCode has some snippets to quickly insert various language elements. The snippets are activated with the Ctrl+Space command.

Thus, VSCode has a very advanced native set of functions dedicated to the Markdown language.

5.2. VSCode with the pluginMarkdown All in One”.

Of course, there are various plugins that extend of VSCode for Markdown.

My favorite at this time is Markdown All In One which allows, among other features, to create an automatic Table Of Contents (TOC) anywhere in the document and to add paragraph numbering.

For TOC creation, simply start at the Command Palette and type “table” to get commands for both creating and updating the table of contents.

For automatic headers numbering you again start from the Command Palette by typing the word “numbers”, even partially, to get the command to create/update or remove the numbering.

It is also possible to generate an HTML document exported from the Markdown document, by typing the word “html” in the Command Palette.

6. In summary.

What program do I use to write in Markdown?

I try to use all of them.

However, I prefer Vim when I want to do some mental training and Visual Studio Code when I want to write “quietly” by automatically getting a preview view, table of contents and paragraph numbering.

Thank you for your attention.

-1:-- Markdown with Vim, Emacs, Sublime Text 4 and Visual Studio Code (Post)--L0--C0--April 12, 2024 12:00 AM

William Denton: Upgrading my Tor bridges

The Tor Project announced the release of version 0.4.8.11 of the Tor server, which meant it was time for me to upgrade the two relays I run, one of which I set up last week.

In brief

Here’s my Conforguration method:

  • I upgrade the version number to 0.4.8.11
  • I hit C-c C-v t to “tangle” a shell script
  • On a code block for copying scripts, I hit C-c C-c
  • I ssh to the remote machine
  • I run conforg/scripts/tor-install-system.sh
  • I run conforg/scripts/tor-run.sh

Aside from the time to compile the code, this takes under one minute.

The explanation

As I said in my earlier post, I use my own Conforguration tool to handle this sort of thing. It uses Org to edit and manage shell scripts that I can run locally or on remote servers. The list above is a great example of how Org can make things much easier if you’ve set things up just the way you want them, while remaining cryptic to non-Org users. Here’s an explanation of most of what’s going on.

In the Tor section of Conforguration, first I set a variable with the version number I want to install. Today I updated it.

#+NAME: TOR_VERSION
| 0.4.8.11 |

Under Install, I have this code block:

#+begin_src shell :tangle conforg/scripts/tor-install-system.sh :shebang "#!/bin/bash" :var TOR_VERSION=TOR_VERSION
cd /usr/local/src/tor/
curl --location --remote-name https://dist.torproject.org/tor-${TOR_VERSION}.tar.gz
tar --extract --verbose --gunzip --file tor-${TOR_VERSION}.tar.gz
cd tor-${TOR_VERSION}
./configure && make && sudo make install
echo "Now run ~/conforg/scripts/tor-run.sh"
#+end_src

(I say tar --extract --verbose --gunzip --file instead of tar xzvf because I like to use the most readable arguments in scripts. I do use short forms when I’m typing at the command line.)

The :tangle argument to the code block is covered under extracting source code in the manual. When I hit C-c C-v t (which runs org-babel-tangle) then that chunk of code is exported to the file named by the argument. It’s given a shebang and the TOR_VERSION variable is passed into it, resulting in this:

#!/bin/bash
  unset TOR_VERSION
  declare -a TOR_VERSION=( '0.4.8.11' )
  cd /usr/local/src/tor/
  curl --location --remote-name https://dist.torproject.org/tor-${TOR_VERSION}.tar.gz
  tar --extract --verbose --gunzip --file tor-${TOR_VERSION}.tar.gz
  cd tor-${TOR_VERSION}
  ./configure && make && sudo make install
  echo "Now run ~/conforg/scripts/tor-run.sh"

Now I need to get that script to one of the machines where I run a Tor relay. In my ssh configuration it’s aliased to the name tor, so I go down to this section of Conforguration and hit C-c C-c on the code block to execute:

Screenshot from Conforguration
Screenshot from Conforguration

In plain text:

:PROPERTIES:
:header-args: :var hostname="tor"
:END:

#+begin_src shell :results silent :noweb yes
<<install-conforg-remotely>>
#+end_src

The angle bracket thing is noweb syntax, which allows me to use this snippet of code that’s set up earlier in the file, with the hostname variable passed in:

#+NAME: install-conforg-remotely
#+begin_src shell
rsync --archive --compress --delete ~/src/conforguration/conforg/ ${hostname}:conforg/
ssh ${hostname} "conforg/dotfiles/link-dotfiles.sh"
#+end_src

That pushes the scripts and dot files to the other machine and freshens the symlinks for all the dot files. In other words, it refreshes everything on the remote machine—all by hitting C-c C-c.

Now ~/conforg/scripts/tor-install-system.sh is on the other machine. I could execute it remotely from inside Conforguration, but it takes a while to run, so I like to log in to the other machine and do it locally. I ssh over and run:

conforg/scripts/tor-install-system.sh

It downloads the source code and compiles it. When it’s done, it finishes up by installing files on the system, and then ends with:

make[1]: Leaving directory '/usr/local/src/tor/tor-0.4.8.11'
Now run ~/conforg/scripts/tor-run.sh

I run:

conforg/scripts/tor-run.sh

This detects that a Tor tmux session is running, kills it off while waiting for the Tor daemon to die nicely, then sets it up again. When it starts fresh, the new Tor server is running.

Another way

For my bridge running on another machine, I could do the upgrade the same way, but to match how I’d installed it I did it like this (after upgrading the version number and pushing the commit to the repository):

  • cd src/conforguration
  • git pull
  • install/install.sh
  • ~/conforg/scripts/tor-install-system.sh
  • ~/conforg/scripts/tor-run.sh

There are other ways to handle configuration management and upgrading servers, but I’ve built one I really like.

-1:-- Upgrading my Tor bridges (Post William Denton)--L0--C0--April 11, 2024 12:40 PM

Charles Choi: Exporting UTF-8 Smart Quotes from Org Mode

Count me as one who really likes using smart quotes when exporting from Org. To enable this requires that you set the variable org-export-with-smart-quotes to t. So far, so good yes? Not quite. Apparently by default when exporting to HTML or Markdown, Org will use the HTML character entity representation of a smart quote which I see as overly conservative in 2024. As most contemporary software now can handle UTF-8, it seems to me more sensible to use smart quote characters that are likewise UTF-8. For English these are:

  • left and right double quote
  • left and right single quote
  • apostrophe (right single quote)

Apparently Org has an alist variable that captures the different representations of the above for different languages and for different export targets. This variable is called org-export-smart-quotes-alist and sure enough it captures the UTF-8 set of characters for each language. Empowered with this knowledge, here’s some Elisp code to reconfigure org-export-smart-quotes-alist so that exporting to HTML or Markdown uses the UTF-8 representation for English (en).

(defun cc/reconfig-org-smart-quotes-lang (lang)
  "Reconfigure Org smart quotes to use utf-8 per LANG."
  (let* ((db-entry (assoc-string lang org-export-smart-quotes-alist))
         (utf8-primary-opening (plist-get (assoc-default 'primary-opening db-entry) :utf-8))
         (utf8-primary-closing (plist-get (assoc-default 'primary-closing db-entry) :utf-8))
         (utf8-secondary-opening (plist-get (assoc-default 'secondary-opening db-entry) :utf-8))
         (utf8-secondary-closing (plist-get (assoc-default 'secondary-closing db-entry) :utf-8))
         (utf8-apostrophe (plist-get (assoc-default 'apostrophe db-entry) :utf-8))
         )

    (setf (plist-get
           (assoc-default 'primary-opening
                          (assoc-string lang org-export-smart-quotes-alist))
           :html)
          utf8-primary-opening)

    (setf (plist-get
           (assoc-default 'primary-closing
                          (assoc-string lang org-export-smart-quotes-alist))
           :html)
          utf8-primary-closing)

    (setf (plist-get
           (assoc-default 'secondary-opening
                          (assoc-string lang org-export-smart-quotes-alist))
           :html)
          utf8-secondary-opening)

    (setf (plist-get
           (assoc-default 'secondary-closing
                          (assoc-string lang org-export-smart-quotes-alist))
           :html)
          utf8-secondary-closing)

    (setf (plist-get
           (assoc-default 'apostrophe
                          (assoc-string lang org-export-smart-quotes-alist))
           :html)
          utf8-apostrophe)))

(add-hook 'org-mode-hook (lambda ()
                           (cc/reconfig-org-smart-quotes-lang "en")))

The above code is tested on Emacs 29.1, Org 9.6.25.

If you export to different languages, be sure to run cc/reconfig-org-smart-quotes-lang with your language of choice.

I leave it as an exercise to motivated readers more experienced in Elisp to write a cleaner version of this code. As it stands, this works well enough to achieve my desired goal.

-1:-- Exporting UTF-8 Smart Quotes from Org Mode (Post Charles Choi)--L0--C0--April 10, 2024 09:30 PM

Irreal: Neal Stephenson On Emacs

All of us Emacs nerds are familiar with Neal Stephenon’s essay In the Beginning…Was the Command Line, in which he describes Emacs as the thermonuclear word processor. A couple of years ago, he did a podcast with Lex Fridman in which he expands on his remarks and comments on the longevity of Emacs.

Fridman asked him if he thought that Emacs would still be around in, say, a hundred years. Stephenon’s answer invoked the John Henry legend where in the end, Henry was unable to keep up with the steam hammer. Stephenson says that Microsoft and Apple are pouring so much money and effort into VS Code and XCode that eventually Emacs won’t be able to keep up.

I don’t think that XCode is an issue in this discussion. It’s not primarily a text editor and is, in any even, very specific to the Apple universe. VS Code, on the other hand, can certainly be said to be an Emacs competitor. I don’t think it’s as powerful or full featured as Emacs but it does have a lot of money and power behind it. Whether Microsoft itself will survive for a hundred years and if they do whether they’ll find it economically advantageous to continue supporting VS Code are open questions.

I think that technology 100 years from now will look so different from what we have today that virtually no technology we have now will be extant. That will probably include Emacs. On the other hand, Emacs has been defying the odds for a long time and may surprise us all. What do you think?

-1:-- Neal Stephenson On Emacs (Post jcs)--L0--C0--April 10, 2024 03:36 PM

Manuel Uberti: Thesis frontispiece with LaTeX

Usually when I start writing a new document I am not immediately interested about the output layout. This may sound unorthodox to one accustomed to the WYSIWYG1 likes of Microsoft Word, but since I mainly write in Markdown and LaTeX, I like to focus on what I want to say first and think about typesetting the text later. The look of the output matters, though, so eventually I have to deal with it.

For example, while working on my BA thesis with LaTeX I was faced with the problem of the frontispiece. Ca’ Foscari university provides a template that students can slap in front of their documents, but the choice is limited to a couple of popular file formats: DOC and ODT.2

The quick and dirty solution could have been along these lines:

  • edit the ODT template;
  • export it to a PDF file;
  • add it to the front of my final document.

However, I decided to stick with AUCTeX and accept the challenge. The following is a working example based on my thesis that can be saved to a frontispiece.tex file:

\documentclass[12pt]{book}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{xcolor}

\begin{document}

\begin{titlepage}

\newgeometry{top=1cm,bottom=1cm,right=1cm,left=1cm}
\fontfamily{lmss}\selectfont
\includegraphics[width=0.15\textwidth]{cafoscari-logo}\par\vspace{1cm}

\begin{center}
\LARGE{Corso di Laurea triennale in \colorbox{gray!10}{indirizzo}\par}
\vspace{1cm}
\LARGE{Tesi di Laurea\par}
\vspace{1.5cm}
{\huge\bfseries \colorbox{gray!10}{titolo}\par}
\LARGE{\colorbox{gray!10}{sottotitolo}\par}
\end{center}
\vspace{2cm}
\vfill
\textbf{Relatore}\\
\colorbox{gray!10}{nome e cognome}\\[0.5cm]
\textbf{Laureando}\\
\colorbox{gray!10}{nome e cognome}\\
\colorbox{gray!10}{numero matricola}\\[0.5cm]
\textbf{Anno Accademico}\\
\colorbox{gray!10}{0000/0001}
\vfill

\end{titlepage}

\end{document}

The only missing bit is the Ca’ Foscari university logo, referenced above as {cafoscari-logo} as per the name of the image file I used, which is cafoscari-logo.png. Here it is:3

Now, getting a PDF is simply a matter of placing the .tex and the .png files in the same directory and run something like pdflatex frontispiece.tex.

On the other hand, I have AUCTeX and PDF Tools on my side. From the comfort of Emacs I can then set TeX-view-program-selection to '((output-pdf "PDF Tools")) and hit C-c C a to create and display the desired PDF output.

One last remark for any Ca’ Foscari student reading this. To the best of my knowledge supervisors in the Philosophy department usually ask for drafts in DOC format. Although this may not be true for other departments, unless LaTeX is a requirement make sure your supervisor and assistant supervisor, if any, accept PDFs when you want their valuable opinion on your draft.


  1. See: WYSIWYG↩︎

  2. See: Upload tesi, antiplagio e veste grafica↩︎

  3. The logo comes from the ODT template, which is publicly available on the university website. I just extracted it to a PNG file using LibreOffice Writer. ↩︎

-1:-- Thesis frontispiece with LaTeX (Post Manuel Uberti (manuel.uberti@inventati.org))--L0--C0--April 10, 2024 03:00 PM

Unwound Stack: Ann: ob-coq

Org Babel support for Coq

-1:-- Ann: ob-coq (Post Michael (sp1ff@pobox.com))--L0--C0--April 10, 2024 07:00 AM

Kisaragi Hiu: Expo: How to do a local build without the dev server and without logging in

I'm trying to test out the startup process of an open source React Native app built with Expo, so I really need the dev server to get out of the way in this case. Expo docs describes two ways to build locally, which are (a) use expo run and (b) use eas --local. This is not the whole picture. In Expo, your actual build options, as far as I can tell, are:
-1:-- Expo: How to do a local build without the dev server and without logging in (Post Kisaragi Hiu)--L0--C0--April 10, 2024 04:48 AM

Jiewawa: Another Way of integrating Mozilla Readability in Emacs EWW

I was browsing Planet Emacslife yesterday when I came across Anand Tamariya’s post Mozilla Readability in GNU Emacs. I recently wrote a minor mode that had achieves the same thing, but Anand and I took very different approaches to get the same results.

Anand used the official Mozilla Readability package, but I use rdrview which is a port of Mozilla’s original program written in C. The developer claims that “the code is closely adapted from the Firefox version and the output is expected to be mostly equivalent.”

He also modified the source code of eww.el, whereas my approach was to use the eww-retrieve-command variable which was added in Emacs 28.1. The following is enough to get started, but I wasn’t entirely happy with the results.

(setq eww-retrieve-command '("rdrview" "-H"))

Since Emacs 29.1, EWW buffers can be automatically renames to give more descriptive names I typically like it to display the title of the web page. The following code can be used to accomplish it.

(defun my-eww-rename-buffer ()
  (when (eq major-mode 'eww-mode)
    (when-let ((string (or (plist-get eww-data :title)
                           (plist-get eww-data :url))))
      (format "%s *eww*" string))))

(setq eww-auto-rename-buffer 'my-eww-rename-buffer)

However, the way that rdrview works is that it only displays the main content of a web page and that does not include the <head> or <title> tags. I often have many EWW buffers open, so it is very important that I can quickly distinguish each of them without having to opening them.

By changing the flags provided to the rdrview command, I could prepend the web page with the title. Then, I simply had to write a function that updates the title in eww-data, and add the function to eww-after-render-hook.

(define-minor-mode eww-rdrview-mode
  "Toggle whether to use `rdrview' to make eww buffers more readable."
  :lighter " rdrview"
  (if eww-rdrview-mode
      (progn
        (setq eww-retrieve-command '("rdrview" "-T" "title,sitename,body" "-H"))
        (add-hook 'eww-after-render-hook #'eww-rdrview-update-title))
    (progn
      (setq eww-retrieve-command nil)
      (remove-hook 'eww-after-render-hook #'eww-rdrview-update-title))))

(defun eww-rdrview-update-title ()
  "Change title key in `eww-data' with first line of buffer.
It should be the title of the web page as returned by `rdrview'"
  (save-excursion
    (goto-char (point-min))
    (plist-put eww-data :title (string-trim (thing-at-point 'line t))))
  (eww--after-page-change))

That’s all you really need to use this minor mode, but my preferred entry point is toggling it on and off from within EWW. The regular eww-readable function is bound to a single key press, and I wanted to also have a function that can be called the same way.

(defun eww-rdrview-toggle-and-reload ()
  "Toggle `eww-rdrview-mode' and reload page in current eww buffer."
  (interactive)
  (if eww-rdrview-mode (eww-rdrview-mode -1)
    (eww-rdrview-mode 1))
  (eww-reload))

Generally eww-readable is good enough at getting rid of the distracting parts of a web page, but there are still times when it doesn’t work exactly as I want it to. There are also times when rdrview doesn’t work as I’d hoped it to either.

Since writing the above code, I find that I have been using both methods for removing clutter from web pages. I’ll try one and if I’m not satisfied, then I’ll use the other.

-1:-- Another Way of integrating Mozilla Readability in Emacs EWW (Post)--L0--C0--April 10, 2024 12:00 AM

Yi Tang: Less Excel, More R/Python in Emacs

Table of Contents

  1. Excel Is Great
  2. But
  3. Emacs Has More To Offer

Excel Is Great

Regardless of how powerful and convenient the R/Python data ecosystem becomes, there is still value in looking at the data in Excel, especially when exploring the data together with less technical people.

Thanks to its trivial interface Excel is widely used in data analysis: hoover the mouse to select columns, apply filters then calculate some statistics. Most of the time that is all it takes to get the answers the clients are seeking.

I recently realised that having transparency and working with the tools that clients use plays a crucial role in strengthening the trust and delivering the impacts to the business. Sometimes I think I should do more in Excel.

But

The problem with Excel is reproducibility - I’m not able to codify the clickings done in Excel and integrate them into the automated data pipeline. It is rather foolish to have quality control procedures, including code reviews, automated testing, CI etc in the system but in the very end drop all those gatekeepers and go for error-prone manuals.

Plus it is way more efficient to have everything done in one place to have a smooth process with no fractions. It is a key factor in enabling quick turnaround.

So I had the motive to limit the usage of Excel to deliver data to the business and pair data analysis. Again I have been looking into how much it can be done without leaving Emacs.

Emacs Has More To Offer

I was pleased to discover the ess-view-data package and its Python counterpart python-view-data. They interact with an active R/Python session in Emacs and print out data.frame objects in plain text, a.k.a. view data. What’s more, it can process the data before viewing, for example, subset the data row/column-wise, summarise the dataset etc.

The package keeps a record of the data processing pipeline so in the end I would have a copy of the R/Python code that generates the output. I can then effortlessly transfer the code to a script to ensure reproducibility in the future.

Another benefit derives from having a plain text buffer for the data. It is handy in exploring large datasets with an excessive number of columns. For example, the dataset I work on daily basis has about 300 columns. It contains different flavours of the financials, the raw values, imputed, ranked, smoothed etc.

It’s not possible to remember all the column names even after more time was spent in giving meaningful names or ensuring the correct columns are referred to. Having a persistent plain text buffer that I can search for makes finding the right column names a lot easier. It also helps to check what’s in and not in the data.

That’s my first impression of Shuguang Sun’s packages, it looks promising.

-1:-- Less Excel, More R/Python in Emacs (Post)--L0--C0--April 09, 2024 11:00 PM

Anand Tamariya: Mozilla Readability in GNU Emacs

 

Output using Readability (left) and original eww (right)

 

Mozilla Readability is a standalone version of the readability library used for Firefox Reader View. A simple hack to eww can bring the same feature in GNU Emacs. (Note: eww already has a readable mode. This is just an alternative. Updated the post to reflect the same.)

 

- Install NodeJS 

- Install npm modules.

npm install @mozilla/readability jsdom

 

- Create a file readability.js with following content. Note the file location.

var { Readability } = require('@mozilla/readability');
var { JSDOM } = require('jsdom');
var fs = require("fs");
var str = fs.readFileSync(process.stdin.fd).toString();
var doc = new JSDOM(str);
var reader = new Readability(doc.window.document);
var article = reader.parse();
console.log(article.content);
 

 

- Modify the following function to use the file location noted above. Evaluate the function.

(defun mozilla-readability (start end)
  (shell-command-on-region start end "node <full path to readability.js>" nil t))
 

 

- Modify eww.el to use the function by adding the line below.

@@ -765,6 +768,7 @@ eww-readable
         (condition-case nil
             (decode-coding-region (point-min) (point-max) 'utf-8)
           (coding-system-error nil))
+                (mozilla-readability  (point-min) (point-max))
                 (eww--preprocess-html (point-min) (point-max))
         (libxml-parse-html-region (point-min) (point-max))))
          (base (plist-get eww-data :url)))
 

 

- Use M-x eww as you would normally do. Use R (eww-readable) to view the Firefox readable version.

 

-1:-- Mozilla Readability in GNU Emacs (Post Anand Tamariya (noreply@blogger.com))--L0--C0--April 09, 2024 06:35 AM

Protesilaos Stavrou: Emacs: ‘ef-reverie’ and ‘ef-dream’ are added to the ‘ef-themes’

I am pleased to announce two new themes for my ef-themes package: ef-reverie (light) and ef-dream (dark). They revolve around the use of gold and other complementary nuanced colours, all while optimising for legibility.

Sample pictures are available below. Check all the items here: https://protesilaos.com/emacs/ef-themes-pictures. Always click to enlarge the image for best results.

ef-reverie

ef-reverie theme sample

ef-reverie theme git sample

ef-reverie theme mail sample

ef-reverie theme org sample

ef-dream

ef-dream theme sample

ef-dream theme git sample

ef-dream theme mail sample

ef-dream theme org sample

Coming in version 1.7.0 (next stable release)

The ef-reverie and ef-dream will be widely available via GNU ELPA whenever I release the new version of the ef-themes package. This might happen before the end of April. At any rate, I consider the themes done, though I might still make some minor refinements.

Enjoy!


The ef-themes are a collection of light and dark themes for GNU Emacs that provide colourful (“pretty”) yet legible options for users who want something with a bit more flair than the modus-themes (also designed by me).

-1:-- Emacs: ‘ef-reverie’ and ‘ef-dream’ are added to the ‘ef-themes’ (Post)--L0--C0--April 09, 2024 12:00 AM

Kisaragi Hiu: Monthly review for March 2024

I felt like I should write reports on what I've been doing, to more accurately guage how much work I've actually done, so here it is. I became a KDE e.V. member at the end of February for my translation work for KDE, following an invitation from Jeff Huang, another zh-TW translator for KDE and other Free Software. In March, I started making kde-project.kisaragi-hiu.com, a redirector from KDE project IDs and also a fast-loading KDE project list, utilizing KDE's own metadata for projects.
-1:-- Monthly review for March 2024 (Post Kisaragi Hiu)--L0--C0--April 08, 2024 04:14 PM

Sacha Chua: 2024-04-08 Emacs news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, lobste.rs, kbin, programming.dev, lemmy, communick.news, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, and emacs-devel. Thanks to Andrés Ramírez for emacs-devel links. Do you have an Emacs-related link or announcement? Please e-mail me at sacha@sachachua.com. Thank you!

-1:-- 2024-04-08 Emacs news (Post Sacha Chua)--L0--C0--April 08, 2024 03:23 PM

Marcin Borkowski: Even more Magit tips

Almost five years ago I wrote a short post with some Magit tips. Well, why not write some more? Magit is slowly but constantly evolving, and recently I discovered something very useful I didn’t even know existed.
-1:-- Even more Magit tips (Post)--L0--C0--April 08, 2024 06:30 AM

Sacha Chua: Emacs interview: Daniel Semyonov

Emanuel Berg wanted to contribute this interview of Daniel Semyonov. Here it is! - Sacha

Interview with Daniel Semyonov, self-taught programmer and Emacs developer, who currently works on an Atom backend for Enacs Gnus - nnatom (Sourcehut link, might not be working) - among other projects.

Q: Can you tell us something about yourself, where you live and so on?

A: I'm a 25 year old hobbyist programmer, recently unemployed, living in Israel.

Q: Where did you first learn how to program, and how did that happen - do you remember?

A: I was interested in programming from a very young age, mainly due to video games. When I was around 8-9 years old, I found a set of tutorials for Game Maker on some website probably long gone by now, and I made a simple single player pong game, where you just play against a wall.

I made a bunch of further attempts to learn programming but most resources I found in Hebrew back then were for basic web development which I didn't find very interesting.

I then took after-school classes where I learned basic C# when I was around 16. I made a bunch of simple programs, and also a simple 2D platformer with XNA. ["XNA's not acronymed", a Microsoft freeware platform for games.]

Q: After that, how did it happen that you got involved in the free software and open source world? Did people bring you along or did you find it on your own? What were your impressions at that time?

A: I discovered free software through Linux, and honestly really "got it" through Emacs.

I started using Linux around 2015, dual-booting with Windows, when some programs I found, probably on GitHub, had to be compiled from source, and only had instructions for Linux. Probably overkill, in hindsight.

Eventually I discovered Emacs and Elisp. Learning Elisp was, for me, incredibly easy because all the information I wanted was always available in a convenient way. Even when there was no docstring, I could click a button to jump to the source code and I could see the results instantly. This made me really appreciate the value of being able to see and modify the source code.

Q: Is there a community for open source people in your city - if so, are you in contact with them? What is your impression from universities and business offices, what kind of position do we, as in Emacs, Linux, BSD and so on, have? Do you see it a lot and do people speak about it enthusiastically, or are they indifferent to it?

A: Unfortunately, there is no community like that in my area which is fairly remote.

I'm also not part of the tech industry in my country and I don't have much experience with universities. To be honest, I can remember maybe three people I've met which expressed any sort of enthusiasm for these things. I try talk to people about Linux, Emacs and other related topics whenever they seem interested, and almost no one ever has any idea what I'm talking about unfortunately.

Q: When and how did you first encounter Emacs in your life? Do you remember why you were attracted to it? Why do you think it happened that you became not just an Emacs user but a developer of its software?

A: I encountered Emacs first when I wanted to program on Linux and I was searching for recommended editors. I noticed quickly a lot of arguing about Vim vs. Emacs, which led me to use Vim for a while.

Vim was annoying to configure - from what I remember, I haven't tried in years - so I looked into Emacs, and honestly I decided to switch to it because pictures of Spacemacs looked cool.

I quickly discovered that while Spacemacs looks cool, I didn't understand how anything works, and after a bit decided to try building my own configuration. Thankfully, Elisp is a pretty nice language, and Emacs allows you to do a lot with just Elisp, so I quickly made more and more advanced changes until eventually I started developing packages and hacking on Emacs itself.

Q: There are many reasons people become programmers, what was the most important one to you?

A: As you might guess from some of my earlier answers, I never really had a lot of money, and many times during my life I had a desire to work on various projects or do various things, but I couldn't afford to do so. As a programmer, it feels that if I only have a simple computer and patience, I can do anything I want.

Q: What project are you currently working on? Go ahead, take your time to describe it - what problem does it intend to solve, and why is it so interesting for you to spend so much time on it? What problem have so far been the biggest and did you overcome it?

A: Honestly, I always work on a bunch projects at once, since I find it hard to focus on one project for an extended period of time. One project I currently work on is a Gnus backend for Atom feeds. I have been working on it for around 3 years at this point, though most of the development actually happened over fairly short time periods, just spread apart.

When I first wrote it, I had a lot of trouble understanding how to implement a backend in the first place. I was much worse at Elisp back then. This led me to eventually separate feed parsing (which is the part you can't avoid handling if you implement a backend for a new type of feed) from the rest of the implementation.

After a few iterations, nnatom, the Atom backend, was based on nnfeed, an "abstract" backend which handles everything except for actually parsing a feed.

This means that nnfeed can be used to define new backends very easily, with minimal knowledge of how Gnus actually works. Since this seems important to me (I honestly don't know the last time a backend was added), I did extra work to make 'nnfeed' more generic. It supports in theory "feeds", Gnus servers, providing multiple Gnus groups, it doesn't require reading the whole feed ahead of time to start parsing it (which is meant to support feeds which can span multiple files/urls, like JSON feeds), it notifies the inheriting (parsing) backend when the last article parsed wasn't new or updated (to prevent parsing the entire feed if it can be avoided, though this is not used by `nnatom' since Atom feeds are only one file anyway), and it should handle most types of articles (and I made that part of `nnfeed' also modifiable by inheriting backends in case there are some it can't).

Q: From a human perspective, how has open source treated you?

A: I've found that usually I either don't get a response or I get a positive one when I contribute in some way to a project. So all in all, it's been fairly positive.

Q: Is there anything we can do better to support our programmers all over the world?

A: Just be nice to them.

As a mostly self-taught programmer, the only times I really advance as a programmer, are when I'm daring enough to try something I don't feel confident about. If at that point someone insulted doing something wrong or making a mistake, I would probably stop working on it to be honest. I won't name it, but there is a project I am passionate about which I will likely never contribute to because the developers often attack would-be contributors for making mistakes, and I just don't want to deal with that.

Thanks to Daniel Semyonov and Emanuel Berg for sharing this story! Daniel has a small website at https://dsemy.com/ , and Emanuel can be found at https://dataswamp.org/~incal/ . - Sacha

-1:-- Emacs interview: Daniel Semyonov (Post Sacha Chua)--L0--C0--April 07, 2024 09:27 PM

Irreal: A Deep Dive On Registers

Arialdo Martini is back with a very informative post about using registers to store buffer locations and other data. He starts with positing the need to store buffer locations by name rather than storing them in a ring buffer as he discussed in his post on the mark ring and then gives two possible implementations.

Of course, that’s not necessary because Emacs already has functions to do this. I generally use registers to store other information such as window configurations and text I need to insert repeatedly into a document but storing buffer locations can be useful.

It turns out that the Emacs implementation is much more robust than you might imagine. For example, if you close a buffer that is stored in a register and is displaying a file, Emacs will update the register to a file-query that will reload the buffer if you jump to the register containing the reference.

But it gets better. Martini shows how you can make registers persist across Emacs sessions. All of this is builtin to Emacs and available simply by invoking the requisite functions.

The only thing that Martini doesn’t mention is that the register keys aren’t stored as a single character but as a symbol reference.That means that you can name a register as a symbol (in Elisp), which makes it easy to store, say, window configurations without risking having it overwritten interactively. I use this all the time to run certain functions in full screen and then restore the previous window configuration when I’m done.

The thing about registers, as Martini says, is that they’re implemented using normal Elisp data structures that are available to end users to use in any way they see fit. It’s another example of how configurable Emacs is.

-1:-- A Deep Dive On Registers (Post jcs)--L0--C0--April 07, 2024 04:02 PM

Please note that planet.emacslife.com aggregates blogs, and blog authors might mention or link to nonfree things. To add a feed to this page, please e-mail the RSS or ATOM feed URL to sacha@sachachua.com . Thank you!