elisp

Applying a replacement map to characters in emacs

The Problem I have text in Cyrillic and need to replace individual characters with their transliteration. I have a tiny json of the mappings: {"в": "v","а": "a","ф": "f","ё": "yo","д": "d","ж": "zh","ы": "y","э": "e","л": "l","щ": "shch","я": "ya","й": "j","у": "u","н": "n","г": "g","с": "s","п": "p","ч": "ch","б": "b","х": "kh","е": "ye","ъ": "\"","з": "z","ю": "yu","ь": "'","ш": "sh","о": "o","к": "k","и": "i","ц": "ts","м": "m","т": "t","р": "r"} And I have a number of files that contain lists with entries like

Why isn't elisp nil the empty string?

Sometimes in emacs nil is not punned well enough. I found this when using Telephone Line, when the crucial problem is that nil can’t be construed as a string (why isn’t it the empty string when strings are wanted?). Error during redisplay: (eval (telephone-line-add-subseparators ‘((lambda (face) (telephone-line-raw (if (telephone-line-selected-window-active) (progn (propertize battery-mode-line-string ‘mouse-face ‘(:box 1))))))) telephone-line-cubed-hollow-left ‘evil)) signaled (wrong-type-argument stringp nil) [36 times] I fixed this manually with some extra code, when writing such cruft feels like a slight against lisps:

Critique my org elisp

Someday I’ll get around to writing about code quality in elisp, but for now I don’t know it well enough to know idioms and avoid code-smell. Orgmode has a massive code-base and the documentation has a hard-time keeping up, so I asked, How is the following code, aimed at getting the list of header tags and making them into a comma-separated string? org-get-tags didn’t work because I needed to support when the cursor is in the text of an entry, not just on the headline.

Improving my elisp by building an API to my YOURLS shortener

Until recently I was well-served by now-derelict url-shortener which worked well. It’s a cool library – very general, supporting a variety of shortening options. But when it broke, it was annoyingly complex to fix. Plus, I needed the excuse to sharpen my elisp skills a bit. The result is below. I learned a lot of good things (big thanks to the Reddit emacs community), including: Using defcustom to create customs groups for use in emacs’ nice customization tooling Utilizing url-build-query-string to build my… well, you know.

Easy incrementing find and replace in emacs

I start with a list with a bunch of entries like this: newsletter W02 newsletter W02 newsletter W02 newsletter W02 EDIT: New Solutions It turns out that emacs automatically initializes a variable that tracks how many interations your replacement function has made, and in lisp mode you can get to it with \#. This way, the single line necessary to number all my newsletters becomes this: W\(02\) → W\,(format "%02d" (+ 4 \#))) and, of course, you can adjust that 4 to whatever you need it to be for your starting digit.

Emacs save custom agenda filter views

If you work much with the Orgmode agenda you soon find that you can have a huge amount of appointments and todo tasks to deal with. You can sort these by putting tags on the, either straight from the agenda view (with :) or in the actual org file (with C-c while point is over a headline). You can then use those tags to filter and search your agenda (from agenda view, with / and \ followed by TAB).

Orgmode Agenda in New Frame Window

If you work much with the Orgmode agenda you soon find that you can have a huge amount of appointments and todo tasks to deal with. You can sort these by putting tags on the, either straight from the agenda view (with :) or in the actual org file (with C-c while point is over a headline). You can then use those tags to filter and search your agenda (from agenda view, with / and \ followed by TAB).