Jun 04,
2018

Killing buffers in Emacs

Good day Interweb surfers!

I've used Emacs for several years but until today I've never realized that the kill-this-buffer function should be invoked only by menu:

This command can be reliably invoked only from the menu bar, otherwise it could decide to silently do nothing.

According to the Interwebs, around 10 years ago the function was made menu-bar specific, but originally could be invoked freely. I haven't investigated the rationale behind the change, but I'm pretty sure I've picked it up more than 10 years ago.

The observant reader would correctly guess that only this morning, amusingly enough, it decided to silently do nothing and I have no idea what I did differently1.

To not be surprised again in the future, at first I modified the binding like this:

(global-set-key (kbd "<f8>") 
                '(lambda ()
                   (interactive)
                   (kill-buffer (current-buffer))))

but immediately after I found out that the kill-current-buffer function, defined in simple.el, seems to do a slightly better job at killing buffers than my lambda above and it's probably the spiritual successor of the kill-this-buffer function.

A few days ago I also fixed the cursor position when correcting typos with Flyspell2 and when reopening a buffer as root, that always annoyed me but I continued forgetting about it:

;; flyspell
(eval-after-load 'flyspell
  '(define-key flyspell-mode-map (kbd "C-.")
     '(lambda ()
        (interactive)
        (let ((origin (point)))
          (flyspell-correct-at-point)
          (goto-char origin)))))

and

;; open the current buffer as a different user or root as default
(defun reopen-this-buffer-as-another-user (user)
  "Re-open the current buffer with tramp and sudo,
  using root as default"
  (interactive "sRe-open as user (default: root): ")
  (when (string= "" user)
    (setq user "root"))
  (let ((origin (point)))
    (find-alternate-file 
      (concat (format "/sudo:%s@localhost:" user)
              buffer-file-name))
    (goto-char origin)))

The only remarkable thing about the two definitions above is I couldn't use the save-excursion function because in both I hit two different corner cases: the first is related to the insertion of text adjacent to the saved position and the second is about changing buffers3.


  1. well, it should be related to the menu-bar's frame 

  2. an Emacs spell checker 

  3. the curious reader can find the details on the official documentation 

 
 

Apr 23,
2018

Emacs Backups

Howdy Interweb neighbor!

Today rambling is about a little known Emacs package that I found somewhat casually. Emacs has an internal mechanism to backup files1 and they could turn up useful in case of a disaster, supposing the mentioned disaster doesn't wipe the user's storage device or worse.

Anyway, I've always found them somewhat difficult to handle on the shell cause their name consists of the full path and the exclamation point ! is used as separator, a tricky character to use when on a shell. The end result was I seldom used them in the past. Or in other words, only as the last option.

Enters backup-walker, available on your local Melpa/Elpa repository.

backup-walker

This nifty tool permits to show the differences, using Emacs' ediff, between your currently opened file and its backed-up copies stored in your home dir, and as the name imply, one can literally walk the differences in the past with the p and n keys.

How did I lived without it until now?


  1. ironically they are usually the first thing disabled because the default is to create them on the same path of the modified file 

 
 

Mar 22,
2018

Sqlitebrowser

Hello folks!

A few days ago I needed to inspect an SQLite DB file and after a quick query through Google, I found out that I already had the Sqlitebrowser package installed but I somewhat forgot about it or to have used it at all.

After firing it up and used it for a couple of minutes I finally recalled why I stopped using it: it horribly breaks Gnome's Workspaces1.

(ノಠ益ಠ)ノ彡┻━┻

This time I chose to fix it, yak shaving time!

Well, to be honest I'm surprised that the issue isn't present on the Debian bug tracking system, I wonder what SQLite browser is used by the Gnome's majority, anyway on the upstream GitHub repository there's a bug report (#934) and a commit (c4c4cf62a2adf90c7604a920c409c27192f177ce) that allegedly should fix this issue.

Small divagation

I started to use Docker to rebuild packages as it's quite friction-less when one become familiar with the terminology and the concepts of images and containers. I was never quite comfortable with the deb-builder even if Docker has some limitations, for example cross-building is not an option, anyway with Debian's dget it's quite fast to get packages' sources and the building dependencies, assuming one is using Docker on a fast up-link with the Interweb or a packages proxy2.

Turning back to the subject of this post, the interested reader can find below the required patch for current Debian stable package:

--- orig/src/MainWindow.cpp 2016-10-03 01:25:32.000000000 +0200
+++ mod/src/MainWindow.cpp  2018-11-14 12:53:07.466422797 +0100
@@ -814,7 +814,6 @@
 {
     if (!visible) {
         // Update main window
-        activateWindow();
         ui->dataTable->setFocus();
     } else {
         // fill edit dock with actual data

By the way, after fixing it, I found another SQLite capable browser called Sequeler, that also supports MySQL, MariaDB and PostgreSQL, and sports in my opinion a quite slick GTK3 interface. The latest version is also available as Flatpak, a nice touch if someone asks me.

For the moment, it lacks the ability to modify a record directly from the interface, without typing an update query on the console, but in it's current form is nonetheless a quite useful tool.

Now after the interruption I can continue with the regular programme schedule.


  1. what are commonly called "virtual screens

  2. Ephemeral Logs Reprise