Emacs Integration

Over at the Emacs subreddit, FortunateDaughter_ notes that the Emacs “editor” has all sorts of other productivity tools, such as email, built in and wonders why this is, what was the philosophy behind it, and whether users benefit from it rather than using dedicated tools focused on those applications.

The first thing that popped into my mind was the usual trope of Emacs being an operating system more than an editor. Of course, that’s with the understanding that being an “operating system” means simply that Emacs provides a unified interface to a wide range of everyday applications.

My own way of expressing this phenomenon is to say that Emacs is actually a light weight Lisp machine that includes an editor as one of its default applications. I think that that’s a more useful and accurate way of describing Emacs’ role. In any event, I was interested in the commenters’ reactions to FortunateDaughter_’s question.

No one used the term “Lisp machine” but several noted that what Emacs really does is provide a Lisp environment in which users can write or download applications to support their workflow. And, by the way, it includes a preinstalled editor.

Other commenters discussed whether or not Emacs adheres to the Unix philosophy. Cases can be made for either point of view but I’ve never been much concerned with the controversy: Emacs mostly does what I want it to do and when it doesn’t, it’s easy to extend it or find a preexisting package to make it do so.

So whether or not you think of it explicitly as a sort of Lisp Machine, it’s certainly true that Emacs provides a setting that lets you subsume most of your existing applications into a unified environment and makes it easy to add new ones.

Posted in General | Tagged | Leave a comment

Captee

Charles Choi has an application, Captee, in the Mac App store that’s a generalization of my jcs-get-link function. My function inserts an Org link to the currently active page in Safari. I use it constantly when writing blog posts. It may seem like a simple thing but it saves me a huge amount of time.

It’s pretty simple but it uses Apple Script so it only works on the Mac. Here it is:

(defun jcs-retrieve-url ()
  "Retrieve the URL of the current Safari page as a string."
  ;; (org-trim (shell-command-to-string
  ;;   "osascript -e 'tell application \"Safari\" to return URL of document 1'")))
  (do-applescript "tell application \"Safari\" to return URL of document 1"))

(defun jcs-get-link (hostp)
  "Retrieve URL from current Safari page and prompt for description.
With the universal argument, return a link to the host only.
Insert an Org link at point."
  (interactive "P")
  (let* ((link (read-from-minibuffer "Link Description: "))
         (result (jcs-retrieve-url))
         (urlobj (url-generic-parse-url result))
         (host (concat (url-type urlobj) "://" (url-host urlobj))))
    (insert (format "[[%s][%s]]" (if hostp host (org-trim result)) link))))

It would be easy to change this to work with any browser on the Mac.

Choi’s solution is a generalization because it works with any application that supports the Mac Share menu. It can also generate either Org or Markdown markup. For non-Emacs use, it puts the result in the clipboard but inserts it directly into the buffer if you’re using Emacs. On the other hand, you have to switch focus to the application to use the share menu whereas with jcs-get-link you don’t have to leave the comfort of Emacs. If you’re looking for an easy way to insert Org or Markdown links, take a look at Captee.

Posted in General | Tagged , | Leave a comment

Microsoft Reverts To Type

Younger Irreal readers whose memories don’t extent beyond the start of the century may be puzzled by my occasional disparaging of Microsoft. After all, they’ve made a point, lately, of reciting all the appropriate open source mantras and cultivating a kinder, gentler demeanor. Those with a longer memory will understand.

Microsoft has long had a reputation for an aggressive, take-no-prisoners approach to marketing. They have, traditionally, met any challenge to their hegemony with a no-holds-barred counter attack. They have, as late, tried to foster the belief that they’ve changed, support open source, and are everybody’s friend. Old timers are suspicious and unwilling to take their protestations at face value.

Occasionally, the facade slips and Microsoft reverts to type. Back in the day, Microsoft got in a lot of trouble for trying to force their browser, Internet Explorer, on their customers. You’d think they’d be especially sensitive to that type of thing to avoid another suit from the government.

You’d be wrong. Sometimes they just can’t help themselves and revert to type. The latest example is Microsoft’s decision to make Outlook and Teams open links in Edge, their current browser. You can read the details of their latest reversion at the link but that’s not the point.

The point is that no matter how much Microsoft would like you believe that they’re a new, reformed company, they’re still the same old Microsoft and you trust them at your peril. In particular, be very suspicious about “free” Microsoft offerings such as VSCode or their other free applications. Their only intention is to entice you into the cult so that they can own your digital life. A little skepticism will serve you well.

Posted in General | Tagged | Leave a comment

Some Navigation Functions

I’ve written before about Aimé Bertrand and his Emacs configuration. In particular, I was impressed with the many specialized functions he had to do various UI tweaks. Bertrand is back with another post. This one discusses some of his navigation functions.

As before, the functions are mostly simple and designed to save him a step or two as he moves around among his Emacs windows. For example, when he splits a window (either vertically or horizontally), the focus remains with the original window. He doesn’t like that and wants the new window to become active. That’s not hard to do and it doesn’t save a huge amount of time but once you implement the new functions, you never have to think about it again.

A similar set of functions opens a new file but splits the window first and opens the file in the new window. He also has a function that will toggle a window splitting from side-by-side to top-and-bottom or vice versa

He’s got some functions dealing with Tabs but given that I never use Emacs Tabs I didn’t pay too much attention to those. There are a few other functions as well so it’s well worth your time to take a look at his post.

By far the most interesting thing for me was his use of emacs-everywhere, a package that allows you fill in text for a non-Emacs application by popping up an Emacs buffer and saving the result back to the original application. As soon as I read that, I installed emacs-everywhere and bound it to an easy to use key sequence. It’s not quite “never leaving Emacs” but it does allow me to use all my normal editing methods in any application. I’ve seen other packages that do this but they seemed more complicated to set up so this is a big win for me.

Posted in General | Tagged | Leave a comment

An Apostate Comes Home

Over at the Emacs subreddit, g_tb has come back to Emacs after trying Neovim, Kate, Helix, and VSCode. None of them met his needs as well as Emacs so he’s back to the one true editor™. Of them all, VSCode came closest to meeting his needs but he’s justifiably suspicious of Microsoft and, apparently, VSCode has different keybindings on Linux, Windows, and the Mac.

Reading between the lines, I infer that his problem with Emacs is that you have to “build your own editor”. It’s a complaint that I see a lot: “I don’t want to have configure everything myself. I just want it to work out-of-the-box.”

Of course, there are solutions. At the simple end, you can use one of the prebuilt configurations like Steve Purcell’s Emacs config. But these configurations usually have a point of view, which may or may not mesh with your desired workflow.

At the high end, there are solutions like Spacemacs and Doom Emacs that do provide an out-of-the-box solution. The problem with them is that everything goes into the box so that the result is bloated and possibly slower. Doomers and Spacemacsers will object that you can configure them to include only the functionality you need but then you’re back to the original problem of building your own editor.

The best solution, I think, is what I did. The TL;DR is to follow the advice that everyone gives for Org mode: do one thing at a time. When I started Emacs, I didn’t have a master plan or even know what I was doing. I was mostly coding in C then so I spent a couple of hours figuring out how to configure Emacs to follow my conventions for spacing and indentation. It wasn’t that hard.

There was some sort of menu item for choosing a light or dark background and, of course, the minions insisted I choose the light background. As I went along, I added things like Flyspell and a mode for Troff source. As I moved to Lisp and Scheme, I added configuration for them. Now I have a reasonably large config file and every bit of it is custom built (although I’ve stolen lots of code as I went along).

The result is that I have an Emacs built just for me. The important point is that at no point did I have to stop everything and spend hours “building” Emacs. I just added stuff as I needed it and ended up with a bespoke Emacs.

Posted in General | Tagged | Leave a comment

A Hopeless Addict

My name is jcs and I’m an addict. A hopeless addict. Yesterday, in my post about fixing mu4e’s new behavior of opening in full frame mode, I mentioned that upgrading to mu 1.10.3 broke Emacs to the point that it wouldn’t load. I was very uncomfortable until I got things working again.

Today (Sunday) is my day to update my Emacs packages. Afterwards, I always bounce Emacs to make sure there are no consistencies. For the second day in a row Emacs wouldn’t start correctly. This time, at least, Emacs started but it aborted reading init.el so none of my packages loaded and Emacs was essentially useless to me.

Even though the breakage was less severe than the first episode, my reaction was more violent. I didn’t hyperventilate, exactly, but I was upset and may have uttered some family-unfriendly words. It was then that I realized—to channel Olivia Newton-John—that I am hopelessly addicted1 to Emacs. When it breaks, all I can think of is “how am I going to get any work done?” That’s a little silly: although I’ve lost my edge, I can still use Vim or—in a pinch—even ed. Still, I feel helpless without Emacs and everything else stops while I figure out how to get it running again.

In short: I’m seriously addicted to Emacs. And I don’t want to kick the habit.

Footnotes:

1

Devoted/Addicted: it’s all the same to us Emacs addicts.

Posted in General | Tagged | Leave a comment

Fixing Mu4e Forcing Opening In Full Frame

A couple of weeks ago, I upgraded my mail client, Mu/Mu4e, to version 1.10.2 with Homebrew. It has some nice features but it also insisted on opening mu4e in full-frame mode, wiping out whatever window configuration I had. That was definitely not something I wanted. I did a quick scan of the documentation to see if there was some new configuration variable controlling this behavior but I didn’t find anything. Then I asked DuckDuckGo but either my search-foo was inadequate or there was nothing relevant.

This seemed like a breaking change to me so I thought maybe it was an error and perhaps a point release was available that fixed it. I checked with Brew and, sure enough, there was a 1.10.3 release so I upgraded. That didn’t help at all. In fact, Emacs wouldn’t even load. That was due to a library incompatibility and I had to recompile Emacs to get back to where I was.

My next plan was to run mu4e in a separate frame. That worked okay but made my Emacs navigation a little fussy. Finally, in desperation, I made another run at DuckDuckGo. Either my search-foo had magically improved or new information had materialized but I found this GitHub PR.

The TL;DR is that you can fix the problem by adding

(add-to-list 'display-buffer-alist
             `(,(regexp-quote mu4e-main-buffer-name)
               display-buffer-same-window))

to your configuration.

If, like me, you don’t want mu4e trampling your window configuration, just add the above to your init.el.

Posted in General | Tagged | Leave a comment

Using Table Data in a Shell Code Block

Just a quickie on a quickie from Grant Rettke. The quickie is an example from Rettke on how to import and use a table in an Org code block using shell. The secret is that the table entries get passed in as arguments to the command specified in the shell block.

That’s good to know but Rettke’s example raised two questions for me. The first is what would happen if the table data had more than a single column. The answer is that it does just what you’d think it should. I reran Rettke’s example with the table

#+name: data
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |

and got the results

#+RESULTS: code
#+begin_EXAMPLE
1	a
2	b
3	c
4	d
#+end_EXAMPLE

The second question was how he got his results wrapped with the #+begin_EXAMPLE, #+end_EXAMPLE delimiters. I thought that maybe he put the #+RESULT: code in between those delimiters but that didn’t work. The only way I could see to do it was to use the :wrap keyword in the header arguments:

#+begin_src sh :var arg=data :results output :wrap EXAMPLE

Perhaps Rettke will drop by and share his secrets with us. In the meantime, if you want to deal with a table in a shell code block, this is how to do it.

Posted in General | Tagged , | Leave a comment

Red Meat Friday: Gray on Gray

Over at the Emacs subreddit, Lalelul wants to know How can I fix hard to read (gray text on gray background) dialog boxe? As soon as I saw it, I deleted the browser tab but I was too late. The Minions had noticed.

They started jumping up and down and insisted that I provide the answer: “Don’t use unreadable dark themes.” Problem solved.

RMF humor aside, why would anyone do this? In a sense it doesn’t matter because the users of these themes are hurting no one but themselves but the Minions—and to tell the truth, I—don’t understand why anyone who isn’t a misanthrope would design a theme in which the menus are unreadable. Maybe it’s a way of encouraging users to eschew menus and learn Emacs key sequences.

One of the features of Emacs is that it enables ultra-efficient editing but when you design themes that are hard or impossible to read, you’re nullifying that efficiency. To channel Nancy Reagan, “Just say no.”

Posted in General | Tagged , | Leave a comment

On Org Alternatives

There’s a phenomenon that I both understand and don’t understand. That phenomenon is happy Emacs or Org users feeling the need to try out every alternative that comes their way. Notice I said “happy” users. If Emacs or Org isn’t working for you, then of course you’d seek an alternative. What I’m talking about are those who’re happy with their Emacs/Org experience.

On the one hand, I can understand the eternal search for the best possible tools and that entails trying out new candidates. On the other hand—unless you’re a software reviewer—your job is not to find the best editor or outliner/todo manager. When you find one that meets your needs well, it’s time to stop actively searching and fallback to “stumble on mode”. By that, I mean if you stumble across an app that for one reason or another appears to meet your needs better, it’s worth giving it a look. Otherwise, spend your tool cycles mastering the ones you already have.

Eric MacAdie has come to a similar conclusion. For a long time he kept a list of Org mode alternatives that he planned to try out. The list got longer and longer and one day he realized that Org met all his needs and, given Org’s extensibility, was likely to continue to meet his needs in the future.

He’s got a great quote from a Hacker News discussion on one of those alternatives. I’ll let you read it on his site or at the link above but the TL;DR is that if you’re looking for a plain text outliner/todo manger you can not do better and are unlikely to ever do better than Org mode. Not only is Org better than anything else, it’s not even close. The quote reminds me of Neal Stephenson’s line about Emacs outshining its competition.

If you believe that it’s somehow incumbent upon you to always be searching for something better than Org even though Org is meeting all your needs, take a look at MacAdie’s post and be disabused.

Posted in General | Tagged , | Leave a comment