(goto-char 1) vs. (goto-char (point-min))

Here’s a short tip for all you Elispers that clears up an obscure point about moving around in buffers. For a long time I’ve been dimly aware that the preferred way to move to the start of a buffer is

(goto-char (point-min))

instead of the simpler

(goto-char 1)

The reason for that is obvious once it’s pointed out: if the buffer is narrowed, the first point in the buffer may not be 1. Still, it never seemed to make a difference in practice. Xah Lee comes to the rescue with a concise post that explains what’s really going on. Take a look at Lee’s post to see why either form works but it is best to use (point-min).

As a final exercise, suppose that like Lee, you decide to replace every (goto-char 1) with (goto-char (point-min)) in all the .el files in, say, your ~/src directory. How would you do that?

Posted in General | Tagged , | Leave a comment

Burner Emails

FourZeroThree has a nice four and a half minute video on how and why you should have a burner email account. The idea has been around for a long time under the name of disposable email addresses. The idea is that you never give out your real email address to Web sites or others who may abuse it. If you’re really paranoid, you might not give it out to anyone. Instead, you have a set of proxy addresses which forward any emails sent to them to your real address.

There are a number of ways to do that. The easiest is if you have control of a mail domain and can create and delete email addresses at will. Not everyone can or wants to deal with that, of course, but there are several email proxy services that let you do the same thing. Watch the video to see some of them.

It’s a good video with some useful information but you should understand what they can and cannot do. Using a burner email address will help protect you from Facebook, Gmail, and other malefactors who want to harvest and sell your personal information but it won’t protect you from the government. If you’re dealing drugs or into other illegal activities, the government will have no problems piercing a burner email veil. Most of us, of course, don’t fall into that category and simply want to keep the snoopers at bay. A burner email won’t do the job on its own but it’s a good start.

Posted in General | Tagged , | Leave a comment

Video Demonstration of Org-roam

If you’re wondering what org-roam is all about, there are a couple of useful videos over at the YouTube Emacs Elements channel. The first video explains what org-roam is and how it works. It works through a couple of examples that show how to insert links and how to reveal back links. One nice aspect of the video is that it shows how to use the org-roam capture templates to enter notes. That’s more important than it might seem because for a working Zettelkasten it’s vital that entering notes be as frictionless as possible so that you won’t hesitate to capture all your ideas and notes.

The second, shorter, video discusses some tweaks that make dealing with org-roam files a bit easier. It also shows some more examples of using templates.

These videos are a nice introduction to how one might use org-roam. You probably won’t want to use the bindings from the videos—they mostly use the Ctrl+h prefix—but that’s just a detail. The videos are 14 minutes, 16 seconds and 7 minutes, 4 seconds long so they shouldn’t be too hard to fit in. If you’re looking for an Emacs-based Zettelkasten solution, you should take a look at these videos.

Posted in General | Tagged , | Leave a comment

Emacs Editing

Over at the Emacs subreddit, WorldsEndless has an interesting post that considers Emacs as a text editor. That is, how convenient is it to edit text with Emacs, putting any of its other virtues aside. He considers both the built-in capabilities and a few of the common packages that most of us use.

What’s surprising, given the constant griping about how “Emacs out-of-the-box is unusable,” is how far you can get with just the built-in functions. Most decent editors can probably do all the things he calls out—with the possible exception of the transpose functions—but Emacs really stands out when you start customizing with the third party packages. WorldsEndless mentions flyspell-correct; some of the ace-* functions; multiople-cursors; and consult-yank-pop, which is similar to one of my favorites, counsel-yank-pop.

I, of course, have my own list. I wrote about my favorites here and here. Doubtless all you Emacers have your own favorites. The takeaway is that Emacs provides really great facilities for wrangling text. The only other editor that I’ve used that comes close is Brief from back in the MSDOS days and I wouldn’t go back even if I could.

I think it’s a fair assertion that the built-in functionality of Vim provides more functionality than the built-in functionality of Emacs but once the you add in packages Emacs is far ahead. You may or may not agree but there’s no denying that Emacs provides great text handling functionality.

Posted in Blogging | Tagged | Leave a comment

Mouseless

If you grew up with computers using a GUI interface, the idea of not using a mouse probably seems ridiculous. Why would anyone want to do that? As I’ve said in other contexts, you can live without air conditioning too but why would you? Some, like Rob Pike, have even claimed that using a mouse is faster than using a keyboard.

Emacs users, of course, famously revile the use of a mouse with their editor but likely fall back to using it in other contexts such as a browser. Sometimes, though, the choice is snatched away from you and you’re forced to live without a mouse. That’s what happened to loafofpiecrust when his mouse failed. As he reports over at the Emacs subreddit, he was in the middle of doing his homework when his mouse failed but was able to continue because he was using Emacs, probably using EXWM, and had made arrangements for mouseless browsing in Firefox with tridactyl. He notes that he found not having the mouse made him even faster.

Naturally, I was jealous. First because as a Mac user I don’t have EXWM available but also because I use Safari and don’t have tridactyl available either. It turns out though, that vimari does the same thing for Safari and bytes in has a list of similar software to allow mouseless browsing with other browsers. There’s even disable-mouse if you want to enforce mouseless editing within Emacs.

Most of us probably wouldn’t want to do away with a mouse in most situations, but it’s nice to know that it’s possible. I might try vimari out to see if browsing without a mouse is feasible. If that were to be the case, essentially all my computing could be done without a mouse.

Posted in General | Tagged , | Leave a comment

Irreal Problems

I just discovered this past week that I’m no longer getting emails notifying me of comments to Irreal posts. As far as I can tell, the problem started either with the new year or when I upgraded the Disqus WordPress plugin around the same time. If anyone else is seeing a similar problem, please leave a comment.

This has had the unfortunate effect that complaints about things like missing links went unanswered and the problems unfixed. I’ve gone through the posts manually looking for unseen comments so I think things are up to date now. My apologies to those who made substantive comments on the content of a post and were seemingly ignored.

One of the comments that I missed was from Vladimir Nikishkin who noted that the links to Irreal’s RSS feed are broken. I made a quick check of my WordPress configuration and didn’t see anything related to RSS although I did find some documentation. Is anyone else seeing a problem with the RSS feed? In the 10 years that Irreal has been running on WordPress, I’ve never before had a complaint about the feed so I’d like to make sure this is a general problem before I commit resources to hunting down a solution.

In the mean time, I’ll ping Disqus to see if they know why I’m not getting notified of comments. These sorts of problems tempt me to consider a static blog although I’m sure that would bring its own set of problems.

Afterword

Just before publishing this, I checked the “Entries feed” item on the blog menu and it does appear to be correct. Now I’m even more confused.

Posted in Administrivia | Tagged | Leave a comment

Red Meat Friday: Real Programmers Use TECO

Think you’re tough because you use Vi or Emacs? Or even ed? “Real Programmers” don’t think so.

It’s hard to see the entire text in the embedded tweet. It says,

Some of the concepts in these Xerox editors have been incorporated into editors running on more reasonably named operating systems. EMACS and VI are probably the most well known of this class of editors. The problem with these editors is that Real Programmers consider “what you see is what you get” to be just as bad a concept in text editors as it is in women. No, the Real Programmer wants a “you asked for it, you got it” text editor – complicated, cryptic, powerful, unforgiving, dangerous. TECO, to be precise.

Oddly, I know of some oldtimers who claim to still use TECO. I can’t believe they use it as their everyday editor though. Probably it’s more a matter of firing it up once in a while to keep current like I do with ed.

You can read a bit more about TECO and the other things that “Real Programmers” do at the link in the tweet.

Posted in General | Tagged , | Leave a comment

An Example of Literate Programming

As I’ve mentioned before, I’m ambivalent about literate programming. I love the idea of it and absolutely agree with all its claimed strengths but I’ve never been able to embrace it in practice. The major problem, I think, is that when I’m reading code—and particularly when I’m debugging it—I like to be able to see everything in context and not have related parts scattered throughout the narrative. I don’t think that’s just me waving my cane but perhaps I’m deceiving myself.

One of the common use cases I see for literate programming is in Emacs configuration files. It make’s it easy to explain why you want things to be configured in a particular way and follow the explanation with a code block that implements it. Usually that results in a fairly coarse division of the code and you can see everything relevant at a glance. Even better, using Org-mode means you can fold the sections making it easy to find and open just what you want.

Hsin-Hao Yu has a nice post on his experiments with literate programming. Like me, he thinks that WEB-style literate programming in Knuth’s sense is overkill for his uses. He decided to experiment a bit using Org-mode with his configuration file. So far that sounds like what lots of other folks have done but Yu pushed the idea a little further by using the noweb feature to restructure the code and make the code layout more logical—at least more logical in the literate programming sense.

The example he gives for this is illustrative. He starts with his definition of org-capture-templates that defines 3 templates. Yu says he finds it hard to read and even harder to add another template in the right place. He fixes that by putting each template in a separate code block and using noweb to pull them all into the setq for org-capture-template. That makes it easy to add another template, of course, but he pushes the idea even further by suggesting that the templates could be moved to the section with which they’re related: the journal capture template could be moved to the section that configures his journal, for example.

That last point is where I become ambivalent again. I agree it makes perfect sense and all but I can’t get over the idea the templates should be defined in the same place. Yu’s opinion in this is as good as mine, of course, and as usual Emacs lets us have it our way but if you come down on Yu’s side of the debate, the example shows you how to implement it.

If you have any interest at all in literate programming, take a look at Yu’s post.

Posted in General | Tagged , | Leave a comment

Transient Mark Mode

If you’ve been an Emacs user for a while, you probably know what transient mark mode is and you might even know that its use is—or was—controversial. It used to be disabled by default but in Emacs 23 the default was changed to enabled. I’ve never understood the controversy. Why wouldn’t you want the active region to be highlighted? I started with Emacs 21 and one of the first things I did was enable it. In fact, I just checked and it’s still in my init.el. After almost a decade and a half of Emacs use, I still didn’t understand the controversy. Until today.

Wilfred Hughes just tweeted a link to a post by Sean Whitton that explains the transient mark mode controversy and gives some mitigations. There are two problems with transient mark mode:

  1. If you want to just set the mark (to jump back to it later, for example) you have to type Ctrl+Space Ctrl+Space instead of just Ctrl+Space to set the mark without activating it.
  2. When you use Ctrl+x Ctrl+x to switch the mark and point, it activates the region between them and you have to either precede the sequence with a Ctrl+u or follow it with a Ctrl+g to avoid the highlighting.

The first isn’t much of a problem. Especially for me since I don’t set the mark manually very often. The second is a little more annoying but is hardly a deal breaker. In any event, Whitton gives a bit of Elisp to inactivate the mark after the switch so that the region doesn’t get highlighted.

There are some benefits to transient mark mode other than highlighting the region that you can read about in Whitton’s post. He provides another bit of Elisp the provides those advantages without having to have transient mark mode enabled. He says that he has been running with the second—but not the first—fix enabled and transient mark mode disabled and found that he didn’t mind not seeing the active region highlighted.

That strikes me like living without air conditioning. Sure, you can do it but why? Whitton’s post made me think that I made the right decision in enabling transient mark mode all those years ago but your mileage may vary. Read Whitton’s post and make up your own mind. At least you’ll know what the controversy is about.

Posted in General | Tagged | Leave a comment

Using a Local Emacs From a Remote Host

Michał Nazarewicz has a very interesting post on using Emacs to edit files on a remote system. Your first reaction is likely, “Meh, isn’t that just Tramp?” I know that was mine but Nazarewicz has a specific requirement: he wants to SSH into the remote system, do his work, and, when he wants to edit a file, use emacsclient to connect back to the Emacs server running on his local host. It is, in a sense, the reverse of what you with Tramp: instead of connecting to a remote file from the local Emacs server, you connect to the local server from the remote host.

The point of this, apparently, is to avoid changing to another shell session when you want to edit a (remote) file. Whether you think this is worth the effort probably depends on what you do on the remote host. If you just want to edit a file or two, Tramp is probably fine. If you’re performing lots of other tasks, Nazarewicz’s method may be useful.

The TL;DR is that when you SSH to the remote host, you arrange to forward the (remote) Emacs server port to the local Emacs server port. That way, when you invoke emacsclient on the remote host, it connects to the server on your local machine. It’s a cute trick but the details can be a little fussy. Read Nazarewicz’s post for the details.

Update [2021-02-04 Thu 16:10]: Added link to Nazarewicz’s post.

Posted in General | Leave a comment