Recent Changes

Updates since 2019-05-23 21:13 UTC

1 | 3 | 7 | 30 | 90 days
List all changes Include rollbacks List only major changes
List later changes RSS RSS with pages RSS with pages and diff

2024-03-18

  • 16:52 UTC (new) (history) 2024-03-18 Follow mode . . . . mbork It is a fairly common opinion that a function should not be larger than your screen. The reality, though, is often different. And even if your functions are shorter, you may want to see more than one at a time. The problem is that our screen are usually not that high. (My laptop gives me 66 lines of text with normal font settings.) You can have an external monitor rotated vertically (I have that at work to see as much of the logs of the application I’m working on as possible), but Emacs gives us another solution – the Follow mode.
  • 16:51 UTC (new) (history) 2024-03-16 Follow mode . . . . mbork Deleted 2024-03-16_Follow_mode

2024-03-14

2024-03-12

2024-02-28

2024-02-26

  • 17:48 UTC (new) (history) 2024-02-26 A simple trick with URL parsing in plain text emails . . . . mbork Today I only have a very short tip I thought up a few days ago. If you sometimes send URL via emails (like me), and you absolutely hate HTML emails (like me), there is a common and annoying problem. If the URL you send is the last thing in a sentence, and you want to be correct and end that sentence with a period (or other punctuation), a lot of email clients will treat that punctuation as part of the URL, and of course such “modified” URL won’t work for the recipient. I usually solved that by putting a space between the URL and the period – not 100% correct, but I could live with that. A few days ago it occurred to me that there is another, slightly hackish way to solve my issue. From now on I’m using a hash instead of a space. Assuming that the website I link to doesn’t have any element with the id~ of a period (or any other weird thing like an exclamation mark, of a period followed by a closing parenthesis etc.), the punctuation will be ignored by the browser, but I won’t need to put any space before the end-sentence period. You’re welcome!

2024-02-17

  • 16:30 UTC (new) (history) 2024-02-17 Opening external drives in Dired . . . . mbork I use external drives pretty often – for backups, for moving files between machines, and for storing mp4 files, for example. I’ve been using UDisks for quite some time now. It automounts an external drive under the /run/media/$USER/VolumeName directory (where VolumeName is different for each drive, of course). I also use Dired as my main file manager. As most Emacsers know, it’s far from shiny, but it’s incredibly powerful, especially combined with some other Emacs features. One problem I have is that when I insert a drive into one of the USB ports, I’d like to be able to open it in Dired.
  • 16:29 UTC (diff) (history) Comments on 2024-02-12 Finding Bible quotes . . . . mbork Ha, that's *very* interesting, thanks! I'm wondering if it's documented anywhere...

2024-02-12

  • 05:39 UTC (new) (history) 2024-02-12 Finding Bible quotes . . . . mbork I often have the need to find some particular quote of the Bible – either I am reading some religious text or I want to link to some passage on my blog. What I miss is the ability to quickly see the relevant passage, open it in a browser and create an Org mode link to it.

2024-02-05

  • 05:45 UTC (new) (history) 2023-02-05 From the kill ring to a register revisited . . . . mbork Two weeks ago I wrote about my little command to move the topmost (or some other) kill ring entry to a register. It turned out that this particular post – which I thought was rather niche – spurred more interest than apparently more useful posts I have. Go figure.

2024-01-26

2024-01-22

  • 04:18 UTC (new) (history) 2024-01-22 From the kill ring to a register . . . . mbork I am probably one of the five or six people on this planet who use Emacs registers. I mostly use them for text insertion (especially when I need to insert some boilerplate – and especially more than one piece of it – several times, but it’s not general enough to be put into Yasnippet), but I sometimes store window configurations in them, and I might have used them for other purposes once or twice. Sometimes, though, I kill some text to yank it elsewhere and only then realize that I’ll need to kill/yank some other fragments, too. Using the kill ring to do this one time is fine (with M-y or with browse-kill-ring); using it more times is rather inconvenient. Hence I decided to write a little command to copy the text from the kill ring to a specified register. And here it is.

2024-01-08

2023-12-25

  • 21:26 UTC (new) (history) 2023-12-25 Merry Christmas 2023 . . . . mbork As usual at this time of year, let me wish all of you Merry Christmas! And also as usual, I promise to say a decade of the Holy Rosary for everyone reading my blog.

2023-12-11

  • 17:05 UTC (new) (history) 2023-12-11 Replacing TeX control words behind the point . . . . mbork Two weeks ago, a friend from Polish TeX Users’ Group mailing list asked about an Emacs tool to replace control sequences with their Unicode counterparts. I also have this need from time to time, and I usually go with the TeX input method. He is not satisfied with it, though, because it replaces too much for him – for instance, he doesn’t want a_1 to get translated to a₁. He remembered some utility (written by another Polish TeX user) which replaces a TeX sequence with a Unicode equivalent, but only on demand. Since that one seems to be lost in the depths of time, he was left without a solution.

2023-11-27

  • 08:33 UTC (new) (history) 2023-11-27 Clocking in to parent entries . . . . mbork Like many, many Emacs users these days, I’m a heavy user of Org mode. In fact, both of my blogs are written in Org. And while this very blog usually has fairly short entries, my other blog has much longer posts, divided into subsections. This creates a minor problem for me. I track time I spend on writing, but I don’t want to track time spent on individual sections of a blog post. In other words, even if I am in some lower-level heading, when I clock in, I want Org to clock in in the parent heading. Emacs being Emacs, I figured there must be a way to make that happen automatically.

2023-11-13

  • 06:24 UTC (new) (history) 2023-11-13 Coloring CamelCase . . . . mbork Some time ago one of the members of the Emacs mailing list asked about coloring CamelCase identifiers. His idea is to define two faces and have all “even” words in a camel case indentifier colored with one of them, and the “odd” words colored with the other one. The question suggests using some code from Glasses mode, which is a lesser-known Emacs feature which inserts undescores between words in camel case identifiers (and it does it using overlays, so the underscores are not really part of the buffer, they just look like this). My general rule is to avoid camel case whenever I can, but I sometimes use Glasses mode, especially when I have to deal with jsx files, where camel case is the standard. It turns out that Glasses mode already has (almost) what is asked for.

2023-10-30

  • 18:52 UTC (new) (history) 2023-10-30 My plans for 2023 - October update . . . . mbork It’s been another two months since my last update, so here we are again! It’s been a busy two months for me, though some plans still are not brought to the forefront (which is a shame, I know, but I can’t do everything).

2023-10-14

  • 05:04 UTC (new) (history) TODO 2023-10-14 Avoiding repetitions . . . . mbork Deleted TODO_2023-10-14_Avoiding_repetitions
  • 05:03 UTC (new) (history) 2023-10-14 Avoiding repetitions . . . . mbork I write a lot of prose. That does not mean I’m good at it nor very creative – I haven’t written any novels or even short stories. By “prose” I mean writing in a natural language (mostly English nowadays). In fact, most of the writing I’ve done in my life is technical in nature (usually either about technology or about mathematics). And (as you obviously know) I’m also a technology geek and an Emacs user. An immediate thought is: how to make Emacs help me write better?

2023-09-30

  • 19:17 UTC (new) (history) 2023-09-30 Confirming potentially dangerous actions . . . . mbork A common situation is when I want to do something on my computer with possibly destructive consequences, like deleting a file, truncating a database table etc. One common approach to making sure this won’t happen accidentally is to require the user to press y or even type yes (this is what Emacs does with its y-or-n-p and yes-or-no-p functions). Some time ago I had a similar need in a shell script. I was afraid, however, that even requiring the user to type yes is not enough – it is easy to condition oneself to type a three-letter word without much thinking, after all.

2023-09-18

  • 18:41 UTC (new) (history) 2023-09-18 Making Anki flashcards from subtitles . . . . mbork Those of you who follow my blog know that one of my hobbies is translating subtitles. The main reason I do this is to watch stuff with my daughter, who doesn’t yet speak English fluently. Some time ago it dawned on me that I can use my translations twice. Not only can I watch films and tv series with her, but I can use them to help her learn English.

2023-09-05

2023-08-21

  • 17:47 UTC (new) (history) 2023-08-21 My plans for 2023 - August update . . . . mbork Since about two months have passed since the last blog post with my 2023 plans update, it’s time for another one. This time it is going to be a bit shorter, since not a lot of stuff has happened (or rather, a lot did, but it was mostly concentrated on one of the projects, which I think is… good?).

2023-08-05

2023-07-22

2023-07-15

  • 04:26 UTC (new) (history) 2023-07-15 Drawing ASCII art charts in Emacs buffers . . . . mbork Two months ago I wrote about how I track my weight in Emacs. I am still doing it, and dieting works quite well, but I had one problem with my setup: I really wanted to have a graphical representation of my weight data – in other words, a chart. After quickly assessing the existing solutions (the chart.el library included in Emacs and Org Plot, I decided that I need something else. I don’t want to have to run an external program (in this case, gnuplot), and I want to have a simple ASCII art scatter plot (but neither a bar chart nor just an additional column containing a histogram of the values in the table.

2023-07-08

  • 13:20 UTC (new) (history) 2023-07-08 Finding a common prefix of a set of strings . . . . mbork Some time ago I needed a very specific thing. Given two strings, I wanted to find their longest common (initial) substring. For example, given abc and abd, I wanted ab. I thought that Emacs Lisp must have something like this already, and I wasn’t wrong. It turns out there are even two functions which can do that!

2023-07-03

  • 05:24 UTC (new) (history) 2023-07-03 From mp3s to podcasts . . . . mbork Many years ago I used to listen to podcasts a lot. I had my two favorite ones, and they provided me with more than 90 minutes of interesting material to listen every week (and that is not counting several hundred archive episodes!). Recently, I decided to start listening again to interesting people while I commute. This time, though, I want to listen to webinars instead, and I have them in the form of mp3 files. Thing is, how do I get them on my smartphone?

2023-06-26

2023-06-19

2023-06-12

  • 18:08 UTC (new) (history) 2023-06-12 Counting time, backwards . . . . mbork Some time ago I thought that I would like to have a feature Org mode doesn’t seem to have. There are things I would like to do once in a while, but I don’t need a reminder with a hard deadline (like a repeating one) – I’d prefer a gentle nudge. What if I could display a list of things I select, each one with information how long ago I did it last?

2023-06-03

  • 10:31 UTC (new) (history) Comments on 2023-06-03 Org agenda clock check . . . . Anonymous You missed the very important and really helpful overlap check!
  • 05:30 UTC (new) (history) 2023-06-03 Org agenda clock check . . . . mbork Some time ago (well, a long time ago) someone posted an interesting discovery in Org mode agenda: “clockcheck mode”. I stored the link to that message with the intention of blogging about it and forgot about it. I rediscovered it some time ago and decided to take a look.

2023-05-29

2023-05-20

2023-05-13

  • 11:46 UTC (new) (history) 2023-05-13 Dieting with Org mode . . . . mbork Some time ago I started to weigh myself every day. Some people argue that this is a bad idea and you should weigh yourself once per week to avoid worrying about random fluctuations. I disagree – the way not to worry about random fluctuations is to look at moving averages instead, Hacker's Diet-style. Note: I do not necessarily endorse Hacker’s Diet as a whole, but the moving average approach is certainly a good one. For the sake of simplicity, I am going to use simple (unweighted) moving averages over one week. I want to keep my weight data in an Org mode table (obviously).

2023-05-06

  • 08:21 UTC (diff) (history) Comments on 2023-05-06 Juggling playlists in EMMS . . . . mbork Thanks, I had no idea that exists! I'll check it out.
  • 06:12 UTC (new) (history) 2023-05-06 Juggling playlists in EMMS . . . . mbork It’s been several times now that I described my productivity system here. While I like it a lot, it still has room for improvement. Some time ago I mentioned it to a colleague and shared one frustration I have with it. When I fail to do even one thing on my carefully prepared plan for a day (which happens once in a while, of course), sometimes I lose motivation and skip more subsequent items. This leads to spending less time on things I want to do and more time on procrastination that day. It happens seldom enough not to be a real issue (and it doesn’t mean I fail to do anything – just less than usual or hoped for), but it is a bit frustrating. He suggested a pretty clever (and obvious in hindsight) way to deal with this. His idea is to have a separate music playlist „for work” and train my brain to associate that particular music with focused work. That way I would have another nudge to do particular kind of stuff.

2023-04-29

2023-04-22

  • 19:02 UTC (new) (history) 2023-04-22 Org mode clock table for the last week . . . . mbork Some time ago I mentioned that I started doing “weekly reviews” of what I have done last week and what I am going in the next week. One part of my weekly reviews is checking how much time I spent doing various things last week. Of course, Org mode clock tables are an excellent tool for that. There is one caveat, though. What does “a week” mean? It turns out that it is not obvious at all. The main problem here is the :wstart parameter, telling what day is the first day of the week.

2023-04-15

  • 18:42 UTC (new) (history) 2023-04-15 Downcasing word at point in the whole buffer . . . . mbork Some time ago, one of the members of the Emacs-humanities mailing list mentioned a very specific problem. He wants to be able to replace all occurrences of the word at point with its upercase (or lowercase) variant. This is one of these things that can be solved with a bit of custom Elisp. Being a big fan of writing small (or sometimes not so small) helper functions to make editing easier, I offered to do a bit of coding to accomplish this task, and here it is. Being a teacher, I’d like to provide at least a short explanation, too. (Most of you probably know that I spent quite some time in 2021 doing exactly this – coding Elisp and explaining it – and the result is my book Hacking your way around in Emacs, designed as a “next step” after Robert J. Chassell’s excellent An introduction to programming in Emacs Lisp. Check out Chassell’s book if you are interested in learning Elisp, and then my book if you ant to go further!)

2023-04-13

2023-04-09

  • 04:39 UTC (new) (history) 2023-04-09 Easter 2023 . . . . mbork So, another year has passed since I last wrote about Easter. It would seem that it’s monotonous, but it isn’t – life brings so many unexpected things that I am surprised every day. I am extremely thankful for quite a few things in the last year, but all this pales in comparison to one Event – Christ’s resurrection. If not for that, everything else – every kind person I encountered, every nice surprise I had, every achievement, every pleasure – all that would mean nothing. If there is no resurrection of the dead, then Christ cannot have been raised either, and if Christ has not been raised, then our preaching is without substance, and so is your faith (1 Corinthians 15:14). Good thing is that it’s all true! All that is not to say that last year was without issues. With war going on in neighboring country and plenty of personal problems I can’t say that life is ideal. But it does not negate the fact that I have a lot to be thankful for! Christ has risen, rejoice! And as the tradition goes, be assured that I will offer a decade of Rosary for all my readers here.

2023-04-01

  • 15:54 UTC (new) (history) 2023-04-01 Showing an image between lines in Emacs . . . . mbork I am now coding a bigger thing in Elisp (and I will definitely blog about it when it’s done), but for now let me say something about an issue I encountered along the way. I needed to display an image between the lines (in the literal sense;-)), preferably not interfering with the editing process – so just inserting two newlines and a space with an image display property inbetween was out of the question. (I wanted the user to be able to edit the buffer irrespective of the image display, and actually inserting anything into the buffer would mess with the undo mechanism).

2023-03-25

  • 07:20 UTC (new) (history) 2023-03-25 Using a thesaurus from within Emacs . . . . mbork Now that I started to devote more time to writing, I need a thesaurus more and more often. What I usually did was to go to my browser and use thesaurus.com – but as we all know, leaving Emacs is always a pain. I fired M-x package-list-packages and it turned out that there are several packages to look up synonyms from the comfort of Emacs.

2023-03-20

  • 21:35 UTC (new) (history) 2023-03-20 Manually entering clocking data . . . . mbork As I alluded many times in the past, I use Org mode’s clocking feature almost all the time. However, there are times I don’t. One of such cases is a rare situation when I don’t have access to my computer. Since I started commuting using public transport, I do some reading in a streetcar or bus. When I get to my laptop again, I want to update my clocking data. How to do that?

2023-03-11

2023-03-04

2023-02-27

2023-02-18

  • 08:52 UTC (new) (history) 2023-02-18 My approach to TODOs . . . . mbork Some time ago I described my productivity system. I also mentioned that it is still evolving. One of the aspects where it needed some evolution is handling TODOs – and this is precisely the stuff I am working on right now. Now the main problem I’ve been having for a long time now is that I tend to add a lot of TODOs to my list, which grows much faster than I deal with them. The worst thing here is that when I have so many TODOs lumped together, important and urgent things often get mixed up with unimportant and not urgent ones, etc. So, I devised a way to handle this situation.

2023-02-11

  • 08:37 UTC (new) (history) 2023-02-11 Linear scaling of subtitles timestamps . . . . mbork As I have mentioned here a few times, I spend some time translating subtitles. That’s a prestigious line of work with a long and glorious tradition. However, there are many problems awaiting a bold adventurer who wants to do that. While I really like translating, it is a lot of effort, and sometimes I get the feeling that it’s just nothing but work, work, work, all the time. Well, life is pain. Anyone who says differently is selling something.

2023-02-08

2023-02-04

  • 09:17 UTC (new) (history) 2023-02-04 My accounting book is finished . . . . mbork As I mentioned in my post about plans for 2023, I spent some time last two weeks on Personal accounting in Ledger, my booklet about, well, personal accounting in Ledger. It is now finished.

2023-01-31

2023-01-30

  • 15:18 UTC (new) (history) 2023-01-30 The benefits of everything being a buffer . . . . mbork For today I only have a very short tip – or maybe let’s call it an anecdote. As all Emacs users probably know, one of the very basic Emacs concepts is the buffer. A few days ago I encountered an (admittedly, not very common) situation when this came in very handy.

2023-01-23

2023-01-14

2023-01-09

2023-01-03

2022-12-25

  • 09:17 UTC (new) (history) 2022-12-25 Merry Christmas 2022 . . . . mbork Merry Christmas to you all! Many people seem to fall in the rut of “Christmas again, and my life is still rubbish – nothing changed, and probably nothing will ever change…”. Folks, this is so wrong! What I think is this: “yet another Christmas” means that God believes that I am capable of change, and is giving me one more chance – again! Thank you, my Lord! That is not to say that I should not try to do my best to be better. In my case this means (among other things) that I’m (finally) starting to do regular weekly reviews, and planning my weeks and (hopefully) quarters and years. But enough of it. This is not a post about my productivity, this is about the joy of Christmas! Our Savior is born, rejoice! (Also, per the tradition, I will offer a decade of rosary for all my readers!)

2022-12-19

  • 07:22 UTC (new) (history) 2022-12-19 A few new things in Emacs 29 . . . . mbork Everybody with an Emacs blogs raves about Emacs 29 these days. Things like Eglot, tree-sitter, SQL support and the like. Well, this is all nice – more than nice, brilliant! – but let’s not forget a few minor advances which are coming with Emacs 29. Let me mention a few things that I especially like.

2022-12-12

  • 10:39 UTC (new) (history) 2022-12-12 Debugging chained operations in Lodash . . . . mbork I use Lodash in some of my projects. One of the nice features of Lodash is the chaining concept. If you have an object (often an array) which you want to transform usign a series of operations like map, filter etc. Now this is great – if it works. But what if it doesn’t and the result is completely unexpected? It would be nice if you were able to see the intermediate results of the chained operations without, so to speak, breaking the chain… It turns out you can!

2022-12-11

2022-12-05

  • 19:33 UTC (new) (history) 2022-12-05 A simple function to create abbreviations . . . . mbork A few days ago I wanted to write to a colleague about accessibility – or, as it is often called, a11y. As you probably know, the 11 comes from the fact that there are 11 letter between “a” and “y” in the word “accessibility”. Of course, I didn’t want to count the letters manually – I just marked the word, pressed M-= (count-words-region) and subtracted 2 from the result. Then it occurred to me that it is Emacs who should be doing things like that, not me.

2022-11-28

  • 17:05 UTC (new) (history) 2022-11-26 Extracting Youtube subtitles in Emacs . . . . mbork A few days ago I read about an amazing package. Like the OP, I very much dislike watching videos with lectures – text is much, much better way to communicate. (In fact, when I was a student, I preferred to skip lectures and learn from my colleagues’ notes instead. It was much more efficient.) I decided that I really need to try out youtube-sub-extractor.el. It turned out that it’s very easy to do so.

2022-11-19

  • 19:55 UTC (new) (history) 2022-11-19 Streamlining my workflow with Magit and BitBucket . . . . mbork We use BitBucket at our company, which is some source of frustration for us. One of the issues we have with BitBucket is that it seems to lack a decent CLI tool. This means that in order to e.g. create a pull request, you go to the website, click a few times and only then confirm that a PR is really what you want. Well, after some time I learned that it’s not that bad. When you git push your changes, Git (on the command line) responds with the URL you need to go to create a pull request out of the branch you just pushed. (This is most probably achieved via post-receive or some other Git hook.) Nice. Well, of course I don’t use Git from the command line – I use Magit. So naturally I wanted Emacs to extract that information for me and open the URL in the browser. It turns out that it was easier than I thought.

2022-11-14

  • 20:43 UTC (new) (history) 2022-11-14 Doubling backslashes . . . . mbork Today’s post is not meant to be very useful to most people, but it serves as a demonstration of a point (well, that, and a bit of advertisement;-)). However strange it may sound, a few days ago I have a very atypical need. I needed to move some LaTeX code to a JSON file. This meant that all the backslashes had to be doubled, of course – LaTeX code is full of them, and they need to be escaped in JSON. Obviously, query-replace​’ing backslashes with double backslashes is easy, and query-replace only operates on the region when it is active, but I wanted to make sure I didn’t replace them twice by accidentally marking too much. So – partly as an exercise, I guess – I decided to write a command to replace every backslash in the region by two backslashes, but only if it was a single one.

2022-11-07

2022-10-29

  • 10:16 UTC (new) (history) 2022-10-29 A bash helper for prefixed scripts . . . . mbork Let’s say we have some project we are working on. The project involves a number of shell scripts for various tasks, like versioning, building, testing, deploying etc. It is useful to have these scripts in your $PATH while working on that project. There are several ways to do that. One way is to add the directory containing them to $PATH, but only for the time we’re working on the project. Another is to use things like npm run and the scripts property of package.json (and I’m fairly sure many other languages feature similar facilities). Recently, I found yet another one, which is pretty useful and extremely cool at the same time. I prefixed all the scripts with the project’s (abbreviated) name, say dw-​. So, assume I have scripts like dw-version.sh, dw-build.sh, dw-test.sh etc. Now I can permanently add the directory containing them to my $PATH, since I (kind of) namespaced them and they won’t get mixed with any other project’s scripts (nor general use utilities). The only trouble that’s left is that typing dw- each time is a bit tedious. Well, Bash to the rescue.
  • 10:15 UTC (diff) (history) Comments on 2022-10-03 Converting words and sentences to identifiers . . . . mbork Correct, though in my use-case the phrase always starts with a letter, so I didn't need that.

2022-10-25

2022-10-24

2022-10-15

2022-10-10

  • 20:35 UTC (new) (history) 2022-10-10 Adding timestamps to youtube links . . . . mbork I sometimes keep YouTube links in my Org mode files. They are often links to lectures which I don’t usually watch in one sitting. One trouble I always have is remembering the point where I stopped watching last time and starting there. Obviously, I decided to write some Elisp to ease that task a bit.

2022-10-03

  • 21:07 UTC (new) (history) 2022-10-03 Converting words and sentences to identifiers . . . . mbork Preview: Some time ago I had a need to “convert” a phrase, or even a whole sentence, into an identifier. By “converting to an identifier” I mean lower-casing the whole thing and changing non-letter characters into underscores. For example, “Hello, world!” should become hello_world. I came up with some simple code to do that – but it turned out that there were some pitfalls I did not expect.

2022-09-26

  • 15:56 UTC (new) (history) 2022-09-26 Knex, PostgreSQL and bytea columns . . . . mbork Today I have yet another PostgreSQL-related tip. Some time ago I needed to put contents of some binary file into a bytea column, using Node and Knex.js. I couldn’t find any tutorials, so I decided to try to do the simplest thing and see if it breaks. To my astonishment, it didn’t – it Just Worked™!

2022-09-17

2022-09-12

2022-09-05

  • 18:53 UTC (new) (history) 2022-09-05 Comments in srt files . . . . mbork As I mentioned several times here, I do quite a lot of editing of srt subtitle files for videos. Sometimes I have problems when I translate subtitles into Polish, and then I usually ask native speakers about some obscure idiom or even more obscure (at least for me) cultural reference. In such cases, I figured I’d really like it if I could put comments into srt files to remember these places.

2022-08-27

  • 15:56 UTC (new) (history) 2022-08-27 Screenshots from Emacs . . . . mbork Some time ago there was a discussion on the Emacs mailing list about making screenshots from Emacs. From one of the posts there I learned about the x-export-frames function, whose existence is fascinating for me. It basically allows you to make a screenshot of your Emacs frame without ay external program, in one of several formats (including pdf and png). Jean Louis provided some simple code in that post which I reproduce here (with minor changes). The frameshot command takes a picture of your current Emacs frame, puts is in the frameshot-directory directory and moves the point to its line.

2022-08-22

  • 15:22 UTC (new) (history) 2022-08-22 The Emacs range package . . . . mbork Some time ago I discovered something really cool. It turns out Emacs has a package named range which can be used to operate on, well, ranges of integers. The truth is, it supports much more: arbitrary finite sets of integers.

2022-08-15

  • 05:54 UTC (new) (history) 2022-08-15 Personal accounting in Ledger . . . . mbork As I mentioned a few times, I use Ledger to keep track of my personal (actually, family) finance. While I definitely do not use the full power of Ledger (I don’t really need to), I find the very basic concept of double-entry bookkeeping extremely simple and elegant (in a mathematical sense).

2022-08-08

2022-08-01

2022-07-25

2022-07-18

  • 18:32 UTC (new) (history) 2022-07-18 Making some things more legible . . . . mbork Continuing the topic of one of the last posts, let me talk about another way to make dealing with a bank easier. In emails or web pages concerning payments people often have bank account numbers. Such a number consists (at least in Poland) of 26 digits. The first two are check digits, and the rest are the “basic bank account number”. Oftentimes people just paste the string of 26 digits, which is very difficult to read (and I sometimes do want to actually read the number, for example to make sure that two numbers agree). To solve that, it is customary to group these digits into sets of four (so the pattern is: two check digits and then six sets of four), divided by spaces. However, often I receive an email where there are just 26 digits lumped together. Let’s make them look better.

2022-07-11

  • 14:05 UTC (new) (history) 2022-07-11 A poor man's Emacs - Jira integration . . . . mbork I use Jira at work. (I know, I know. Actually it’s not that bad – at least it’s much better than Asana.) Of course, I also copy all my tasks to Emacs to clock them using Org-mode. A few days ago a teammate, seeing my Org file with all the Jira tasks, asked me how I pull them from Jira to Org. A bit embarassed, I told him that I’ve been just creating a new headline, typing the task id (like LT-1337) and copying the task title from Jira. This is not as bad as it sounds since it happen very rarely – say, once or twice per day, so automating this doesn’t really pay off. Still, it would be nice. So, I set out to do exactly that.

2022-07-02

  • 19:30 UTC (new) (history) 2022-07-02 Paying my bills with Emacs . . . . mbork I use Emacs to pay my bills. Literally. I mean, I use it in my day job, obviously, but it’s not what I’m talking about today. In Poland, the most often used way to pay bills like electicity, phone, internet etc. is via bank transfers. To make a transfer you need to type at least the account number of the person or company you transfer money to, the description of the transaction and (obviously) the amount you need to pay. To simplify things, I defined a few recurring recipients in my bank system so that I only need to choose the recipient and type in the invoice number (as the description) and the amount. Still, this is a bit cumbersome. And this is where Emacs can come in.

2022-06-24

2022-06-20

2022-06-13

  • 19:14 UTC (new) (history) 2022-06-13 Highlighting and de-highlighting things . . . . mbork From time to time I want to perform a kind-of “human search” on a file. For example, there is some keyword – or maybe something describable by a regex – and I want to be able to easily spot all of its occurrences in some file. For some reason, isearch or Swiper won’t work for me. (This may happen if, for instance, I don’t exactly know what I’m looking for. Imagine going through some file and deciding to search for some keywords only when I actually see them for the first time. So, I’m skimming a buffer and once I see the word “banana”, I go “hey, bananas are good, let’s find more of them” and then I want to easily see every line containing the word “banana”. Skimming further, I can see the word “apple” and I suddenly have a craving for apples, so I want to add apples to things that should be easily seen. And so on.) It turns out that Emacs has a few commands which can help with that.

2022-06-04

  • 07:04 UTC (new) (history) 2022-06-04 Diffing structural changes revisited . . . . mbork Two and a half years ago I blogged about diffing program structure changes. Since then I learned about a fantastic new diffing tool, called (very appropriately) Difftastic, by Wilfred Hughes, the author of many great Emacs packages I will definitely blog about some day.
  • 07:02 UTC (new) (history) difftastic-example.png . . . . mbork A simple example of using Difftastic (minor)

2022-05-29

  • 08:26 UTC (new) (history) 2022-05-29 A short hike in Polish . . . . mbork Dzisiejszy post jest nieco nietypowy, choćby z z tego powodu, że jest dwujęzyczny – co ma sens, zważywszy na jego temat. Today's post is rather atypical, if only because it is //bilingual// -- which makes sense, given the subject.

2022-05-23

  • 05:39 UTC (new) (history) 2022-05-23 Copying code snippets . . . . mbork Two weeks ago I wrote about copying stuff from Emacs to the system clipboard, converting from Org-mode to markdown along the way. Even earlier, I wrote a snippet of code to convert double spaces to single ones when copying. Let’s continue the thread of transforming stuff while copying it from Emacs.

2022-05-16

  • 10:50 UTC (new) (history) 2022-05-16 Two simple helpers for debugging Express.js applications . . . . mbork Sometimes, when debugging Express.js applications, it happens that one of the many middlewares for some route is misbehaving and either redirects to somewhere it shouldn’t, hangs or something like this, resulting in a 500. While it is possible to attach a debugger to Node.js, a good ol’ console.log is often an easy and fast way to find a culprit. Especially with this very simple middleware:

2022-05-09

  • 16:59 UTC (new) (history) 2022-05-09 My productivity system - implementation . . . . mbork Last year I wrote about the design of my personal productivity system, and promised to describe my implementation. I have to admit I am not very satisfied with it, but I’ve been using it for over half a year now and it works (well, sort of). Its main advantage is its simplicity – I only needed to wrote about 100 lines of Elisp to handle it. So, here is the idea.

2022-05-02

  • 16:47 UTC (new) (history) 2021-05-02 Org-mode to Markdown via the clipboard . . . . mbork Some time ago I have written about transforming stuff while copying it from Emacs to the system clipboard. Recently, I noticed that I sometimes write something in Org-mode only to subsequently copy it to some place which accepts Markdown formatting. So, I decided to write a simple function transforming the region in Org-mode syntax to Markdown.

2022-04-25

  • 15:08 UTC (new) (history) 2022-04-25 Calculating fuel consumption in Org . . . . mbork While I am a big fan of Org-mode, I admit that I don’t try to use it for everything. Having used it for over ten years now I am aware that it is not the answer to everything – not even everything related to time-management. That said, it has quite a few unique features which make it very well suited to some specific needs. Some time ago, I decided to make a very simple fuel consumption calculator. A natural choice for most tech-savvy people would be to use a spreadsheet. I thought, why not use Org-mode? So, I came up with this table.

2022-04-17

  • 05:09 UTC (new) (history) 2022-04-17 Easter 2022 . . . . mbork Another difficult time – not only because of COVID-19 (which hopefully seems to finally retreat), but now also war in Ukraine. I honestly cannot imagine what Ukrainian people live through. Though I also think about Russians – often, when someone hurts other people, the aggressor ends up suffering, too… Still, the Good News about Christ living yesterday, and to day, and for ever means that all suffering, however terrible, will come to an end. I pray for all the people suffering because of various reasons – which in fact means all people – and I hope to meet you all in Heaven some day. And even amidst all the suffering and pain we have this one reason for joy greater than all our troubles. Christ lives!

2022-04-11

  • 05:38 UTC (new) (history) 2022-04-11 pgrep, or what I do when Vagrant hangs . . . . mbork I use Virtualbox (via Vagrant) pretty extensively. Unfortunately, sometimes it just hangs. (Two cases when it tends to happen is when I put my laptop to sleep with the VM on or when I try to run too many things on the VM. Not every time, but often enough to be a nuisance – say, maybe once a month. And given that I regularly have uptime on the order of weeks – Emacs uptime, not computer uptime, mind you;-), though in my case it is usually almost the same), I don’t want to reboot the system. Unfortunately, in such situations even vagrant halt --force doesn’t help.
  • 05:37 UTC (diff) (history) Comments on 2022-04-04 Warning about trying to setq a non-existent variable . . . . mbork Well, a function would require me to quote the variable name (unlike {{{setq}}} and unlike my macro).

2022-04-04

  • 17:28 UTC (new) (history) 2022-04-04 Warning about trying to setq a non-existent variable . . . . mbork Some time ago I wrote about how I changed a value of one of Emacs’ internal variables to get the behavior I needed. As I mentioned, I submitted a bug report (apparently, I’m in a minority needing this, and I don’t expect it to be fixed in near future – but that doesn’t bother me much, since I have the workaround in place anyway). There is one thing that does bother me, though. If this bug gets solved at some point in time, and the variable js--declaration-keyword-re disappears (and some other one – without the two dashes – is created in its place), how do I know that?

2022-03-26

  • 12:29 UTC (new) (history) 2022-03-26 A nice use-case for pee . . . . mbork Well, sorry for the click-bait-ish title;-)… Of course I meant this pee. It is similar to tee in that it can “split” the input stream, but while tee directs it to a few files (by default to stdout and to the given ones), pee directs it to pipes. You can give it names of commands and it will run them in succession and feed every one of them its input. (Unlike tee, it doesn’t put it to stdout, so you need an explicit cat to achieve that.) Here is a nice use-case.

2022-03-21

  • 06:18 UTC (new) (history) 2022-03-19 Variable-width font in the modeline . . . . mbork Some time ago there was an experimental change on the master branch in Emacs, bringing “variable width” fonts to the modeline. The main problem with them is of course the fact that when a part of modeline on the left changed (even without changing the number of characters), the rest of it would “jump” because the width of the changed portion would not be constant anymore. Well, that is now fixed: such things now have a fixed width, so changing the modeline font to a variable-width one works very well.

2022-03-14

  • 16:47 UTC (new) (history) 2022-03-14 Proper indentation after a const in Emacs . . . . mbork A few days ago I decided to finally fix one of the issues I had with JavaScript indentation in Emacs (in the default js-mode – I use js2-mode, which delegates indentation to js-mode). When using const to declare variables, and the declaration not fitting in one line, the indentation of the next line was broken...

2022-03-07

  • 05:53 UTC (new) (history) 2022-03-07 Transient input method . . . . mbork A long time ago I wrote about my usage of the TeX inout method, which is great for entering mathematical Unicode characters not present on the keyboard. Of course, I don’t have it on all the time...

2022-02-28

  • 18:56 UTC (new) (history) 2022-02-28 A clever trick with psql copy and multiline select statements . . . . mbork For today, I have another PostgreSQL tip, which I admit is extremely niche, but useful nevertheless. As I mentioned a few times, I’m a big fan of psql. One of the nice things it has to offer is the \copy command. It is a very thin wrapper around SQL’s copy command, with an important change: it generates files on the local filesystem, and they are owned by the user who runs psql, not the postgres user (under whom the PostgreSQL server operates). However, \copy does not accept multiline queries, which is a pain if you have a long, nicely formatted query and you just want to feed it to \copy to get a result e.g. as a csv file.

2022-02-21

2022-02-12

  • 10:28 UTC (new) (history) 2022-02-12 tomato.el update . . . . mbork Last year I wrote about my pomodoro-like setup with Org-mode. Since then I tweaked that a little bit and decided to share the updated code.

2022-02-07

2022-01-29

  • 09:56 UTC (new) (history) 2022-01-29 Running a script before (and after) starting the psql prompt . . . . mbork And here I am again, with another PostgreSQL tip. Recently, I had a need of running psql interactively but executing some script first. Of course, this can be done from psql itself by saying \i some-script.psql, but let’s assume that I’d prefer for that to happen automatically, so that instead of typing psql at the shell prompt and then \i some-script.psql at the psql prompt I could just say psql-some-script.sh at the shell prompt and be done. The important thing here is that I want to run some-script.psql first and go to the psql prompt next.

2022-01-24

  • 16:26 UTC (new) (history) 2022-01-24 Journaling with Org-mode . . . . mbork OK, so let’s admit it. I’ve been journaling with Org-mode for more than 6½ years now. Every day (well, almost every day) I sit down and make notes of important things that happened that day.

2022-01-17

2022-01-10

  • 21:59 UTC (new) (history) 2022-01-10 Simple tmux scripting revisited . . . . mbork Some time ago I wrote about my (very simple) tmux script. Since then I started to like tmux even more, and in fact I tend to create a similar script for every major project I work on. Last time, however, I noted how the sleep part is very fragile (and less than elegant). Since then I realized that I do not need any advanced scripting to run command Y in tmux window B when command X in window A finishes its job. In fact, this is very simple, and I’m ashamed I didn’t think about it earlier.

2022-01-03

2021-12-24

  • 09:44 UTC (new) (history) 2021-12-24 Merry Christmas . . . . mbork It seems that it is already a tradition that I wish Merry Christmas to all my readers! Of course, as old-timers surely know, I’ll offer a decade of Rosary for you.

2021-12-18

  • 12:44 UTC (new) (history) 2021-12-18 Automatically starting Firefox with a clean profile . . . . mbork I am currently working on a side project, which is a very specific web application. One of the requirements is that several users should be able to be logged in simultaneously and interact with each other in real time. For the “real time” part, I use websockets (with the Socket.IO library, which is quite nice to work with). Today, however, I wanted to say something about a different thing: testing. Not automated testing (I will probably blog about it later, too), but good old manual testing. The trouble is, how do I log in as two (or more) users at the same time? I can’t use separate browser tabs, since they share cookies and logging in or out in one of them logs me in or out in all of them. It turns out that if you open several “private browsing” windows in Firefox, they all share cookies and similar data, too – that wasn’t obvious for me, but this is how it works. I could use separate browsers (say, Firefox and Chromium), but that is far from comfortable – and obviously scales very poorly. Of course, Firefox profiles are exactly what is needed here. They have one drawback: it takes a lot of clicking to create a new profile. (Also, you have to name it, keep track of your profiles, delete the ones you don’t need anymore…) So, let’s script it.

2021-12-11

  • 10:53 UTC (new) (history) 2021-12-11 My productivity system - design . . . . mbork Note: this is another of those really long posts. It’s probably only interesting for some productivity geeks, since it describes my current system for beating procrastination and making most of my time (or rather, one layer of that system). In a future post I’m going to write about some (Org-mode-based) tools I use to actually implement it, but for now I just want to show the main ideas – in fact, this system was first implemented with pen and paper, and in fact it worked very well that way.

2021-12-04

  • 07:59 UTC (new) (history) 2021-12-04 Org timer once again . . . . mbork I’ve been writing about the Org timer about a month ago, and today I’m revisiting this topic because once I started using it, I discovered a cool feature which is, let’s say, half-documented.

2021-11-29

  • 13:00 UTC (new) (history) 2021-11-29 Counting the number of columns in PostgreSQL . . . . mbork So I had this pretty big PostgreSQL table, and I wanted to know how many columns it had. Should be simple enough, right? Remember about using psql to show how some comands are converted to SQL? Well it didn’t really help me that much.

2021-11-20

  • 09:14 UTC (new) (history) 2021-11-20 Tricks with GNU date . . . . mbork Date- and time-related computations are hard – we all know this. Sometimes the problem is that there are many edge cases, sometimes the issue is conceptually hard, and sometimes both. Recently, I had an instance of a problem which was conceptually hard (at least for my little brain).

2021-11-13

  • 04:44 UTC (new) (history) 2021-11-13 y-or-n-p but with RET meaning yes . . . . mbork Today, I had an extremely specific need. I wanted the Elisp function y-or-n-p (which asks the user a yes-or-no question, expecting a one-key answer of y or n), but I wanted to interpret RET (or “Enter”) as “yes”. It turns out that by default it means “exit”, which is because y-or-n-p-map has no binding for RET, and y-or-n-p falls back on query-replace-map (in a rather convoluted way). So, here is one way I could change it:

2021-11-06

2021-11-05

2021-11-01

  • 19:23 UTC (new) (history) 2021-11-01 Org timer with sound . . . . mbork For today I have another tip. I often need to know when some amount of time has passed. I know about org-timer-set-timer, but I never got to using it because it only gives a screen notification, so it’s useless when you don’t look at the screen. Or so I thought. It turns out that you can set the variable org-clock-sound and have Org play the given file when the timer runs out. Great!

2021-10-25

  • 17:56 UTC (new) (history) 2021-10-25 debug-on-variable-change . . . . mbork Yet another short tip for today. (Don’t worry, longer, more involved posts will still happen here;-)!) A few years ago I wrote about a few useful debugging features of Emacs. A few days ago I learned that there are more of them now! About two years after I published that post, Emacs learned how to invoke the debugger every time some variable changes its value.

2021-10-18

  • 09:12 UTC (new) (history) 2021-10-16 The funniest bug I've seen in a pretty long time . . . . mbork I might be in the minority, but I actually do like debugging. It’s often like that sort of puzzle game (or an escape room;-)) where you need to find some hidden clues. And often at first you know nothing or very little, but then you gradually pinpoint the problem and finally find it. And sometimes I am really amazed at what craziness lies hidden in the code. Today, I want to share a recent story which I find almost unbelievably hilarious.

2021-10-11

  • 16:35 UTC (new) (history) 2021-10-11 Highlighting word differences when diffing . . . . mbork I have a short tip for today. Sometimes it is useful to diff two files (in terminal), highlighting the differences on the level of words. Apparently, GNU diff cannot do that – but Git can. Did you know that you can say git diff –word-diff=color <file1> <file2> even outside any Git repo?

2021-09-27

  • 20:18 UTC (new) (history) 2021-09-27 Ellipses in math - ldots versus cdots . . . . mbork It’s been a while since a TeX-related post here, but I still use TeX and friends once in a while, and this time I’d like to share something apparently not everyone knows about. LaTeX has a \dots macro, setting the ellipsis (three consecutive dots) which is just an alias for \ldots.

2021-09-20

  • 11:28 UTC (new) (history) 2021-09-20 Simple tmux scripting . . . . mbork I have recently started to use tmux instead of separate tabs in my terminal. I had a few reasons for this, one of them being that tmux is much more keyboard-oriented.

2021-09-13

  • 16:18 UTC (new) (history) 2021-09-13 A gotcha with PostgreSQL's jsonb type . . . . mbork As you may probably know, I am a big fan of PostgreSQL. That doesn’t mean that it’s always easy for me to use or intuitive, though. Today I ran into something strange (which is not that strange when you think of it, but still). Consider a table with a jsonb field, which sometimes has some key and sometimes not (which is the main point of having a jsonb field after all)

2021-09-06

  • 18:31 UTC (new) (history) 2021-09-06 My experience with book writing . . . . mbork This is a rather atypical post in that it is just a bunch of thoughts about how to write a book, how not to write a book, how I’ve been writing my book on Emacs Lisp, what was easy, what was difficult etc. If you want to write a book, it might be useful to learn where a fellow author struggled – note however, that this post reflects my personal experiences and your situation, personality, experience, work style etc. may be similar or completely different. Also, this post is quite long, and – let’s say – not extremely structured. It is just a collection of thoughts, some of which might be useful, entertaining or interesting to someone – or not. You have been warned;-).

2021-08-30

  • 04:14 UTC (new) (history) 2021-08-30 How I avoid deleting large parts of Org buffers accidentally . . . . mbork For today, I have a kind of obvious trick, but one that saved me a lot of trouble at least once. As many Emacs users, I am a heavy Org-mode user. However, one of the strengths of Org-mode is also one of its weaknesses. By default, it hides a lot of stuff from the user, in the sense of rendering them invisible (property drawers, folded parts of the tree etc.). This means that if I e.g. clock in and then accidentally call undo (effectively deleting my clock entry), it’s possible that I won’t notice that something is missing. Another thing I happen to press accidentally is C-c ;, which toggles the COMMENT keyword of the current entry – when I’m editing a long section of my book on Elisp, for instance, pressing C-c ; instead of C-c , (which is used to e.g. edit a source block) is pretty easy. Almost a year ago I decided to do something about it, and I came up with a primitive but working solution.

2021-08-23

  • 04:22 UTC (new) (history) 2021-08-23 grep and context lines . . . . mbork Sometimes (well, actually pretty often!) I need to search text files with grep. By default, it displays all the lines that are matched by some regular expression. As is usual with heavily-used and battle-tested shell commands, it has numerous well-though arguments, like -H and -h (print or suppress the filename prefix in every line), -n (print the line number along with the matching line) and many others. A few weeks ago, however, I had an extremely specific need, and I was very pleasantly surprised that grep supported precisely my use-case. I wanted to grep a log file having a particularly annoying format, and I wanted grep to display every match together with one preceding and two following lines. Well, it turns out that grep has such a feature, too.
  • 04:21 UTC (diff) (history) Comments on 2021-08-16 Remapping commands . . . . mbork Well, you're right – but still, they solve a very similar problem. At least I couldn't think about a real-life situation when only one of them would . . .

2021-08-16

  • 16:49 UTC (new) (history) 2021-08-16 Remapping commands . . . . mbork Several weeks ago I wrote about a nice feature of Emacs where you can bind some command to every key bound to another command in some (other) keymap. Since then, I found another feature solving the same (or at least a very similar) problem – command remapping.

2021-08-09

2021-08-02

  • 04:15 UTC (new) (history) 2021-08-02 Reordering sentences in Emacs . . . . mbork I’m probably in a minority, but I am a heavy user of Emacs’ transpose-* commands, most notably transpose-words and transpose-chars. This is probably because I have spent a lot of time editing texts in Emacs – not writing, but editing, and wrong order of words is a very common mistake I often needed to fix. One problem with transpose-words, though, is that it can only swap two words, usually two adjacent ones
  • 04:12 UTC (new) (history) reorder-sentence.gif . . . . mbork A screencast showing sentence reordering (minor)

2021-07-26

  • 06:10 UTC (new) (history) 2021-07-26 Binding a command to every key bound to another command . . . . mbork For today, I have an extremely specific Emacs Lisp tip – this is definitely not something you would use every day, but when you need it, it’s there. Assume that you are writing a mode (call it cool-mode), which should support some general Emacs command (call it do-something) – only the workings of this mode are so specific that this command should be basically written from scratch instead of using Emacs’ own do-something. You could (of course) advise do-something, but it seems cleaner to define cool-do-something instead. How do you bind it to the same keys it is normally bound to in Emacs? For bonus points, the user might have its Emacs customized (with global-set-key, for example) to bind do-something to a key of their choice.

2021-07-12

  • 21:18 UTC (new) (history) 2021-07-12 Counting business days . . . . mbork A need that I sometimes have is to know how many business days are there in a given month. It is not difficult to code a suitable function, but it is probably worth knowing that you really don’t have to: Emacs has you covered! Well, almost…

2021-07-03

  • 17:10 UTC (new) (history) 2021-07-03 Emacs Lisp book - contents . . . . mbork As you probably know by now, I am writing an intermediate textbook on Emacs Lisp, entitled Hacking your way around in Emacs. Last time I mentioned that I’d like to write something about the contents of the book. So, here it is. (Keep in mind that things may still be subject to some changes, though – the newest of them came to my mind today in the morning!)

2021-06-28

  • 18:03 UTC (new) (history) 2021-06-28 Going to where you were when visiting a file . . . . mbork I don’t close my Emacs very often. Basically, I start it right after I turn my computer on and log in, and usually the only reason for me to close Emacs is when I update the system (given that use Arch Linux, this is actually pretty often, say once every week or two). Usually, after a few days’ worth of work, I have most of files I work on open, and I’m accustomed to just switching to a suitable buffer to continue something at the point I left it a day (or several days) ago. Of course, I lose that information when I close Emacs.

2021-06-21

  • 09:28 UTC (new) (history) 2021-06-21 fx - a terminal JSON viewer . . . . mbork Some time ago I had a need to dig (interactively) into a deeply nested JSON. While I know and use json-navigator, sometimes I’d like to have something similar in the terminal. After a short search, I found fx, which is similar to jq, but has an awesome interactive mode.

2021-06-14

  • 19:35 UTC (new) (history) 2021-06-14 New behavior of yank-pop . . . . mbork I have another short Emacs tip for today. Quite recently (well, in November 2020, which – given the scale of Emacs history – is pretty recently, but I only learned that a few weeks ago or so) the yank-pop command (bound to M-y by default) acquired a very cool new feature. Its main use is (and has been for decades) to cycle through the kill-ring right after the yank command (C-y). It was one of the things that made Emacs a sophisticated editor and not a toy. Of course, M-y did nothing if pressed not immediately after C-y or another M-y, since what it could do then? Well, it’s obvious, isn’t it?

2021-06-07

  • 03:52 UTC (new) (history) 2021-06-05 Emacs Lisp book update – what the book is going to look like . . . . mbork About a month ago I decided to write about the book on Emacs Lisp I am writing. I also made it available on Leanpub where you can download the first chapter and pay me to get the (roughly) 40% of the book that is already written. This post is the first in a series of updates I plan to publish about once per month. Read on if you are curious about the process of writing a book, or want to learn if it is for you, or want to actually help me to write it! First of all, I’d like to thank all the people who trusted me so far and say that I was surprised and humbled to have so many of you. Now I feel even more encouraged to stick to my writing schedule.

2021-05-30

  • 16:55 UTC (new) (history) 2021-05-30 Extending subed-mode . . . . mbork Some time ago I mentioned the subed-mode, Emacs mode for editing srt files with movie subtitles. Well, I’ve been using it regularly for more than half a year now, and I used it to translate more than 20 hours of material into Polish, spending more than 100 hours on it altogether. (And before you ask, this is – again – a hobby/amateur project for my family, not even published.) I think I can safely say that I know quite a bit more about subed-mode now – for instance, I now know that it supports playing the video and actually syncing it to the subtitle at point (with some margins, of course), which is absolutely great. It had some shortcomings, though.

2021-05-29

2021-05-24

  • 04:37 UTC (new) (history) 2021-05-24 Ivy and ignoring the order of tokens . . . . mbork Emacs function naming is strange. I rediscovered that fact a few weeks ago when I tried to find a function giving me the position of the beginning of the current line. I tried to look for a function whose name would match begin.*line, and there was none. I concluded that there is no such function (which was strange, but I learned not to be surprised that often), and proceeded to write my own. After some time I found out that such a function obviously exists, and that it is called… line-beginning-position. Oh well.

2021-05-17

  • 19:43 UTC (diff) (history) Comments on 2021-05-01 Emacs Lisp book revived . . . . pkd The RSS feed is great, thank you!
  • 19:33 UTC (new) (history) 2021-05-17 Updating an Emacs buffer in real-time . . . . mbork I am in the process of writing some Elisp code which needs to provide feedback to the user about a certain aspect of the state of the buffer. (This is a bit vague, I know, but the whole thing is not yet blog-ready – sorry for that. And since it is a fair amount of code, I won’t be blogging about it in detail when it’s done, so I decided to share one or two things if they are potentially interesting.) The point is that every change to the buffer’s content may change that aspect, and computing it may be a bit expensive. The problem is, how to do that efficiently?

2021-05-10

2021-05-09

  • 13:37 UTC (new) (history) 2021-05-08 Disabling distractions . . . . mbork Like many other people, I have to fight with distractions a lot. The main distractors (at least when I work on my computer) are a few websites that rhyme with “litter”, “space crook” and “poo cube”. Some time ago I decided that I need to take brutal action against them, and I put this in my /etc/hosts file:

2021-05-01

  • 08:40 UTC (new) (history) 2021-05-01 Emacs Lisp book revived . . . . mbork Five and a half years ago I mentioned that I was writing an intermediate book on Emacs Lisp programming. Unfortunately, the project started – and then stalled for quite some time.

2021-04-26

  • 05:34 UTC (new) (history) 2021-04-26 Binding a command to what is normally a prefix key . . . . mbork Some time ago, someone on the help-gnu-emacs asked how to rebind f2 so that it sets the default major mode for the current buffer. (The use case was that he wanted to change the mode of a buffer to perform some task, and then have an easy way to return to the “default” mode, based on the normal way Emacs uses to choose the major mode. That normal way is indeed a bit tricky.)
  • 05:33 UTC (diff) (history) Comments on 2021-04-17 Multiple Help buffers . . . . mbork 1. Thanks for the hint about {{{rename-uniquely}}}, I forgot about it. 2. As for the second comment - you have to have something to diff first, so . . .

2021-04-17

  • 13:22 UTC (new) (history) 2021-04-17 Multiple Help buffers . . . . mbork When using many Emacs’ help commands (like C-h f, or describe-function), we are presented with the *Help* buffer. It has some basic navigation commands, most importantly forward-button (TAB), hepl-follow (RET), help-go-back (l) and help-go-forward (r), and usually they are enough for me. Some time ago, however, I had a very specific need which could not be achieved by any of them.

2021-04-10

  • 07:52 UTC (new) (history) 2021-04-10 deactivate-mark . . . . mbork Emacs Lisp has two entities called exactly the same – the deactivate-mark function and the deactivate-mark variable. (This is possible at all because Elisp is is a Lisp-2.) As the name suggests, they both serve the same purpose (or rather a similar one), but there seems to be a subtle difference.

2021-04-04

  • 03:37 UTC (new) (history) 2021-04-04 Easter . . . . mbork Christ is risen! So, happy Easter for everyone! I’m looking at my Easter post from a year ago, and I stand by everything I said then.

2021-03-27

2021-03-20

  • 07:31 UTC (new) (history) 2021-03-20 Using index in the Emacs Info viewer . . . . mbork Recently I was looking how to use the index in the Emacs Info viewer. First of all, let me mention that it is really, really great, and I would love it if more software used this format. Imagine having all MDN Web Docs within Emacs – no network latency, everything available without even touchning the mouse… Or even better – the whole DevDocs project… Now that I think of it, I guess writing a tool to automatically convert it should not be too difficult to write – any volunteers? Anyway, let’s get back to reality. The index.

2021-03-15

2021-03-07

  • 07:57 UTC (new) (history) 2021-03-07 A directory name as a command-line parameter for Node.js . . . . mbork Some time ago I accidentally discovered a neat feature of Node.js, which seems undocumented (at least I could not find anything about it in the docs). If you have some npm project in a directory, say /tmp/some-npm-project, and it has the main property in package.json set to some Node.js script, say bin.js, then saying just node /tmp/some-npm-project runs /tmp/some-npm-project/bin.js. It turns out to be quite useful if you have a directory full of various Node.js CLI utilities, each occupying its own directory, with its own package.json, especially considering shell autocompletion. And that’s it for today!

2021-02-27

  • 09:44 UTC (new) (history) 2021-02-27 Visible bell in Emacs . . . . mbork Emacs has this habit of beeping when something goes wrong (or when the user presses C-g). Frankly, this is quite useful, since it is an instant feedback, but there are times when I don’t want that behavior.

2021-02-23

2021-02-20

  • 09:00 UTC (new) (history) 2021-02-20 Using keyboard macros to emulate query replace . . . . mbork A few days ago, however, I needed to do something I consider really blogworthy, even though the tip I’m going to share today is (surprise, surprise!) very Emacs-centric. I was editing a paper which used italics (with the \emph LaTeX macro) really a lot (more than 100 times). Very many (but not all) of its occurrences were to be changed to quotes, so that e.g. \emph{petrichor} should be changed to ,,petrichor’’ etc.

2021-02-13

  • 15:44 UTC (new) (history) 2021-02-13 Copying to clipboard with single spaces . . . . mbork I sometimes need to transfer some text from Emacs to another program, like a web broswer or terminal. A few weeks ago I thought that it would be nice if I could somehow transform that text – mu use-case is changing double spaces (which I habitually put after every sentence, so that I can use Emacs’ sentence-aware commands) to single spaces (which is what most people expect, and some people treat as the only correct option).

2021-02-06

2021-02-01

  • 10:07 UTC (new) (history) Comments on 2021-01-25 Generating consecutive dates in Unix shell . . . . Anonymous You don't need the grep, just use the output formatting in date: for d in `seq 0 7 36`; do date -d "2020-01-05 $d days" +"%A%t%d-%m-%Y"; done . . .
  • 08:06 UTC (new) (history) 2021-02-01 Copying symlink targets in Dired . . . . mbork I have a short but pretty useful tip today for everyone who uses Dired as their main file manager (which I do, of course). When copying symlinks using dired-do-copy (bound to C by default), Dired copies them as symlinks. Giving a prefix argument of C-u makes dired-do-copy dereference the symlink first.

2021-01-25

  • 11:26 UTC (new) (history) 2021-01-25 Generating consecutive dates in Unix shell . . . . mbork It is no surprise for any regular reader that I have a kind of love-hate relationship with the shell. Bash is one of the most terrible languages out there, but sometimes writing a short shell snippet is just handy. This was the case some time ago, when I wanted to loop over several dates.

2021-01-17

  • 19:08 UTC (new) (history) 2021-01-17 Królowa Magnolii I . . . . mbork No to dzisiaj coś z zupełnie innej beczki. Kilka dni temu skończyłem czytać tom I Królowej Magnolii Marty Marii Dobrzyńskiej. Najkrótsza recenzja, jaką potrafię napisać, ma trzy litery. Wow.

2021-01-11

  • 15:09 UTC (new) (history) 2021-01-11 Deleting last entry from the kill ring . . . . mbork The Emacs’ kill ring is a brilliant and extremely useful concept. It has some drawbacks, too, though. Probably the biggest one is that the entries there persist for quite some time. This is, after all, what it’s for – but sometimes you explicitly want some entry to disappear. This is of course the case when you have some password or a similar thing you copy to e.g. config files.

2021-01-04

2020-12-24

  • 07:58 UTC (new) (history) 2020-12-24 Christmas 2020 . . . . mbork As usual, the time has come for Christmas wishes to all my readers. Frankly, I have no idea how many of you there are, since I do not track you in any way. But I know that there do exist people who read my blog, and to them I say thank you, and God bless you. (According to my now several-years-long tradition, I will offer a decade of Rosary for you as my Christmas gift!) And please notice this: Jesus, our Lord and Savior, is just so reliable. There may be the epidemic, lockdown, there might even be war, famine or whatever – but He will come to save us. I find it extremely reassuring. Also, this time I’d like to say a bit more than just wishes.

2020-12-21

  • 19:12 UTC (new) (history) 2020-12-21 Pretty printing json and jsonb columns in PostgreSQL . . . . mbork And for today I have yet another short PostgreSQL tip. I use a database which has quite a few tables with jsonb – and also json – type fields. (I know, I know. No new json columns, but legacy etc.) Since they often contain quite a few things, pretty printing them is something I tend to do fairly often. Happily, PostgreSQL has a function to do that. Less happily, it only works with jsonb columns, and has a long, awkward name: jsonb_pretty. But it’s no longer a problem for me, since it is easy to create a shorthand.

2020-12-14

2020-12-07

  • 22:02 UTC (new) (history) 2020-12-07 Temporary PostgreSQL tables . . . . mbork Today I have yet another small PostgreSQL tip. Sometimes you want just to experiment a bit, or maybe move some data around a bit, and then you may have the idea “ok, so I’ll just create this table, do something with it, and then drop it”. Well – you don’t have to drop it.

2020-11-30

  • 21:43 UTC (new) (history) 2020-11-30 Repeating complex commands . . . . mbork Today I learned about a fantastic Emacs feature I had no idea about. I knew that the key C-x z is bound to the repeat command, which, well, repeats the last (simple) command – I even use it from time to time. I had no idea, however, that there is another command which can repeat “complex” commands – i.e., ones that use the minibuffer to accept some input.

2020-11-23

  • 10:52 UTC (new) (history) 2020-11-23 Emacs and the X selection . . . . mbork One thing I have been reading about lately is the interaction between Emacs and the outside world via the clipboard. Of course, Emacs predates the clipboard by a lot, but it interacts with it pretty nicely. I have a blog post about that in the works, but it’ll need a bit more work, and I’m really busy now (again…), so for today I only have a short tip.

2020-11-16

2020-11-09

2020-11-01

  • 21:51 UTC (new) (history) 2020-11-01 The situation in Poland . . . . mbork I really planned to post something else today (I even have written something about Bash redirection – it will just wait one or two more weeks). But the situation in my country, well, escalated quickly, and I think a few sentences of comment are very much in place.

2020-10-26

2020-10-23

2020-10-18

2020-10-13

2020-10-12

  • 04:58 UTC (new) (history) 2020-10-12 Editing subtitles in Emacs with subed . . . . mbork Some time ago I bought a DVD with one of my favorite movies of all time. (I am not really a movie person, but I like to watch some film once or twice a year.) Unfortunately, the film is only available in English, and I really wanted my daughter (who doesn’t speak it yet) to watch it with me. I set out to translate all the dialog to Polish (which was quite a challenge, and I am proud to say that I managed to do that – better or worse, sometimes perhaps inevitably worse, but still). Now what I need is to prepare subtitles for the film. It turns out that the industry standard is called srt, and – not that it is surprising – Emacs has a suitable mode.
  • 04:56 UTC (new) (history) tpb-subtitles.png . . . . mbork

2020-10-05

2020-09-27

  • 19:38 UTC (new) (history) 2020-09-27 Pretty printing SQL queries . . . . mbork I often work with SQL queries. Sometimes I write them myself, sometimes they are created by an ORM – in either case, they are sometimes pretty long. This means that it would often be nice to have them formatted in a nice way (I mean indentation and line breaks).

2020-09-20

  • 10:00 UTC (new) (history) 2020-09-20 A simple trick with Textern and require-final-newline . . . . mbork I have been using the Textern add-on for Firefox for quite some time now. What it does is it lets you press some key combination while being focused on a textarea element and start editing it in an editor of your choice. Of course, the editor of my choice is Emacs (well actually, Firefox thinks it’s emacsclient, of course). However, there was one thing that annoyed me.

2020-09-14

  • 07:46 UTC (new) (history) 2020-09-14 amsreftex – a long-expected package . . . . mbork I have been a long time user of the amsrefs LaTeX package. I am also an avid fan of the AUCTeX Emacs package. Unfortunately, the two don’t get along very well with each other – AUCTeX has RefTeX, which assumes that the bibliographies are done with BibTeX (and possibly also works with BibLaTeX). This makes RefTeX basically useless for me. And that was the situation until a few days ago.

2020-09-05

  • 06:01 UTC (new) (history) 2020-09-05 Better look of the ivy-occur-grep buffer . . . . mbork Continuing the trend of short tips due to lots of work I have nowadays, here is one thing that bothered me for some time and how I fixed it. I use Ivy and Counsel a lot. One of the functions I have even bound to an easily accessible key is counsel-rg.

2020-08-31

2020-08-24

  • 20:24 UTC (new) (history) 2020-08-24 Sorting object keys with Lodash . . . . mbork I have been extremely busy recently, so I have only a short tip today. Imagine having a JavaScript object like this: { a: 1, b: 3, c: 2, } and needing to have an (almost) identical object, but sorted by increasing values. (Yes, I know that theoretically the order of object properties does not matter and should not be relied upon, but come on.)

2020-08-17

2020-08-10

2020-08-03

  • 14:55 UTC (new) (history) 2020-08-03 Look up a global variable in the database in Node.js . . . . mbork Today I encountered an interesting problem. Assume that you want a global constant in your Node.js backend, but its actual value is to be taken from a database. This means that fetching the constant should be done asynchronously. Unless you use Node.js 14.3.0 or newer (which as the time of me writing this is not yet ubiquitous), you cannot await your database request at the top level

2020-07-26

  • 08:05 UTC (new) (history) 2020-07-26 Running Node.js scripts from the command line . . . . mbork A few days ago I accidentally ran Node.js from the command line with a wrong argument. I had a script – call it myscript.js – in a directory called myscript. I typed node mys in the directory one level higher, pressed tab and ended up with node myscript/, then pressed enter and got an error (obviously). So, I then cd​‘d into the right directory and (without much thinking) pressed up twice and enter. To my surprise, the script ran. What is going on?

2020-07-19

2020-07-13

  • 20:42 UTC (new) (history) 2020-07-13 Miller - a csv Swiss Army knife . . . . mbork I often need to work with csv files. Until recently, my go-to tools to do most things with them were Emacs with csv-mode (when I need to interactively edit simpler csvs, LibreOffice (when I need interactivity and more complex things, like multi-line cells, which are not supported by csv-mode), and xsv (when I need to automate some transformations, like selecting a subset of columns, changing the order of columns and other things). Some time ago, I learned about another csv-related tool: Miller.

2020-07-06

  • 17:51 UTC (new) (history) 2020-07-06 Auto renaming image files . . . . mbork Like probably everyone else, I have lots of pictures from digital camera(s). Cataloging them is basically a nightmare, and I lost any hope for doing that manually a long time ago. But why not make the computer do as much work as possible?

2020-06-27

  • 11:51 UTC (new) (history) 2020-06-27 Selective display . . . . mbork A few days ago I was working with some large JSON files. The top level of the file contained a large array, and each of its elements was a large object consisting of numbers, strings and other objects. I needed to work with a few elements at the top level of those objects, and did not want the lower-level objects to get in the way. In other words, I needed to hide them somehow.

2020-06-22

  • 21:03 UTC (new) (history) 2020-06-22 lodash iteratee shorthand . . . . mbork As is widely known, JavaScript is a language with good semantics, not-so-good syntax and a terrible standard library. There are a few modules that aim to help with the last part, and lodash is one of them that I happen to use. It is a very nice thing, but is not necessarily easy to learn for newcomers. One of its nice features is so-called “iteratee shorthand”, mentioned many times in the docs. What is that? Well, Lodash has (among many others) the _.iteratee function. It accepts one argument and returns a function. If the argument is a function, _.iteratee just returns the same function – nothing interesting (and if given null, it returns the identity function). The first interesting thing happens when the argument is a string or an integer.

2020-06-15

  • 20:51 UTC (new) (history) 2020-06-15 Emacs, Org-mode, Beeminder and pomodoros . . . . mbork As some of my readers probably know, I am a happy user of Beeminder, and I even wrote my own Emacs- and Org-based Beeminder client. For some time, I’ve been thinking about somehow incorporating the famous pomodoro technique into my productivity quiver. The problem was, I did know how exactly to do it. Until today.

2020-06-08

  • 20:11 UTC (new) (history) 2020-06-08 Emacs as a (very simple) CAT . . . . mbork From time to time, I need to translate something (usually from English to Polish). Being an Emacs user, I obviously do the typing in Emacs. However, translating – as opposed to writing – has its own set of challenges. One of them is that I need to have two texts on the screen, and track my positions in both. While the “current position” in the active window is clearly marked with the point, this is not that helpful in the “other window” – while the point is visible there, it is usually not very prominent (even if you customize the cursor-in-non-selected-windows variable, which see). You probably expect where this is going to. Yes, I’m going to write such a tool myself.

2020-06-01

  • 06:20 UTC (new) (history) 2020-06-01 Node modules working as command-line scripts . . . . mbork Recently, I wanted to run one Node.JS CLI script from another. Of course, being in a hurry and KISS and whatnot, I decided to just use child_process.execFileSync with node as the first argument, but this is of course grossly inefficient. What if I could write a module usable both from the command line and other code? Well, it turns out that not only is this doable, but actually easy and robust.

2020-05-24

  • 08:17 UTC (new) (history) 2020-05-24 Two parameters and at least one required in yargs . . . . mbork I happen to write shell scripts in Node.JS quite often. They usually consume some kind of command-line agruments, and my library of choice to parse them is yargs. Recently, I had a situation where there were two parameters and it was required that one of them is given. A bit surprisingly, yargs does not seem to have an option requiredAlternative or something that says “of the following two parameters, at least one must be given” (it has a conflicts method and option, either of which can be used to say “of these two parameters, at most one may be given”, though). Happily, there is a simple way to enforce such a requiement due to the quite general “check” method.

2020-05-18

  • 20:19 UTC (new) (history) 2020-05-18 entr, a wrapper around inotify . . . . mbork Shortly after my post from last year describing how I use inotifywait to start programs on file change, one of the readers emailed me about an utility called entr. It is an extremely simple-to-use tool which just gets the filelist to watch on stdin and a command to execute when any of the files changes as CLI arguments – and that’s pretty much it. (That does not imply it is simplistic – according to its website, it performs some non-trivial stuff under the hood.) Thanks!

2020-05-11

  • 20:37 UTC (new) (history) 2020-05-11 Diffing and font-lock . . . . mbork I often work with diffs in Emacs. I usually do that within Magit, which highlights diffs in the usual way (highlighting deleted lines with reddish background, inserted lines with greenish background, and the deleted/inserted characters within these lines with slightly more prominent versions of the same colors). However, I sometimes use plain Emacs diff (e.g. to compare two fles not kept in Git), and I noticed an annoying thing: diff’s font-lock is applied on top of the usual font-lock, depending on the files’ syntax. While in general this seems resonable, in the case of LaTeX files in AUCTeX (where the font lock colors are especially diverse) this makes the diff completely unreadable. I was pretty sure that disabling the syntax font-lock would reduce the visual noise of the diffs.

2020-05-03

  • 07:08 UTC (new) (history) 2020-05-03 Help in read-string . . . . Marcin Borkowski Last week I wrote about making Emacs ask for parameters for lp when printing from pdf-tools. The only thing missing was some kind of help for lp, which is far from intuitive. I figured that it would be best if I could somehow make read-string display some help string when some key was pressed, even in the midst of editing in the minibuffer. (Preferably, the key would be C-h, which is Emacs’ default for “help”.) And guess what? This is Emacs. Not only is such a feature possible, it is actually built-in!

2020-04-27

  • 09:39 UTC (new) (history) 2020-04-27 Printing from pdf-tools . . . . Marcin Borkowski Some time ago I studied the command-line interface to CUPS. Of course, my goal from the beginning was to use Emacs, not the terminal. It turns out that setting the default printer using lpoptions is not enough for pdf-misc-print-document (bound to C-c C-p in pdf-tools) to work. This command tries first to locate one of three tools for command-line printing: gtklp, xpp and gpr. Frankly, I’ve never heard about any of them, and I just wanted to use lp. This is easy to accomplish – you just need to set the variable pdf-misc-print-programm (sic!) to "lp" and you’re good to go. However, what about my 2-up printing?

2020-04-18

  • 12:06 UTC (new) (history) 2020-04-18 The main line of history of some branch . . . . Marcin Borkowski Some time ago, it occurred to me that it would be cool to be able to see the history of some branch of my Git repository – say, develop – but filtered so that I could only see the commits done directly on develop (which do not happen very often) and merge commits indicating that some feature got merged into develop, but without the individual commits. This could then serve as a poor man’s changelog - a list of features committed to develop since e.g. last tagged version.

2020-04-12

  • 07:32 UTC (new) (history) 2020-04-12 Easter 2020 . . . . Marcin Borkowski According to the tradition of my blog, I wish everyone reading this Happy Easter. May the Christ Risen give you His graces every day, and I wish you deep faith in Him. Do not forget that He is stronger than economic crises and physical or mental illnesses. This is no surprise, since He is in fact stronger than something much more serious than that – He defeated all our sins combined. In other words, we have all the right reasons to sing with joy, even if there are also some reasons to cry. As usual, I am going to offer a decade of the Holy Rosary for all my readers. God bless you all!

2020-04-07

2020-03-28

  • 18:40 UTC (new) (history) 2020-03-28 psql as a PostgreSQL teacher . . . . Marcin Borkowski A week ago, one of the commenters of my post from two weeks ago asked about the way to do stuff like \d (“describe table”) or \l (list the databases) etc. from SQL blocks in Org-mode. Well, the answer is – rather expectedly – “this is PostgreSQL, of course it’s possible”. Here’s how psql can teach you how to do it.

2020-03-23

  • 22:14 UTC (diff) (history) Comments on 2020-03-09 Using Org-mode as a PostgreSQL client . . . . Marcin Borkowski Hi, thanks for all the comments! I'm very busy now, but I will address them in another post in a week or two -- stay tuned!
  • 22:11 UTC (new) (history) 2020-03-23 A rebase trick with disappearing commit . . . . Marcin Borkowski Today, while working with Git, I discovered a very nice feature. I was working on a dedicated feature branch. Suddenly I discovered a bug which had to be fixed in order for that feature branch to make sense. However, the bug was not really connected with the feature I was working on. Well, it was connected in a sense, but it could affect other things as well, and I decided it should be fixed much earlier than I could possibly finish working on that feature – in other words, it deserved its own branch, based on the develop branch. So, I stashed my work, switched the current branch to develop, created a fixbug branch, fixed the bug, created a merge request and asked a colleague to review it. But here’s the deal: I could not work on my feature without that particular bug fixed. On the other hand, I wanted my feature branch to be based on develop and not on some other, random branch (well, that would work, but I like the history to be as clean as possible). What to do?

2020-03-16

  • 20:28 UTC (new) (history) 2020-03-16 COVID-19 . . . . Marcin Borkowski It seems that everyone is talking about the COVID-19 pandemic now. Well, I decided to jump the bandwagon with a PSA. As all long-time readers of my blog know, it is a small tradition here to offer a decade of Rosary for all my readers on occasions of Easter and Christmas. I figure that a situation of life-endangering pandemic is a perfect opportunity to remember about prayer, so I am going to do the same also today.

2020-03-09

  • 08:12 UTC (new) (history) 2020-03-09 Using Org-mode as a PostgreSQL client . . . . Marcin Borkowski I often have to write more or less complex SQL queries. In case of the easy ones, there is no problem – I just write them and that’s it. With more complex queries, however, it is very useful to adopt an incremental technique – writing them piece by piece. One of the best tools for such “incremental programming” is of course the REPL. In case of SQL (PostgreSQL in my case), this is usually solved with psql. While it has lots of nice features, editing a multiline query within it is not the nicest experience in the world. My first attempt to solving this problem was to use psql​‘s \e command. If given in the line on its own, it launches the default system editor with the previous query. While the readline library used by psql is fine, it is not very helpful in case of long, multiline queries – in such a case, a real editor like Emacs or Vim (or even a toy editor like everything else;-)) seems much better. After some time, however, I had an even better idea.

2020-03-02

  • 21:10 UTC (new) (history) 2020-03-02 PostgreSQL on Docker . . . . Marcin Borkowski Lately, I’ve been experimenting with PostgreSQL a lot. It is of course convenient to be able to set up a temporary database to play around. I didn’t want to do it directly on my laptop. One solution was to use Virtualbox (with Vagrant). This is a nice way, and it is even apparently officially supported. (Go to the linked wiki page to learn about various possible reasons why you might want to run PostgreSQL in a VM.) However, I also wanted to try something different. I am completely new to Docker, and I figured that setting up PostgreSQL in Docker would be a good way to start introducing myself to this technology.

2020-02-24

  • 19:44 UTC (new) (history) 2020-02-24 Some psql tips . . . . Marcin Borkowski I have to admit that I’m more and more enamored by PostgreSQL. Since I often use its default client psql, I started searching the Internet for some features I’d like it to have – and I wasn’t disappointed.

2020-02-17

2020-02-10

  • 19:14 UTC (new) (history) 2020-02-10 My first steps with Lua . . . . Marcin Borkowski Well, the title of this post is a misnomer – I am already well past my first steps with Lua, since I’ve written a few (admittedly, very simple) Lua scripts. In the near future, though, I’d like to play around with Lua a tad more seriously. (I still do not have a lot of spare time for that, but we’ll see how it goes.) One thing I missed when I tried Lua last time (it could have been a year or so ago) was a feature found in Node.JS’s npm package manager.

2020-02-02

  • 08:38 UTC (new) (history) 2020-02-02 Encrypted Org-mode journal . . . . Marcin Borkowski I use the Org-mode capturing feature to write a daily journal, where I record various important events in the case I’m going to need the information about them. Some time ago it occured to me that encrypting that journal could be a good idea, so I decided to explore that possibility.

2020-01-27

  • 22:17 UTC (new) (history) 2020-01-27 Splitting a past commit in two, and a bonus regex trick . . . . Marcin Borkowski More than a year ago I described a very simple Git rebase workflow, where all we were interested in was just fixing some mistakes in a past commit. Let us now go a little bit deeper. One thing I had always trouble with was splitting a commit in two (or more). While there are many tutorials about this on the internet, I wrote my own, even though it turned out that it is not better than the other ones. Go figure. (One advantage is that I have it on my website, so that I won’t need to do much searching in case I need it.)

2020-01-19

  • 17:51 UTC (new) (history) 2020-01-19 tldr . . . . Marcin Borkowski For today, I only have a short tip. Some time ago, I discovered this little gem called tldr. This project aims at creating an example-based alternative to man pages. It comprises several hundred short pages containing a short, one-line introduction to the command explained and a bunch of examples.

2020-01-13

2020-01-06

  • 09:08 UTC (new) (history) 2020-01-06 Org agenda statistics, part I . . . . Marcin Borkowski Some time ago I wrote about the org-batch-agenda macro. I decided to finally put it in good use. My goal is to write a command-line tool (or alternatively, an Emacs command) displaying some statistics about my pending tasks. However, for that I needed to solve two (minor) problems.

2019-12-24

  • 14:14 UTC (new) (history) 2019-12-24 Christmas 2019 . . . . Marcin Borkowski So, it’s Christmas Eve again! Thanks be to God for His mercy and coming to us as the Child! This year, I have special reasons to be thankful, since my family got through a difficult time of serious illness of one of us. I am sure every one of my readers has something to thank for – don’t hesitate to kneel before God the Almighty, his Son Jesus Christ and the Holy Spirit and thank! As usual, my Christmas present to all my readers is a decade of Rosary for you.

2019-12-23

  • 15:01 UTC (new) (history) 2019-12-23 Counting sentences in emails . . . . Marcin Borkowski Some time ago I wrote about sentence counting in Emacs buffers (or regions). I promised a sequel, and here it is. The real reason to count sentences is that I wanted to be able to automatically put a signature in my email referring to one of the http://sentenc.es/ webpages. It turns out, however, that counting sentences in email messages is much more difficult than it seems.

2019-12-16

2019-12-07

  • 10:06 UTC (new) (history) 2019-12-07 Dollar-quoted strings in Bash . . . . Marcin Borkowski As we all know, bash is a terrible but ubiquitous thing. Nowadays I usually avoid writing bash scripts as much as I can – but sometimes I really need to do something bash-y, for instance in the command line. One thing I encountered some time ago is putting newlines into bash strings, e.g. in parameters. My use case was that I wanted to make a Git commit from command line with a multiline commit message.

2019-12-01

2019-11-25

2019-11-20

2019-11-17

  • 10:28 UTC (new) (history) 2019-11-17 Diffing buffer fragments, continued . . . . Marcin Borkowski Apparently, my last blog post about diffing buffer fragments sparked a small discussion on Twitter. Most comments fell into one of two categories: some people wanted to use ediff (which I explicitly mentioned I didn’t want), and some people complained about the temp files (which do not bother me that much). Well, it turns out that I really did not have to create the temp files after all!

2019-11-11

  • 18:49 UTC (new) (history) 2019-11-11 Diffing buffer fragments . . . . Marcin Borkowski While working on a certain project, I needed to check the differences between two text fragments. We all know and love diff, but it operates on files, and what I had was two fragments of two files (or sometimes even of one file) which I wanted to compare. There are a few solutions to this problem, but they seemed too complicated for me.

2019-11-04

  • 20:12 UTC (new) (history) 2019-11-04 Starting Emacs with custom configuration directory . . . . Marcin Borkowski The usual thing people are told to do when debugging/isolating Emacs problems is to say emacs -Q, that is, start Emacs without reading in any configuration. Sometimes, however, this may not be a good idea. When there is some problem with packages, however, we may actually want to load some things, like a minimal set of packages if we suspect they do not work together. Of course, what we don’t want is changing our configuration.

2019-10-28

2019-10-21

  • 18:59 UTC (new) (history) 2019-10-21 Clearing the Eshell buffer . . . . Marcin Borkowski Since I’ve been quite busy recently, I only have one short tip today. I sometimes use Eshell, and sometimes want to clear it so that I can e.g. isearch through the result of running some command and not be bothered by the output of previous commands. In such a case, I can say clear, but it does not really clear the Eshell buffer – it only makes the part above point scroll past the visible part (and it seems that it doesn’t even take into account the font – if I make it smaller, clear does not scroll enough). But I can also give clear any argument (e.g., say clear t), and then the previous contents of the buffer are really deleted. Handy.

2019-10-12

2019-09-30

  • 20:33 UTC (new) (history) 2019-09-30 diff and ignoring lines . . . . Marcin Borkowski One of the most well-known commandline tools is the classical diff program. On my system, it is (of course) the GNU diff, which is a part of the GNU diffutils package. Recently, I found out that GNU diff has an interesting option, -I (or --ignore-matching-lines). You can give it a regex and it will ignore added or deleted lines if they contain a match for this regex. This may be useful in many circumstances.

2019-09-23

  • 18:44 UTC (new) (history) 2019-09-23 A comparison between merging and rebasing . . . . Marcin Borkowski Many Git tutorials and howtos discuss the question whether you should merge or rebase your branches on the master branch when ready to include some feature in your code. What they usually do not mention is that rebase may be trickier to perform than merge. Why is that so? Let’s dive in and see.

2019-09-16

  • 15:30 UTC (new) (history) 2019-09-16 sponge and other moreutils . . . . Marcin Borkowski GNU coreutils are well-known and loved, especially with pipes (of course!). But what may be slightly less known is the collection of command-line tools called moreutils. As their author says, moreutils is a growing collection of the unix tools that nobody thought to write long ago when unix was young.

2019-09-08

2019-09-05

2019-08-31

  • 11:17 UTC (new) (history) 2019-08-31 A simple tip with overlays and diffs . . . . Marcin Borkowski A few days ago I had an interesting problem. I had to resolve a particlarly nasty Git merge. It involved several files with lines’ lengths in the triple digits and a fair number of very small changes. Seeing those changes (in smerge-mode), even after refining the diffs, was tricky – there were many very small patches (sometimes two, sometimes four characters) of changed text and I was quite afraid that I would miss some of them. I searched for a command to “go to the next patch of changes”, but to no avail. Then I decided to write my own.

2019-08-19

2019-08-11

  • 19:18 UTC (new) (history) 2019-08-11 A console.dir hint . . . . Marcin Borkowski As everyone knows, console.log is the ultimate debugging tool. ;-) Joking aside, it is genuinely useful (together with console.error) in scripts. I often write small (and sometimes not so small) CLI utilities in Node.js, and they are really indispensable. Sometimes, however, you want to output a complicated structure.

2019-08-05

  • 17:04 UTC (new) (history) 2019-08-05 datefudge and agenda testing . . . . Marcin Borkowski Some time ago, a question was asked on the Org-mode mailing list about a specific kind of task in Org agenda. This made me think about debugging one’s agenda settings. I’ve already written about batch agenda, but one problem with agenda testing is that it is inherently stateful, in one of the worst ways – it depends on the notion of now. Debugging time-related stuff is hard. (Well, time-related stuff is hard, after all.) It would be great if you could just manipulate Emacs into thinking that the time is some day in the future (or in the past)… Well, actually, it can be done – and it’s easier than I thought.

2019-07-29

2019-07-22

  • 18:43 UTC (new) (history) 2019-07-22 Increasing timeout in nginx . . . . Marcin Borkowski Today’s is a short follow-up to the post about debugging Node.js programs in a Vagrant virtual machine. It turns out that it lacked one important piece. It’s all and good in an artificial environment of an isolated script – but when we debug a real Node.js application, the server will timeout while we are slowly stepping through code.

2019-07-15

  • 18:31 UTC (new) (history) 2019-07-15 Batch Org agenda . . . . Marcin Borkowski Org-mode agenda is a notoriously complex system. It is really great from a user’s perspective, but a nightmare for a programmer wanting to tap into its generation. A long time ago I have had an idea for a productivity tool which would compute my “agenda score” (for lack of a better name), where each task not yet done would contribute to a total of some kind of “penalty” points – and more of them depending on how long the task is overdue. However, I am probably too stupid to be able to understand what is going on under the hood of org-agenda, and I started to look for better ways. There do exist some tools which might help with that – org-super-agenda being one of them, but there are probably others. Still, I felt this is not the best way. I decided to drop my idea (at least until I have more time and motivation to get back to it). After some time, however, I came back to org-agenda, this time from another direction.

2019-07-08

2019-07-01

2019-06-24

  • 04:56 UTC (new) (history) 2019-06-24 org-agenda-todo-ignore-timestamp vs org-agenda-todo-ignore-with-date . . . . Marcin Borkowski Org Agenda is a legendary feature. One of its selling points is customizability (as is usual in Emacs in general). This, however, comes at a price: agenda generating is slow, even though it is reportedly heavily optimized. (At the worst moment, my agenda took about half a minute to generate. A naive benchmark convinced me that the reason was a rather large Org file, weighing almost a megabyte and containing several thousand headlines (a.k.a. capture.org). No surprise, and a good candidate for optimizing (most of its entries do not really need to be even considered for agenda, so those which do can be moved to another file, and this one can be excluded from agenda generation). But today, I’d like to talk about something else – two of the many options governing agenda generation, namely org-agenda-todo-ignore-with-date and org-agenda-todo-ignore-timestamp.

2019-06-15

  • 18:21 UTC (new) (history) 2019-06-15 Debugging Node.js programs in a Vagrant virtual machine . . . . Marcin Borkowski One of the very nice things in a programmer’s toolbox is a debugger. Coming from Emacs, I am accustommed to Edebug, which allows to step through the code, install breakpoints (conditional ones as well as unconditional ones), watch variables etc. Programming in JavaScript is (or at least should be) no different. Indeed, both Firefox and Chromium have a debugger in their DevTools (although Chromium’s one seems a tad more confusing). This is all good when I’m debugging front-end code, but I often work on some backend code in Node.js. Fortunately, it can be debugged, too.

2019-06-09

2019-06-03

2019-05-27

2019-05-24

More...

Filters