Compared to extending via workarounds, extending in “pure Lisp” can be both easier and harder, as we are still bounded by coding conventions and existing code, and one cannot possibly extend everything without breaking some of them. Let’s start by overriding a single function. For example, when exporting Org-mode files to HTML, Org-mode defaults to generating random HTML ID anchors. To change that, you just override the org-export-get-reference function that generates the IDs, right? (advice-add #'org-export-get-reference :around #'org-html-stable-ids--get-reference) Oh no! It turns out that, sometimes Org-mode directly calls org-html--reference, bypassing our override. That means we also need to redirect org-html--reference: (advice-add #'org-html--reference :override #'org-html-stable-ids--reference) Problem solved? No. Conventionally, Emacs Lisp code uses double dashes to tell the users “this function is internal”, as is in the org-html--reference name. Yes, by being free to extend any part of the editor, you are free to modify any internal functions or states, in a way that may or may not be problematic under specific circumstances, with code that can be broken in any future updates. And it’s not the end of it. The el-patch package allows you to apply “patches” on most any Lisp code to modify behaviours nested deep inside a function: ;; Original function (defun company-statistics--load () "Restore statistics." (load company-statistics-file 'noerror nil 'nosuffix)) ;; Patching (el-patch-feature company-statistics) (with-eval-after-load 'company-statistics (el-patch-defun company-statistics--load () "Restore statistics." (load company-statistics-file 'noerror ;; The patch (el-patch-swap nil 'nomessage) 'nosuffix))) ;; Patched version (defun company-statistics--load () "Restore statistics." (load company-statistics-file 'noerror 'nomessage 'nosuffix)) Luckily, el-patch provides el-patch-validate so that you can worry less about your patches going ineffective or une...
First seen: 2026-01-02 03:13
Last seen: 2026-01-02 13:14