Org-flow-mode

jouke hijlkema has published a nifty project that uses Org mode to draw flow charts. “Uses Org mode” means, in addition to the obvious, that the Org source tree reflects the diagram tree. The project is still new and development is ongoing but it seems to be usable now if you want to try it out. Hijlkema has installation instructions at the repository so it should be easy to give it a spin.

These days, flowcharts aren’t used very much to describe the logic of a program for “coders”. Still, the idea of a flowchart is useful for describing process flows even if they aren’t used as a precursor to writing code. The example Hijlkema shows is pretty complex and it’s easy to imagine it being adapted for all sorts of applications. If nothing else, it would be useful for documenting an algorithm flow.

The “source code” for the example is straightforward and shows that it would be easy to learn and use the application. If you have a need for something like this, take a look at the GitHub repository.

Posted in General | Tagged , | Leave a comment

🥩 Red Meat Friday: You Don’t Need A Terminal Emulator

Andrey Listopadov has an interesting post that advances the notion that you don’t need a terminal emulator. To developers, that’s already an idea worthy of being included as a Red Meat Friday offering but the real reason this is a Red Meat Friday item is the diagram at the top of Listopadov’s post. Vim users aren’t going to like it and VS Code users are really going to hate it.

But fun and games aside, Listopadov is advancing a serious proposition: power users don’t need a terminal emulator. Well, at least if those power users are Emacs users. One thing you can say for Listopadov is that he’s walking the walk. He deleted vterm from his configuration and tries to do everything from within Emacs.

His basic method is to use async-shell-command for most situations where a terminal user would use an interactive command. He has other strategies as well so it’s well worth taking a look at his post to see how he works without a terminal emulator. Particularly noteworthy is his use of Tramp. Using it, he says, eliminates the need to use SSH.

The first time I read his post, I was unconvinced. I could see his point but I thought, “That’s not for me.” Then I realized that I don’t use a terminal emulator either. I have vterm installed but I can’t remember the last time I used it. I do have an iTerm instance but I use it only to bring up the mbsync log so I can practice using ed. When I need to invoke an extra-Emacs application, I use eshell, which, as Listopadov says, is a shell not a terminal emulator.

Emacs users may or may not embrace his workflow but it’s definitely worth taking at look at them. Who knows, perhaps you’ll find a new way of working.

Posted in General | Tagged , | Leave a comment

Five Shell One Liners

Perhaps I’m just old fashioned and pining for the old days. Or perhaps I’m anticipating the time when I can finally wave my cane at all those pesky kids. Whatever the case, I do believe that avoiding the command line—or worse, disparaging it—is leaving a lot on the table.

Doug McIlroy’s original conception of hooking up programs as if there were a garden hose between them is a powerful and liberating idea and arguably one of the most important Unix innovations. You can see it in action in this video about Unix where Brian Kernighan pipes together some simple programs to build a spell checker or in the famous McIlroy rejoinder to Knuth on writing a word count program.

But you don’t even need the power of pipes to see the usefulness of the shell. Mirco has a short post that demonstrates 5 one line shell invocations to solve various problems. In a sense, they’re all trivial problems but try to imagine a better way of solving them—especially with a GUI program in your toolkit.

As far as I can see, these examples are semispecific to Bash and Linux. For example, the last example of negating a file specification doesn’t appear to work with the zshell (although I’m certain there’s an extension that makes it work) and the date example depends on the version of date you’re using. Still, they demonstrate how you can often use the shell to solve a simple problem quickly and easily.

Posted in General | Tagged , | Leave a comment

Emacs Line Wrapping

Line breaking in Emacs is a complicated thing. By default the line just stops at the window edge and you have to scroll right to see some or all of the truncated part. This is called truncating long lines. That’s probably what you want for the programming modes but a case can be made for just breaking the line at the window edge and wrapping the rest to the next displayed line. Emacs calls this wrapping at the window edge. A downside to this method is that a word can be split in the middle if it straddles the window edge.

You can already see a problem with just those two behaviors. What do we call the two “lines” in the second method? It’s actually a single line but it’s displayed as two. Some of the commands that operate on lines treat it as two lines and some treat it as one so there can be a lot of confusion.

But, of course, there’s more. Visual line mode is like wrapping at the window edge but takes care to break the line at a word boundary. That’s probably what you want for writing prose (as opposed to code). It’s the mode I’m using to write this post.

Finally, there’s a fourth mode, autofill mode, that is like visual line mode but inserts actual line breaks at the places the line is split. That makes what you see on the screen correspond to the actual text file.

As I said above, all of this can be a bit confusing. Emacs Elements has a very nice video that explains the terminology for talking about the lines and demonstrates the four modes. It’s 12 minutes, 21 seconds long so you’ll have to set some time aside but it’s a good way to get a handle on this confusing Emacs aspect.

Posted in General | Tagged | Leave a comment

Zamansky: Learning Elisp #12

Mike Zamansky just published the latest video in his Learning Elisp series. This is the second video is his project to insert emojis into a buffer by replacing keywords with the corresponding emoji. In his previous post, Zamansky showed how to write a function to replace the keywords with the appropriate emojis. This video considers how to make the substitution happen automatically.

Experienced Elispers won’t be surprised that the vehicle Zamansky used for this was hook functions. In particular, he used the after-change-functions hook. The functions in his hook get called every time the buffer changes. That means that it gets called whenever a character is inserted. The rest is easy.

Every time a character is typed, Zamansky’s function is called by the hook. The first thing it does is check if the character is a space. If it’s not, the function simply returns. If it is, the function checks for a keyword—delimited with colons—and if found replaces the keyword with its emoji. The function is essentially the same as that from the previous video except for the checking if the current character is a space.

The thing that strikes me is how easy all this is. The function itself is short and simple and automating it is simply a matter of calling add-hook. I can’t imagine how one would do this in another editor, if you could do it at all.

The video is 13 minutes, 46 seconds so you’ll probably have to schedule some time. If you aren’t familiar with hook functions, this video is a good introduction. As usual, the video is worth your time.

Posted in General | Tagged , | Leave a comment

An Occur Video

Occur is, I think, an underappreciated command. At first glance, it seems sort of like grep except it works on buffers rather than files. You give it a regular expression and it opens a new buffer that lists the matches. So far, just like grep but each of those listed matches is actually a link to the line it matches.

Just this capability is very useful. I use it when I’m entering items from my monthly bank statement into my tax file. The tax file is an Org file with a headline or subheadline for each category of items I’ll need for my tax return. I run Occur with the regular expression "^\\*+ ", which lists all the headers of the tax file in an Occur buffer. That makes it easy to jump directly to the correct place in the tax file for each relevant item in my bank statement.

But wait; there’s more. You can also make the Occur buffer editable and every change you make there will be reflected back into the original buffer. As with the similar grep buffer capability, this is obviously a powerful feature.

All of this and more is discussed in the recent Emacs Elements video, All you need to know about the Emacs OCCUR command in 4 minutes. Occur is a simple but powerful tool. All you need to do is add is a little bit of imagination to enhance your workflow. A nice example of this is the comment from the reddit post for the video.

If you’re not already familiar with Occur, the video is a nice introduction. The video is only four minutes, ten seconds so it should be easy to fit it.

Posted in General | Tagged | Leave a comment

Vimari

Back in August, I wrote about my quest to minimize mouse usage as much as possible. That’s easy in Emacs where my mouse usage is essentially zero. It’s a bit harder when navigating between apps and performing various system duties such as emptying the trash. For that, I’ve discovered that in macOS, Alfred is the ideal solution.

It can mostly eliminate the need to use the mouse except when in Safari. Even with Safari, it can go a long way. For example, I can simply type the first letter or two of a site I want to visit and Alfred will open the browser and take me to that site. It’s almost entirely eliminated my clicking on bookmarks and the favorites bar.

In the post, I lamented the lack of a good solution for dealing with the browser. In the comments, nitin suggested vimium. It was exactly what I wanted but, sadly, it only worked with Firefox and Chrome. Since I’m a Safari user, I was bitterly disappointed but J Tevq popped in to tell me about vimari. It’s a port of vimium to Safari that’s available in the Mac App store.

I really love vimari. Now my mouse usage is minimal even when I’m dealing with Safari. As the name suggests, it uses Vim’s keybindings for navigation. That may seem strange for a guy who’s all in on Emacs, but the single keys for navigation and following links is a win and hasn’t bothered me at all.

If you’re a Chrome or Firefox user, even on Linux, don’t despair. You can use vimium, which is even more full featured. Neither extension completely does away with the occasional need for a mouse but they go a long way. If, like me, you like to keep your fingers on the home row, take a look at whichever of them is appropriate for your setup.

Posted in General | Tagged , | Leave a comment

Customizing Emacs Menus

As I’ve mentioned before, I’m not a big fan of Emacs menus. That’s mostly because I’m much faster if I can stick to the keyboard and, of course, my general desire to avoid the mouse when I can. Still, I admit that often the menus are handy when I want to execute some obscure command for which I don’t remember the name.

Others, of course disagree. One of those people is Charles Choi who has previously schooled me on the the proper way to configure Emacs. Choi likes to use the menus but he’s not always thrilled with their content. In a recent post, he take a look at the Tools menu and what’s wrong with it.

The post isn’t so much about what’s wrong with the Tools menu as it is about how to change it to better serve your workflow. You don’t have to modify the Emacs source for the menu. You can simply specify that you want to delete an item, add a new command, or insert a separator line. There are commands to do this to an existing menu so it’s easy to configure menus to your liking.

Choi insists that using menus lowers the cognitive load of memorizing commands and there’s no doubt that’s true but I’m of the mind that, at least for commands you use more than once a month, it pays to spend the mental cycles to memorize them and keep your fingers on the keyboard.

This is another one of those questions where there can be reasonable disagreements. In the end, it doesn’t matter much which side you come down on as long as it works for you.

Posted in General | Tagged | Leave a comment

Open Xcode From Emacs At The Same Line

Álvaro Ramírez has a nice post on opening a file in the macOS Xcode editor from Emacs. There’s nothing unusual about that, of course, but Ramírez’s wrinkle is that he wants Xcode to open at the same line the Emacs point is on.

It’s reasonable to ask why a devoted Emacser like Ramírez would want to open Xcode at all. The answer is that he’s more pragmatic than I am. I consider leaving Emacs a fail; something that I should try to find a fix for. Ramírez, as I say, is more pragmatic. Although he much prefers working in Emacs, he’s willing to use other tools if they’re more appropriate. Although he mostly uses Emacs for his iOS development, there are certain situations—debugging, for instance—where he feels Xcode is a better solution.

He’s long used Bozhidar Batsov’s crux to open the file he’s working on in Emacs in the Xcode editor. The problem was that it opened at the top of the file rather than at the line he was looking at in Emacs. It turns out, though, that you can call Xcode from the command line and specify the line to open the file at.

Ramírez, of course, used his dwim-shell-command framework to implement this but it would be trivial to adopt to plain Elisp if you’re not a dwim-shell-command user. You should also check out the comments in the reddit post about the method. There are some other useful ways of integrating Emacs and Xcode workflows.

Posted in General | Tagged , | Leave a comment

Elisp Links

In order to be a really proficient Emacs user, you’re going to have to learn at least a little bit of Elisp. As I’ve said before, Elisp is at once both easy and hard to learn. Like all Lisps, there’s not much syntax or dark corners to know. That’s simple. The hard part is the huge run time library. There are hundreds of functions performing all sorts of actions. Even after 15 years, I still don’t know all of them.

Over at Emacs Elements there’s a new video titled Great links to help you learn Emacs Lisp. The video starts off by saying that unlike many other languages you’re going to have to learn Elisp by yourself. That’s true, I guess, but no more true than for any other language. There are plenty of resources for learning Elisp—indeed, that’s the point of the video—probably not as many for learning, say, Python but still plenty.

One of the commenters complained that there was no point in having a video; all that’s really required, he says, is the list of links. I disagree with that. The video discusses each link in the list and why it’s worthwhile spending your time on. In any event, the list is here. As you can see, there are lots of way to learn Elisp but like everything else you have make the effort. I don’t know of any other way of learning anything but learning it yourself.

Posted in General | Tagged , | Leave a comment