Let us collect the facts:
Perhaps the simplest method:
(defun old-fun (a b c)
(interactive "sa: \nsb: \nsc: ")
(message "{(old-fun %s %s %s) in buffer %s}"
a b c
(current-buffer)))
(defun my-transform (a)
"Special transformation when `my-minor-mode' is active."
(message "{(my-transform %s) in buffer %s}" a (current-buffer)))
(define-minor-mode my-minor-mode
"Replace `old-fun' with `my-special-fun'.")
(defun around-old-fun (fun a b c)
"Override advice which replaces `old-fun' with `my-new-functions'.
Falls back to `old-fun' when no function is registered at `my-new-functions'."
(if my-minor-mode
(funcall fun (my-transform a) b c)
(funcall fun a b c)))
(advice-add 'old-fun :around #'around-old-fun)
The appearance of the advice in the doc-string of old-fun
is a nuisance you have to endure in buffers where my-minor-mode
is not active.
Appendix:
The simple implementation of symbol-function
does not allow for buffer-local values:
DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
doc: /* Return SYMBOL's function definition, or nil if that is void. */)
(Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
return XSYMBOL (symbol)->u.s.function;
}
In contrast there follows the definition of symbol-value
:
Lisp_Object
find_symbol_value (Lisp_Object symbol)
{
struct Lisp_Symbol *sym;
CHECK_SYMBOL (symbol);
sym = XSYMBOL (symbol);
start:
switch (sym->u.s.redirect)
{
case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start;
case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym);
case SYMBOL_LOCALIZED:
{
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
swap_in_symval_forwarding (sym, blv);
return (blv->fwd.fwdptr
? do_symval_forwarding (blv->fwd)
: blv_value (blv));
}
case SYMBOL_FORWARDED:
return do_symval_forwarding (SYMBOL_FWD (sym));
default: emacs_abort ();
}
}
DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0,
doc: /* Return SYMBOL's value. Error if that is void.
Note that if `lexical-binding' is in effect, this returns the
global value outside of any lexical scope. */)
(Lisp_Object symbol)
{
Lisp_Object val;
val = find_symbol_value (symbol);
if (!EQ (val, Qunbound))
return val;
xsignal1 (Qvoid_variable, symbol);
}
The line
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
in find_symbol_value
retrieves the buffer local value of the symbol.