Defadvice Is Text Editor Superglue

The Emacs advice system lets you modify the code running Emacs in a simple way. For example, if you wanted to change one line in a package you use to do something different or fix a bug before the maintainers release a new version, you can “advise” code to do what you want.

Here’s a recent example from my init.el that wraps a function to fix a bug in my setup:

;; ox-hugo doesn't set the `relref` path correctly so we need to
;; tell it how to do it
(defun my/org-id-path-fix (strlist)
  (file-name-nondirectory strlist))

(advice-add 'org-export-resolve-id-link :filter-return #'my/org-id-path-fix)

See also: