Converting Markdown to Org

Charles Choi has a handy tip on converting from Mardown to Org. My first thought was that I don’t care about this because I write everything in Org Mode and never use Markdown. But then it occurred to me that the same is doubtless true of Choi as well and that someday I’m going to want to import a Markdown document into Org.

Choi’s basic process is to cut and paste the Markdown document into Emacs and then use Pandoc to convert from Markdown to Org. But there’s a problem. Pandoc will wrap lines while Choi likes to keep paragraphs as a single line. I do that too because it’s how visual line mode works. The excellent Pandoc has us covered, of course. You need only specify --wrap=preserve to get the desired behavior.

With that bit of wisdom, Choi gives us a handy function that will convert the Markdown in the current region to Org. It’s probably worthwhile adding his short function to your init.el just so you’ll have it when the need arrives. If you don’t like cluttering up your init.el with things you’re not actively using, at least bookmark his post so you’ll know what to do when the need arises.

Posted in General | Tagged , | Leave a comment

🥩 Red Meat Friday: Notepad Vs. Emacs

Of all the pretenders to the Emacs crown, notepad strikes me as the most ludicrous. I am not, apparently, the only one. This cartoon captures my feelings exactly.

The Emacs haters were, of course, out in force trying to deflect your attention from the essential truth but we keepers of the faith were not deceived.

Posted in General | Tagged , | Leave a comment

Using Ediff On Regions

One of the Emacs powerhouses is Ediff. Every time I think I’ve found a better way of comparing files, it turns out that I just didn’t understand Ediff well enough. It can seem intimidating but as Prot informed me it really pretty simple if you ignore all the complications. I took his advice and can only agree with his assessment.

Now James Dyer has his own take on Ediff. His particular use case is comparing regions rather than whole files. It turns out that there are two functions, ediff-regions-linewise and ediff-regions-wordwise that will use Ediff to compare two regions in the usual Ediff way.

The documentation recommends that you use ediff-regions-wordwise for small regions and ediff-regions-linewise for larger regions. In either case, once you set up the regions to be compared you use Ediff in the usual way. Take a look at Dyer’s post to see how to set up the regions. It’s straightforward and easy to remember once you use it a couple of times.

It’s a nice post and well worth reading even if you don’t need to compare regions right now. You probably will in the future and even if you don’t remember the details, you’ll know what to look for when you do.

Posted in General | Tagged | Leave a comment

Extracting Email Addresses

Mike Zamansky has a late Christmas present for us but, as they say, better late than never. This particular present is another video in his Using Emacs series. In this video he considers the problem of extracting all email address from an Emacs buffer.

The original problem was that Zamansky had several documents, including spreadsheets, that contained email address and he wanted to get a list of all those addresses for further processing. Being an Emacser, his first thought was to extract all the text into an Emacs buffer and work from there.

That extraction amounted to cut and pasting, which, while not particularly satisfying, is probably optimal considering the many types of documents involved and the fact that is was a one-off. Once he has all the text into an Emacs buffer, the rest is relatively easy. Zamansky’s solution was to put together a bit of Elisp to do the job. The value of the video is his walking us through the process of doing that.

One of the things I really like about Zamansky’s videos is that he doesn’t clean them up. You see his mistakes and fat fingering and that helps you understand the process much better than just viewing a polished video of the final result.

Accomplished_Will_31, in a reddit comment, notes that occur can do a lot of this more easily. That’s probably true but the real value of the video is seeing how Zamansky puts together his Elisp solution. His process is applicable to a wide range of problems whether or not occur offers a shorter solution.

The video is 17 minutes, 56 seconds so plan accordingly. Like all of his videos, this one is well worth spending the time on.

Posted in General | Tagged | Leave a comment

Shopping Lists With Emacs

Kris Carta has a nice post on a problem we all have: handling grocery shopping lists. If you’re single and a geek, this is not a problem. All sorts of solutions suggest themselves. The problem comes when you have a significant other that is not a geek but still likes to organize things on the computer.

If one or the other of you does all the meal planning and shopping it’s not too big a problem but in most households, both partners are making suggestions and adding things to the shopping list. If, in addition, the technical partner is an Emacs geek, the problem becomes how to import the non-technical partner’s suggestion into Emacs and how to export a final list to a smartphone application that either or both can use while shopping.

I wrote about this eight years ago and not a lot has changed. Carta is an Apple user and wanted to produce a shopping list in the iOS Reminders app. That’s what we do at the Irreal bunker too and it works well. All of us here, geek or not, is perfectly capable of using Reminders and marking off items as we buy them.

Carta has a separate wrinkle. He and his wife have always planned their meals in Notion and they wanted to export the items on their meal lists to their shopping list. Even though Carta is new to Emacs, he was able, with help, to figure out how to get the Notion data into Emacs and from there to isolate the food items for the shopping list and export them to Reminders. This leverages Applescript, which is definitely a pain, but provides functionality not available on other platforms.

Here at the bunker, we just enter the list into Reminders directly. That’s easier but not as pleasing to our geek sensibilities.

Posted in General | Tagged | Leave a comment

Recognizing Repeated Tasks In The Org Agenda

Thanks to Alex Popescu for pointing me to this nice post from Wai Hon about marking repeated tasks in the agenda listing. Why would you want to do that? Han explains it in his post: if you mark a repeated task as done but forget to readd the repeater, the task can disappear. Marking agenda tasks as repeated helps to prevent that.

Fixing the problem is pretty easy but involves a few lines of Elisp. Take a look at Han’s code for the details. It’s only a few lines and relatively simple. If you object to having to use Elisp, Han provides a couple of alternative solutions one of which doesn’t involve writing Elisp.

One could dismiss all this as a non-problem or at least a problem too small to worry about but we Emacers are all about reducing friction wherever we find it and this is a nice example of that. Regardless, if you sometimes find yourself having to base your next action on whether or not the current task is repeating, take a look at Han’s post.

Posted in General | Tagged , | Leave a comment

Freewrite Mode

As most of you know by now, I have a fascination with how non-technical people use Emacs. I’m particularly interested in how writers use it. Certainly there are some world class writers who use (or used) Emacs: Neal Stephenson and Vernor Vinge spring to mind but there are doubtless many others.

A fundamental problem for writers is coming up with ideas. One technique for dealing with this is called “free writing”. The idea is that you simply write whatever comes into your mind as fast as you can without worrying about editing or even correcting typos.

There are some problems. As Chris Maiorana explains, there’s a strong urge to fix things as you write. That’s not too bad when you write in long hand but when you’re typing on a computer, as most writers these days do, there can be an overpowering urge to hit the BackSpace key if only to fix a typo.

Maiorana has a solution. At least for Emacs users. It’s a simple mode that natters at the user whenever the BackSpace key is used. As Maiorana says, there’s plenty of room for improvement. After all, there are ways of deleting characters other than BackSpace but those are all details and, really, mostly you’re going to use BackSpace in those circumstances.

If you’re writing, or trying to write, fiction, you may want to try the free writing technique and if you do, you might want to use Maiorana’s mode to keep you honest.

Posted in General | Tagged | Leave a comment

Writing With Doom

Recently, some one posted a link to this post about using Emacs for writing. It was written by Mediapthatic in 2022 but still very useful and up to date. It takes the point of view of a book writer but is equally applicable to any type of writing.

The post assumes you’re using Doom Emacs and Evil but that manifests mainly in the key shortcuts used to invoke the various commands. It mostly uses vanilla Emacs (including Org) but also depends on Avy for a lot of its functionality. There are some other packages but they play fairly minor rolls.

The real value of the piece is the workflow and strategy that Mediapthatic uses to organize his books. It’s very Org-centric. The obvious benefit of Org is the outlining and the ability to easily move headlined sections around. But there’s more. You can use tags to control export, track characters and their characteristics, and other useful things. Take a look at the post for the details.

Another advantage to Org for some writers is folding. It allows you to essentially disappear all the text except for that portion you’re working on. Mediapthatic also shows a bit of code that opens a new window with the file narrowed to the Org subtree that the point is in.

There’s some other useful information and a bunch of links to other resources so if you’re interested in using Emacs for writing prose, take a look at Mediapthatic’s post.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: Where Should Your Configuration Live?

When I started using Emacs, just about everybody stored their configuration in ~/.emacs. Then it seemed as if folks were using ~/.emacs.d/init.el instead. For a long time when I was writing about Emacs configurations I would write something along the lines of “your .emac or init.el”.

Now, apparently, some Johnie’s come lately are putting their configuration in ~/.config/emacs/init.el. These neo-configurators are insisting that theirs is the one true way. Some of us are demurring. What do you think?

Posted in General | Tagged , | Leave a comment

Deleting Extraneous Spaces In Emacs

Charles Choi has a nice post that reminded me about something I know but never take advantage of: the Emacs cycle-spacing command. As Choi points out, we often find there are additional spaces in our text that we want to delete. That’s not hard. You just navigate to where the extra spaces are and use Back Space or Ctrl+d to delete the unneeded spaces.

Still, that seems like a lot of bother to us Emacsers who are always on the lookout for ways to reduce our work and keystrokes. An easy way to reduce keystrokes for deleting the extra spaces is the cycle-spacing command that will, on consecutive invocations,

  • Replace all spaces with a single space
  • Remove all spaces
  • Restore the original spacing

Even given a simple keybinding for cycle-spacing that’s almost always too much work because—at least in my experience—there is usually only a single space to be deleted. For me, the real value of Choi’s post is his offhand remark that Avy makes it easy to navigate to the excess spaces.

Choi doesn’t elaborate but I assume he means something along the lines of using avy-goto-char-timer with two spaces as the argument. Since I have avy-goto-char-timer bound to Hyper+s, it’s really fast to get the target area. Doubtless, those of you using Helm or some other navigation aid have a similar command to get you to the right place.

If you often find yourself with more than one extra spaces, cycle-spacing may be worth internalizing. Even if you only have a single extra space, it may be worth writing a little Elisp to search for the extra spaces and delete them with cycle-spacing.

Posted in General | Tagged | Leave a comment