emacs

Simulating `C-u` args to lambda-wrapped functions

I build hydras for common functions in my use-pattern; sometimes it’s the C-u version that I want in my hydra. Usually this is easily done by passing a '(4) to the function. However, I have one fn that is failing at this: ("<f11>" (lambda () (interactive) (flyspell-correct-wrapper '(4))) "spell correct") ;; eval: Wrong number of arguments: (0 . 0), 1 The reason for this failure is that it turns out emacs has two ways of calling fns with prefix args.

Quickly Creating DB namespaces with shell, emacs, and init.sql

My project design includes creating a file/namespace for each database table, with a suite of CRUD operations applying to each table. The end result is that I have functions like db.my-table/CREATE, READ, UPDATE, and DELETE available for each table. The strategy is as follows: Establish the template clj file that has all your CRUD operations Obtain all table names (e.g. from init.sql) Use a script to create a matching clj file based on template (1) customized to refer to the tables from (2) 1.

Scratch buffer

I have been deep in emacs for over a decade but still never utilized the scratch buffer until I saw how much it was part of the workflow of a friend. I’ve now fixed may ways and just needed a fast way to open it, optionally in a side Window. I wrote up this quick command and bound it to a convenient hydra key and now I have one-stroke scratch buffer opening.

Printing from the Command Line (and emacs)

Helpful Resource: https://www.cyberciti.biz/tips/linux-unix-sets-the-page-size-to-size.html Command Note lp print with good defaults lpc status all See printer settings lprm clear print jobs export PRINTER='Sharp-MX-2700N’ Set the target printer before printing lpoptions See available options I generally print PDFs, using the excellent pdf-tools. This provides C-c C-p which will print with the $PRINTER and settings you’ve configured, but sometimes you need more customization.

How to find the highlight face in emacs?

https://www.reddit.com/r/emacs/comments/fcernd/how_to_find_the_highlight_face_in_emacs/ The doom themes I try all have too un-obvious a background color for selected text – the text of future matches when doing an interactive search, or the highlight color of matches while I’m spell-checking, or the mark area when I am highlighting a section of text. I assume these are all the same face, because they look the same. Does anyone know which face this should be so I can customize it, and secondly, can tell me how I could figure out the answer to this question on my own without reading a lot of code?

Image previews with helm-follow-mode

When using helm-find-file you can use helm-follow-mode to cause images to show themselves as you move over them, replacing the need to start up some other program to preview images. The shortcut for that while within helm-find-file is C-c C-f. By default, you will be ejected from the follow mode as soon as you move over a non-image file. The following customizatoin will give it a little more tolerance: (setq helm-follow-input-idle-delay 0.

Emacs Gnus delay (schedule) email sending

I always forget how to schedule my emails and it’s a pain to look up because Gnus uses the word “delay” instead of “schedule”, so here it is. Note that for gnus message scheduling (delaying) to work, you will need a line like this in your init file: (gnus-delay-initialize) In a message buffer with Gnus you can execute C-c C-j (gnus-delay-article) to schedule an item for a later sending. After that I see it scheduled in my nndraft:delayed folder with a “date” line describing the time at which it will be sent.

Bulk multi-line find and replacement with Dired instead of SED

Scenario: I have a directory full of code files (in this case, 51 of them) that each need a find-and-replace executed; however, it is adding a line to part of the code, so replace one line with several. This means that SED cannot do the trick; you’ll get errors like, > > > sed: -e expression #1, char 49: unterminated `s' command Rather than spending the time figuring out how to encode things for SED, the simplest solution was just to use emacs inimitable dired.

Newsticker failure

https://emacs.stackexchange.com/questions/55125/newsticker-failure-wrong-type-argument-listp/55126 Suddenly newsticker is failing to load. I get the following stack trace on error. I have made no recent upgrades. Debugger entered–Lisp error: (wrong-type-argument listp \.\.\.) newsticker–stat-num-items(Bus\ Driver\ Diaries new immortal) apply(newsticker–stat-num-items Bus\ Driver\ Diaries (new immortal)) newsticker–stat-num-items-for-group(Bus\ Driver\ Diaries new immortal) newsticker–treeview-tree-get-tag(“Bus Driver Diaries” nil “feeds-4”) #f(compiled-function (g) #<bytecode 0x2370c3d>)(“Bus Driver Diaries”) mapcar(#f(compiled-function (g) #<bytecode 0x2370c3d>) (“Sacha Chua” “Good Questions” “Quote of the day” “Tory C Anderson” “Bus Driver Diaries” “Dadacity” “Austen Knows Best” “Every Day Miracles” “Vi Hart” “Brain Pickings” “Inside Clojure” “Reddit Clojure” “Reddit Emacs” “Reddit Postgres” “Reddit Programming Languages”))

How to Save an Emacs Keyboard Macro Permanently

Courtesy of gnu manual, we can permanently save a keyboard macro for future use: https://www.gnu.org/software/emacs/manual/html_node/emacs/Save-Keyboard-Macro.html The steps are as follows: perform macro (start with f3, then do your stuff and return to where you started, then stop recording with <f4>) name that macro kmacro-name-last-macro insert macro code into buffer insert-kbd-macro <RET> macro-name I want the ability to go into a let-form and, in the spirit of REPL debugging and development, bind the X VAL part of a (let [ .