Single Function to Center Emacs Window on Screen

Fellow Emacs-user Göktuğ Kayaalp condensed my frame centering stuff into one function as I mentioned one could do, and then improved it by adding a condition for full-screen frames. This is probably the last post on this topic, ever, because what else could be said. Right?! It’s so nice, I want to share the code, reformatted a bit. And Göktuğ didn’t add the binding of frame to selected-frame as a fallback, so I added that back in, plus longer docs.

Continue reading …

Automatically Center New Emacs Windows (Aka Frames) on Screen

When I open a new GUI window of Emacs on macOS (which Emacs calls frame) it’s positioned in the top-left corner. Since I have an ultrawide monitor at my desk, that’s pretty annoying. Unlike regular macOS apps, Emacs doesn’t remember where I dragged the last NSWindow to, so it doesn’t spawn new windows next to that. It also doesn’t stagger them like NSDocument-type apps usually do.

Continue reading …

Funding Open Source Software as a Third Party?

In a Discord chat, we’ve recently talked about how well funding for Blender turned out. At the time of writing, they get $137k per month for development. I cannot say if that’s enough or too little. But it’s not nothing. Being crowd-funded comes with its perils. Especially with free open-source software like Blender, developers tell that it’s not easy to know which user base to focus on, which UI/UX compromises to make, and how to figure out if the project backers are satisfied with the result.

Continue reading …

Change Case of Word at Point in Emacs, But for Real This Time

Teaser image

At the moment, I’m proof-reading and editing the book manuscript of my pal Sascha for the new edition of the Zettelkasten Method book. As with most things text these days, I’m doing that with Emacs. Something that continually drives me bonkers is how Emacs handles upcasing, downcasing, and capitalization of words by default. The functions that are called for the default key bindings are upcase-word, downcase-word, and capitalize-word. These sounds super useful to fix typos. The default behavior is odd, though: They only change the case of the whole word when you select the word first. Otherwise they change the case of the remainder of the word beginning at the character at the insertion point. The docstrings say as much: “Capitalize from point to the end of word, moving over.” Why?

Continue reading …

Emacs Org-Mode: Automatic Item TODO/DOING/DONE State Transitions for Checkbox Changes

Teaser image

In Emacs org-mode, you start with two states for your outline headings by default to manage tasks: TODO and DONE. I recently introduced a new state in between: DOING. That helped me come back to stuff I had to let lie for a while. In code, that means at least: I actually have multiple sequences, but these don’t matter for this demonstrations.

Continue reading …

Create Custom Org-Mode Links to Open My External Zettelkasten App

I’m a fan of linking into my Zettelkasten. I usually do this via a convention: when a 12-number digit is used to signify a timestamp with accuracy to the minute, like 202102101025 for 2021-02-10 10:25, then I expect this to be a note identifier in my note archive. When the timestamp is accurate to the second, I expect this to be something else outside my note archive, like invoices I filed away. To utilize this information, in the worst case, I have to copy the ID and paste it into Spotlight to get to the note.

Continue reading …

Protesilaos Stavrou: Commend on Unix versus Emacs

In this post, Protesilaos answers an email by one of his readers. In the email, the sender seems to assume that Emacs is bloated by definition, and that e.g. Vim isn’t, because it comes with less stuff baked-in and works well with piping – the core way to compose in *nix command lines.

The sender asks:

This video [of Luke] really provide some good reasons why to invest on ‘coreutils’ to build a small, maintainable and decentralized system rather than investing on a giant mutable system.

Emacs being the giant, mutable system, and the pipe-able Unix command-line tools comprising the “maintainable and decentralized system”. (That way of asking is loaded with assumptions already.)

Prot does a very good job at not preaching, and actually bringing forth useful arguments.

  • Vim has a lot of stuff built-in, like a terminal emulator, and isn’t that different from Emacs in that way. (Plain vi is a different beast.)
  • Prot treats Emacs “as a layer of interactivity on top of Unix”. That’s a very good description, I think.
  • There is non-negligible overhead in composing a system of many independent pieces. You end up writing a lot of glue code, so to speak. (And it can be rather brittle.)
  • Emacs ties things together into a coherent software where you can share stuff between pieces of functionality easily. You can copy from the Emacs shell and paste in a text buffer. You can perform mass text replacement from a UI you already know instead of having to learn syntax. (Opposed to sed/awk/…)

In closing, Prot points out that the underlying issue can be binary thinking (which is rather limited and avoids entertaining opposing opinions):

This hints at the kind of thinking that treats the world in simplistic, binary terms: Unix is simple VS Emacs is complex; Arch Linux is for hackers VS Ubuntua is for simpletons… Those are stereotypes that rest on misunderstandings about the intent and the purpose of each of those paradigms, their context-specific pros and cons, as well as the potentially numerous reasons one may have to opt for a given choice.

Worth a read during this time “between the years.”

How to Profile Slow Scrolling (And Other Performance Bottlenecks) in Emacs

I played around with Nicolas Rougier’s NANO Emacs configuration because it looks so hot and I wanted to try some of his tasteful settings myself. One thing that let me down for a couple days since I started eyeballing the package was performance. In my huge org files to organize app development tasks, scrolling was so-so. Pixel scrolling, which I discovered through Nicolas’s configuration ((pixel-scroll-mode +1)), didn’t work at all on my machine. I have a MacBook Pro 13” from 2020. This is a text editor. Something’s not right with my config.

Continue reading …

OpenMoji Support in emacs-emojify

Teaser image

If you have no dignity (like me), you might enjoy displaying emoji in Emacs. I actually really like that when composing/reading email, and when I want to add colorful stuff like stars in my to-do lists. There’s this package, emacs-emojify, you might want to check out. When you install the package, it will download EmojiOne images by default. You can set up your own, and I found the OpenMoji set to look very nice. Clear lines, crisp shapes, very recognizable expressions in big and small sizes. Love it.

Continue reading …

Shorten Emacs Yes-or-No Confirmation Dialogs

Some commands in Emacs and its various packages are destructive. They require a confirmation by the user. These usually use yes-or-no-p, which won’t complete the command until the user replies by writing “yes” and then hits enter, or “no”, or aborts the command with C-g. Some of the commands that require confirmation in this way are overly protective, I find. Like projectile-kill-buffers (C-p k) which closes all open buffers for a project at once. I use this heavily when e.g. editing my website: jump into the project, edit a file or two, commit, then leave. I don’t want to type “yes” and hit enter just for that. (Please note that killing a buffer this way will still ask me if I want to save or discard changes, so the kill command alone is not destructive.)

Continue reading …

Make RVM's Ruby Available to Emacs Shell Commands

No matter if you use exec-path-from-shell or not, Emacs will not be able to know your RVM-managed Ruby information. This drove me crazy. Most Emacs shell commands are invoked in an “inferior” mode, aka a “dumb” shell. This includes M-!, M-x shell, and also the projectile compile commands. That’s when some of your user login scripts will not automatically load, like the entirety of rvm, the Ruby Version Manager.

Continue reading …

Add HTML Entity Picker to Emacs

Emacs comes with a lot of stuff out of the box, but I was missing TextMates “Insert Entity” action that lets me search through HTML entities by name and then insert " or ™ for me. I can never remember the names of typographic quotation marks in German, for example.

Continue reading …

Delete the Next Word or the Current Selection in Emacs with the Same Shortcut

When you delete a character or the current selection, you usually hit C-d (Control + d) in Emacs. I got into the habit of revising drafts by deleting whole words, and the M-d (Meta + d) key combination is super useful for that. It also works into the other direction with backspace. It’s essentially the same effect of +backspace everywhere else in macOS.

Continue reading …

Indie Support Weeks: beorg

Teaser image

This is week two of the COVID-19 lockdown that led to #IndieSupportWeeks to help independent developers get a shoutout and maybe find a couple extra customers.

For today’s installment, I picked beorg.

beorg is a bit weird. It’s basically a task manager and calendar, but based upon plain text files that I sync via Dropbox. It’s not a particularly user-friendly application, and its UI didn’t win any prizes, unlike e.g. Things or OmniFocus (I’m often confused by the app icons and lack of labels, but also glad because my iPhone 5S screen is so smol). So why did I pick this app, then?

Urist likes beorg for its visual representation of plain text outlines

beorg is a mobile companion for my Emacs org mode files. It’s capable of handling org mode outlines, and parts of these outlines can be tasks or TODOs, and you can group them in projects, and then display an overview or “Agenda” – and things get out of hand quickly from there. Emacs is ridiculously customizable, and org mode is no different. beorg makes these information available on mobile.

So since over the years I moved from OmniFocus 1 to Things to OmniFocus 2 to Emacs, I got used to viewing tasks on my mobile phone and iPad; and I really much like the capability to capture information on the go. A piece of paper will do most of the time; but having a web clipping synced to my computer directly is nice.

You can even write Scheme scripts inside beorg! I haven’t touched that topic at all. The REPL (yes, it has a REPL!) provides a sandbox for experimentation, and by convention beorg will load and run file from your list of files right after bootstrapping. You can even customize the app’s UI with this. Writing org files that auto-execute during launch to customize the behavior of the editor is a long-running theme, see this random example (source).

Regarding the business model: most stuff is free, and the free version will get you really, really far. You currently can buy access to additional features:

  • “Properties” will let you add custom key/value pairs to any item; it’s mostly a UI affordance for the plain text underpinnings
  • “Encryption” to, well, encrypt your items or files
  • “Task Timers” to track how long you work on a task (ahem, I suggest an automated service like Timing for that; note: this is an affiliate link)
  • “Templates” are pretty self-explanatory, and org mode capture templates can get out of hand and cover JIRA ticketing, for example (did I mention you can configure org mode to sync with JIRA?)
  • “Export Themes” are CSS styles to generate HTML from your outlines because, well, org mode is supposed to be a structured markup language for HTML and LaTeX export and such thing
  • “UI Themes” for Solarized and additional dark modes in the app
  • “Saved Searches” to more quickly access the results of complex searches
  • “Box Sync” to … sync to (beats me why this of all things is an add-on)

The developer provides release notes for updates in the app, which I absolutely adore for this kind of “make it your own” pro user application, to make sure I keep up-to-date with the good stuff. The tip jar that goes along with it is probably the main source of his income – at least as much as I’m concerned. The updates are really good and much appreciated.

Native macOS Notifications for Emacs Org Tasks and Appointments

Emacs is a text editor, kind of. But I use its Org mode for “keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system” – its Agenda became my daily productivity hub. It’s a calendar view of all things scheduled for the day, plus some other info interspersed: thanks to the plain text nature of the whole interface, it’s simple (albeit not easy) to re-style everything you see there. Add sub-headings, spacing, links, text, what have you.

Continue reading …

Emacs Settings for PHP Development

Teaser image

The project that I’ve been working on over the weekend, I worked on in emacs. This is part of my re-learning the basics of text editing and programming in emacs to slowly move away from TextMate when it comes to scripts. I want to move away from TextMate because I eventually want to transition to be productive on a Linux machine – that means, to create stuff in an otherwise foreign operating system. Emacs is portable, so that’s a good start.

Continue reading …

Fold Current Level-1 Heading in Emacs Org-Mode Outlines

There’s no standard shortcut to fold the current subtree of an org-mode outline. When I work in org-mode outlines, I usually am 3 or more levels deep into a so-called “subtree” and want to get back to the root item, fold it to hide the details, then drill down into another item. I use that when I am working on an app and want to have a look at a planned milestone nested deep down at a different point in the outline.

Continue reading …

Emacs for Remote SSH Python Development

Teaser image

I am using Emacs for over a year now to manage my tasks. I like how I can mix tasks with long form notes in a single outline. It’s good. We had to play with vi and emacs for a while at University. I’m very happy I got used to the very basics of both editors because I ended up using vi a lot when SSH-ing into remote machines, and now Emacs for everything else.

Continue reading …

Add Blog Post Text Template Expansion to Emacs with Org Babel

In my quest of total immersion into Emacs, I am trying to write blog posts in Emacs instead of TextMate. That means my TextMate macros are gone for good, including insertion of YAML header information. On this very blog and on, I used to type cthead and zkhead respectively, then expanded the YAML header with tab. TextMate’s great template feature even allows you to specify multiple points inside the templates to jump to by tabbing forward. Emacs works a bit differently, so I adapted the templates to request information up front instead and fill in the values.

Continue reading …

Indent Code and Lists by 4 Spaces in Emacs Markdown Mode

I noticed that my Emacs didn’t maintain the current line’s indentation when editing code blocks in Markdown (markdown-mode). I indent the first line with 4 spaces like any sane person would. When I hit enter to continue in the next line, thanks to the markdown-mode defaults, I am presented with a new line that’s properly indented visually. Only when committing to git did I notice that Emacs inserted tabs instead of spaces. Gasp!

Continue reading …

Global TODO Capture Hotkey for Emacs Org Mode on macOS

I am using GNU Emacs for a while now to do all kinds of stuff. I’m thinking about migrating away from OmniFocus as my task manager and use Org mode instead. What I like so far is the free-form list nature of Org files. I can have an outline of notes and sprinkle TODO items inside them. This way I can take notes on puzzling problems I’m working on and mark things I need to do later. This is super useful to remind myself what to clean up before a commit, for example write or amend tests or remove debug code somewhere. I like it. I got used to a lot of shortcuts already, so most of the pain of daily use is gone.

Continue reading …