I'm trying to modify how asm-mode
does its automatic indentation.
I thought I would use the following:
(defun yasm-calculate-indentation (oldfun)
"Add the formatting for a few other keywords I like."
(cond
((looking-at-p "section") 0) ; section
((looking-at-p "global") 0) ; global
((looking-at-p "extern") 0) ; extern
(:default (oldfun))))
(add-hook 'asm-mode-hook
(lambda ()
(advice-add :around #'asm-calculate-indentation
#'yasm-calculate-indentation)))
However I'm getting the error: Unknown add-function location ‘asm-calculate-indentation’
Leaving me rather confused.
Am I adding the hook in the wrong location to be able to access that name?
I tried adding the advice from the minibuffer when editing an assembly file but it gave me the same error.
This is my first time trying to use advice so maybe that's where I'm going wrong... How can I get this to work?
oldfun
is not the name of a function, but rather a local variable whose value is a function, so it must be called as(funcall oldfun)
. (b) There is no need to calladvice-add
from a hook function. You can advise symbols before they are defined as functions; this is called forward advice. Furthermore, the hook will run every timeasm-mode
is enabled, whereas the advice needs only be registered once.