Inserting Newlines in the Mac’s Messages App

On the heels of yesterday’s semi-Mac-specific post, here’s one that’s entirely Mac specific. If you’re a Linux or Windows user, there won’t be anything very interesting for you in this offering.

John Gruber over at Daring Fireball, provoked by a New York Times crossword clue, notes that the Enter and Return keys are not the same even though they most often perform the same function. If you didn’t already know this, the piece provides an interesting bit of information.

What was really interesting for me, though, was the footnote. One of the annoying things about the Apple Messages app is that pressing the Return key sends the message—unlike the iOS versions that have a separate Send button—so that it didn’t seem possible to format the message with separate lines. Gruber has the answer: pressing ⌥ Opt+Return will insert a newline without sending the message.

This isn’t worth declaring a national holiday over, of course, but it does resolve one more small annoyance so it’s been a good day.

Posted in General | Tagged , | Leave a comment

A Shortcut Manager for My Emacs-centric Workstation

At first glance, this post might appear to be of interest only to Mac users but most of the ideas also apply to other systems. As I’ve written many times, Emacs is at the center of my computing workflow. Almost everything I do, I do in Emacs. The only major exception is browsing for which I use Safari. Of course, other things are always going on—my continual Backblaze backup, for example—but I don’t normally interact with those.

Because I run Emacs and Safari in full screen on their own pages, it’s important that I have a quick and easy way of switching between them. I also want to bring up an Org capture buffer from anywhere in the system. I do all these things by assigning systemwide function keys to the desired action. Thus F6 switches to Emacs and F7 to Safari.

I used to do all that through Quicksilver but it’s really more heavy duty than I need since all I’m interested in is mapping shortcuts to actions. I’ve long considered getting one of the key mappers available for the Mac but as I mentioned in my Emacsclient and macOS post, I recently learned about iCanHazShortcut, which does just what I need. I specify a key combination and the desired operation and iCanHazShortcut takes care of the rest.

One of the tricky things on a Mac is telling the system to switch to an app—Emacs, say—rather than starting a new instance. It turns out that the proper command line invocation is open -a emacs. Now I have a simple and lightweight way of switching between Emacs and Safari.

That leaves only invoking a capture buffer from outside Emacs. This is the thing I’ve had the most trouble with historically. I used to use a bit of applescript to do it but it didn’t always work and other methods I tried worked even less well. Then I found Alphapappa’s yequake. It does just what I need and I can easily invoke it with iCanHazShortcut: I have it mapped to F9.

Finally, I had to deal with the touch strip on my MacBook. It likes to present different “buttons” depending on what app has focus but you can set it to always display the function keys and bring up the other buttons with the fn key.

Naturally, most of this will work on any system. You’ll have to find a key mapper appropriate to your OS but other than that, the ideas in this post should travel well.

Posted in General | Tagged | Leave a comment

Emacs for Everything

Alex Schroeder is an Emacs user who, like me, does as much as he can in Emacs. Also like me, he spends most of his tube time in Emacs or a browser. Unlike me, he uses EWW for a good part of his browsing. I’ve tried to do that too but could never make it stick. Something always seems to go wrong.

Schroeder has an interesting post in which he documents some of his configuration. Especially interesting is his Dired configurations. He use Dired as his file manager so it gets a lot of use and he has some tweaks that you might not know about. If you’re an EMMS user, you might be interested in how he uses Dired as his play list.

If you’re looking for ways to subsume more of your tasks under Emacs, Schroeder’s post may have some ideas you can use. Take a look; if nothing else you’ll enjoy his rant about open plan offices.

Posted in General | Tagged | Leave a comment

Emacs Keybindings on macOS Redux

I just saw this tweet from Vivek Haldar

and thought that it’s probably time for Irreal’s semiperiodic reminder that the reality is actually much better than a few default Emacs keybindings.

As I wrote back in 2011, you can customize the keybindings for many of macOS’s editing commands. It’s really easy to setup. You just download a file, rename it, stash it in your ~/Library/KeyBindings folder, and enjoy Emacs editing keybindings across your entire system. Even if we can’t stay in Emacs all the time, at least we can take our muscle memory with us when we’re forced to leave. All the details are in the 2011 post, so take a look at that if you’re interested.

By the way, I checked the links and they’re all still good even after the 14 years since Rus originally wrote about this.

Posted in General | Tagged | Leave a comment

Polyglot Documents in Org-mode

The University of Oxford Software Engineering Research group (OxRSE) has an interesting post on how they use Org-mode to publish tutorial material with the examples in different programming languages. The idea is to present the concepts, which are language agnostic, in a language familiar to the student. The language specific material includes both example and the accompanying narrative.

Of course, they don’t want to maintain separate documents for each language since most of the material is independent of the language and would be the same in each such file. Emacs and Org-mode to the rescue.

Org-mode, along with Babel, is already an ideal solution for writing technical material but there’s another Org feature that provides just what OxRSE needed: tags. They can mark code examples and the accompanying prose with a tag for that particular language. Then when they want to export the document for a particular language, they can add the tags for the other languages to a #+EXCLUDE_TAGS: directive.

It’s a nice technique for most situations where you’d like to maintain a single document for several slightly different versions of the same material. The post has a toy example for a tutorial on the Hello, World program but it’s so simple to implement that you hardly need the example.

If you have to the same document in slightly different flavors, be sure to take a look at this post.

Posted in Blogging | Tagged , | Leave a comment

Red Meat Friday: Word as a Random Number Generator

As you all know, Word is one of my favorite whipping boys. I often say it’s the worst piece of software ever foisted on an unsuspecting public. Doubtless that’s hyperbolic but Word is something I try never to use. Karl Voit apparently feels the same:

If you’re in any doubt as to what Voit really thinks, there’s this:

Posted in General | Tagged | Leave a comment

Emacsclient and macOS

As I’ve said many times, Emacs is the first thing I start after a boot and it stays running until the next boot or I update packages that need a restart. That means that Emacs startup time is a non-issue for me. If you’re one of those people who like to start Emacs when you need it and shut it down afterwards, Emacs can be painfully slow to get running. Fortunately, Emacs has you covered. You can start Emacs in server mode and use emacsclient to bring up a frame whenever you need one.

Sadly, it’s hard to start a GUI Emacs frame without going through the terminal first. Dante Catalfamo has a handy post that discusses his method of starting GUI frames with emacsclient. He uses iCanHazShortcut to map hotkeys to actions that would otherwise require invocation on the command line. I’ve always used Alfred or Quicksilver for things like that but iCanHazShortcut seems like a nice lightweight solution if you don’t want or need the power of Alfred or Quicksilver. Really, macOS should have the hotkey capabilities built in but the above utilities are free and more than capable.

In any event, if you’re an Emacs user on macOS, you should take a look at Catalfamo’s post. It’s a short and easy read.

Posted in General | Tagged | Leave a comment

Websockets from Emacs

Websockets are a way of providing two way communication between a Web server and a browser. Their benefit is that the server can send data asynchronously to the browser. That differs from the normal protocol of the browser sending a request and the server responding. With websockets, the server can send data whenever it needs to. A good example of their use is in the Web-based chat applications that many companies use for customer support.

Naturally, Emacs has a way of interacting with Websockets. You can write code to act either as a client or server. Adrien Brochard has a very nice post that illustrates the use of emacs-websocket package for using websockets.

Brochard’s post is sort of a minitutorial. He shows how to use the basic interface to send a message to the server and to write a server side function that refreshes a page on the browser whenever it’s code on the server is updated. The interface is simple and easy to use. Brochard’s examples include some code written in Javascript that talks to Elisp code using websockets.

If you have any interest at all in websockets or working with them, be sure to take a look at Brochard’s post. It’s an excellent introduction and well worth the time to read.

UPDATE [2020-07-15 Wed 13:53]: Fixed link to Brochard’s post.

Posted in General | Tagged | Leave a comment

Idiosyncrasies in Academic Publishing

If you’ve been around for a while, you know that I’m not a fan of academic journal publishers and their rent seeking. Happily, those days are years behind me now but for thousands of academics the process and its indignities are a daily reality.

One of the points of my rants is that it’s hard to see exactly what value the publishers bring to the process. Bastian Rieck has a post that provides some insight into that question. It turns out, according to Rieck that mostly they just add work for the authors. Read his post for an infuriating list of examples.

What’s ironic is that’s many of the things that Rieck finds annoying are simply the result of “that’s how we publishers have always done things.” The irony lies in the fact that the reason they can continue doing things the same old way—and seeking rents—is that academics also insist on doing things the way they’ve always done them: Want tenure or promotion? Publish in the top journals. Want to publish in a top journal? Abide by their annoying and nonsensical rules.

Rieck’s solution to this problem is a bit different from mine. I think either the publishers must be eliminated entirely or they must change their business model to charge for publishing instead of reading papers. Rieck just wants them to be a little more transparent about how they spend all that money they make and maybe share some of it with the people doing all the work. He’d also like the publishers to hire more competent people to do the final tweaking of the LaTeX. No doubt all this would help but the problems run deeper with than that.

Even if you aren’t in academia, Rieck’s post is a revealing peek into the publishing process. Doubtless, we all have similar inanities in our own jobs so it’s comforting to know others are suffering their own Sisyphean trials

Posted in General | Tagged | Leave a comment

Ransomware: Prevention & Recovery

A couple of days ago, I mentioned Backblaze and their newsletter with an article about Tips for working remotely. That newsletter has a link to an older article that discusses how to prevent a ransomware attack and recover if you get one. It’s a fairly long article that covers a lot of ground.

Sadly, ransomware is a growth business. Between Q1 and Q3 of 2017, attacks grew from one every 2 minutes to 1 every 40 seconds. Thing haven’t gotten any better. Hardly a day goes by with a report of another attack and some hapless company or government entity trying, often times unsuccessfully, to recover.

Infections can be difficult for big organizations to prevent because every employee has to security aware and vigilant. The means of infection are mostly the usual vectors of phishing, corrupt Websites, and social media. There are some other methods mentioned in the article so be sure to take a look.

The best part of the article, I think, is their discussion of what to do when you get infected. That includes isolating any infected machines from the local network, of course, but also the best way to go about recovering.

Effective recovery assumes, of course, that you have a backup of your data. That could be local or, better yet, a cloud based backup service. After that, the most important step is to complete wipe your system and start from scratch. They even recommend formatting your disks. Otherwise, the infection could reestablish itself.

Needless to say, the article suggests Backblaze as the means of backing up your data. They, of course, have an ax grind but I don’t and as I said in my previous post I’m really happy with them. They have a history of your files going back 30 days (a year for $24/year more) so you can recover your files before they were encrypted even if some of the encrypted files were also backed up.

If you care about the data on your computer, ransomware is a terrifying threat but a decent backup can make recovery as pain free as possible.

Posted in General | Tagged , | Leave a comment