help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replacing a function with another one


From: lee
Subject: Re: replacing a function with another one
Date: Sun, 09 Mar 2014 18:58:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> lee <address@hidden> writes:
>
>> is there a way to replace a function with another one other than
>> re-defining the original function?
>>
>> Using (defalias) doesn´t seem to work for this.
>
> Although it's probably cleaner to use advices, `defalias' should also
> work.  How did you call it?

The function is called by the hi-lock-mode itself.  I used defalias in
another mode.  It´s basically like this:


in mode A:

(defun mode-a-function-one (mode-a-function-two))


in mode B:

(defun mode-a-function-two-replacement)
(defalias 'mode-a-function-two 'mode-a-function-two-replacement)
(defun mode-b-function (mode-a-function-one))


It was possible to re-define 'mode-a-function with mode B, provided that
mode A was already loaded at the time the function was re-defined ---
which makes sense because otherwise there is nothing to re-define, and
mode A may even re-define the function of mode B when it´s loaded after
mode B is loaded.  The defalias somehow didn´t kick in.

Defadvice shines.  I wonder who invented that ...


And re-defining functions just like that?  Isn´t that a rather dangerous
and potentially troublesome feature?


-- 
Knowledge is volatile and fluid.  Software is power.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]