December 4, 2021

Unprettify Ligatures With Idle Timer in Emacs

Emacs prog-mode provide prettify symbol for ligatures. It also has a prettify-symbols-unprettify-at-point option to unprettify symbols when cursor is on the symbol. Below is code snippet to only unprettify when emacs is idle for 1 second.

(after! prog-mode
  ;; unprettify when idle for 1 seconds
  (defadvice! +prettify-symbols--post-command-hook (orig-fn)
    :around #'prettify-symbols--post-command-hook
    (run-with-timer 1 nil
                    (cmd! (let ((ti (current-idle-time)))
                            (when (or (> (nth 1 ti) 0)
                                      (> (nth 2 ti) 900000))
                              (funcall orig-fn)))))))

Note: after!, defadvice!, cmd! are all macros from doom-emacs.

December 4, 2021 emacs



Previous post
Inject Script Into Pages As Early As Possible With Web Extension Content Script
Next post
List All Chrome Extensions Pragmatically