Note Taking with Org Mode

Heikki Lehväslaiho has a nice series of 4 blog posts on how he takes notes with Org mode. He lists the first three posts in each entry but not the fourth; it’s here.

The last two posts are particularly interesting. He talks about how he takes notes from his Elfeed buffer and from his phone. Elfeed has some built-in methods for capturing links but Lehväslaiho’s method makes it speedy and easy. If, like me, you’re more interested in forming Org mode links, it would be easy to slightly modify his elfeed-link-title function to make the link and perhaps query you for the link description instead of using the title.

If you’re using an Android phone, Lehväslaiho shows how to get notes from the phone into an Org file using a package he wrote. Sadly, it doesn’t appear to work for iPhones

Posted in General | Tagged , | 1 Comment


Those of you who been following Irreal lately know of my fascination with the WeChat mobile app and its use in China where it serves as a wallet and messaging service. Chinese users pay for practically everything with it, use it to access government services, and for more mundane things like haling a cab or texting a friend.

I love this idea and wish we has something similar in the West. I don’t care so much about having every function in a single app but I would like to have something like Apple Pay that worked everywhere. If I have to use the Uber app to get a ride, that’s okay. The MIT Technology Review has an interesting article asking if WeChat can thrive in the U.S.

The answer so far is maybe not. Just as Western companies often have difficulty penetrating Chinese markets, Tencent, the maker of WeChat, has had limited success in penetrating markets outside of China and what success they have had is mostly with ethic Chinese traveling abroad. Part of that is that although I can download the WeChat app, I can’t link it to my bank account so I can’t use it to pay for things. On the other hand, there are already lots of successful social and messaging apps available so it doesn’t make a lot of sense to start using WeChat. That is, the network effects of the incumbent players inhibit Tencent from gaining traction in the West just as WeChat’s dominance in China would prevent, say, Facebook from succeeding in China were the Chinese government to cease blocking it.

If you’d like to learn a bit more about WeChat, take a look at my two previous posts about it. WeChat or something like it is in our future and it can’t come too soon for me.

Posted in General | Tagged | Leave a comment

Magit Bisect Tutorial

The other day, I wrote about Guowei Lv’s two very nice tutorials on using Magit rebase. Now Lv has another tutorial out on using Magit bisect. When you’re trying to track down which commit introduced an error, the Git bisect function can greatly reduce your work (\log n versus n). I’ve used it from the command line a few times and it really helped.

I’ve never used it from Magit because I wasn’t sure how to do it and in the heat of the moment, it just seemed easier to use the command line. Lv shows, that was just silly. As usual, Magit makes using Git easier and you can do it right from Emacs.

Lv’s tutorial looks at a toy bug and first runs through the bisect process from within Magit manually. That’s pretty nice but of course you can automate the process further if you can test the commits with a script. Lv reruns the bisect process using a script for testing the commits and the process is almost completely automatic.

As with rebasing, bisecting might be something you don’t use that often. If that’s the case, it probably makes sense to bookmark Lv’s tutorial so you can refresh your memory as needed.

Posted in General | Tagged , | Leave a comment

Fence Edit

There are, I suppose, reasons that an Emacs user might need or prefer to use Mardown rather than Org mode. A popular reason is that some blogging platforms want their input in Markdown and writing directly in it rather than Org mode, saves the extra exporting step. One very nice feature of Org is the ability to write code snippets in a separate buffer that has the mode of the language you’re writing in.

This is an example of the org-edit-special functionality, which is actually more powerful than just conveniently editing code; take a look at its documentation to see what else it can do. Aaron Bieber, whom I’ve written about before, has brought this functionality to Markdown with his Fence Edit package. Actually, it’s a little more general than merely being a code editing facility for Markdown: you can specify—with regular expressions—the beginning and end of a code snippet and Edit Fence will bring up an appropriate editing buffer for you. Take a look at the README file for the details.

This is really nice. At first it doesn’t seem like much but once you start using org-edit-special you don’t want to go back. Bieber’s package brings the same functionality to Markdown and other situations where it’s convenient to edit a code block in a larger document.

UPDATE [2017-08-12 Sat 19:50]: Fixed link to Fence Edit.

Posted in General | Tagged | 2 Comments

Tips for Writing LaTeX documents

Speaking of \LaTeX —as we were yesterday—Diomidis Spinellis, who’s the Editor and Chief and IEEE Software and who has written hundreds and papers and books in \LaTeX has a nice set of tips for writing LaTeX documents.

He has the usual advice about using the \LaTeX language but also mentions such things as source control, make files for building documents, style files, and recommended third-party packages. If you are writing with LaTeX, it is well worth your while to take a look at Spinellis’ advice. It’s relatively short and mentions all those little things that I, at least, always forget—do footnote indicators go before or after punctuation, for example.

Posted in General | Tagged | 8 Comments

Finding Unbalanced LaTeX Delimiters in Emacs

Here’s a handy tip from John Cook’s \TeX Tips Twitter feed (see here):

Posted in General | Tagged | Leave a comment

Lisp Runtime Redefinition

One of the things I love most about programming in Elisp is what I (and others) call interactive programming. You can write a little snippet of code—even as small as an expression—and try it out immediately without having to build any special test scaffolding. Working this way, you can incrementally build up to your final code by adding more and more snippets to it and trying things out as you go. This previous post of mine points to two brilliant examples of this. In terms of Emacs itself, you can change one of it’s core functions and have the new version take effect immediately without restarting Emacs or doing anything other than a Ctrl+x Ctrl+e.

I recently stumbled upon an old post by Tibor Simko in which he expands upon that idea by talking about runtime redefinition in Common Lisp. It’s a really great post and helps explain why Lisp languages are so much fun to program in. Even when you get a run-time error, you get dumped into the debugger where you can fix the error and take up the computation exactly where it left off except with the corrected code.

Simko illustrates this and more in his post. Even though it’s almost 15 years old, it’s as relevant and interesting today as when it was first written. If you have any interest at all in Lisp languages, be sure to take a couple of minutes to read it.

Posted in General | Tagged , , | 1 Comment

Magit Rebase Tutorial

Guowei Lv has a very nice two-part tutorial on using Git rebase with Magit. Rebase often seems to cause confusion with n00bs—at least it did with me—so I’m always happy to see more tutorials about it. If you’re a visual learner, Howard Abrams has a nice video on the subject that I wrote about previously. If you prefer to read about a subject at your own pace, you may prefer Lv’s tutorial. If, like me, you like to first see a video to get an overview and then read a tutorial to understand the details, you should first watch Abrams’ video and then read the tutorial.

In the first part, Lv shows how to amend the commit message for a commit other than the last one. Then he moves on to showing how to squash two or more commits into a single one. The need for this happens a lot to me so it’s nice to know how to get everything into a single commit.

On the other hand, sometimes you need to split a commit into two or more parts. He also shows how to do this. Again, this is something that comes up more than you’d expect.

The second tutorial considers how to use rebase to merge branches. My problem with rebasing is that I don’t do it enough to remember the details. I can always go back and watch Abrams’ video to refresh my memory but that seems like overkill. Lv’s tutorial is nice because it serves as a go-by for the common cases and I can just bookmark it and refer to it when I need to.

Posted in General | Tagged , | Leave a comment

Counting Words in Some Buffers Only

It is often, but not always, nice to have a running count of the words in a buffer. Most usually, this is convenient for writers or students who need to keep track of word count in a paper or book. One way of doing that is the excellent wc-mode that I wrote about previously.

I like to keep a running count when I’m writing a blog post but almost never otherwise. I have a key sequence to turn it on and off so it’s easy to enable it for the buffers that I need it in. Still, it got to be a pain to turn it on every time I wrote a post so I added a bit of Elisp to enable it when I open a file in /Users/jcs/org/blog, which is where my blog posts live.

Here’s the code, which as you can see, is merely part of the use-package call.

(use-package wc-mode
  :ensure t
  (add-hook 'org-mode-hook
            (lambda () (when (and (buffer-file-name)
                                  (string= (file-name-directory (buffer-file-name))
                         (wc-mode 1))))
  :bind ("H-=" . wc-mode)
  (wc-mode nil))

It’s important to add the hook in the :init section, otherwise it won’t work until wc-mode is enabled manually at least once.

This is pretty trivial and I wasn’t going to write about it but I saw a question on reddit asking how to do something similar so I thought my solution might be useful to someone else.

Posted in General | Tagged | 3 Comments

Don't Say I Didn't Warn You

As yet another example of why we should always look askance at the government collecting data, I offer the recently revealed debacle of the Swedish government’s loss of control of government and police databases. The databases contain information on almost all Swedish citizens and may also reveal the identities of military and security personnel.

The loss was apparently due to incompetence (see here and here) rather than malevolence but at least two ministers have already resigned and there’s a real possibility the government could fall. In the mean time, the personal information of almost all Swedish citizens is at risk.

This seems outrageous but it’s what always happens when a government is allowed to collect and centralize information: sooner or later it will be abused or the government will lose control of it. Either way, the subject of the data will be the ones to suffer.

Posted in General | Tagged | Leave a comment