[Top][All Lists]

[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 21:57:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> lee <address@hidden> writes:
>> Defadvice shines.  I wonder who invented that ...
> The file header says it was Hans Chalupsky.
> Note that defadvice has now been obsoleted by a new implementation:
> nadvice.el.  You can do all of the stuff that defadvice can, but it has
> cleaner and simpler syntax and semantics.  If this is new to you, you
> may want to start learning with the new mechanism.

Hm, that´s probably the reason why defadvice doesn´t appear in the

So I guess should use advice-add instead --- and I can´t figure out how
to get that to work.  I need to access the argument passed to the
function the advice is for, too.  I tried to find examples, without

What I have is:

(defadvice hi-lock-set-file-patterns (after 
lsl-hi-lock-set-file-patterns-advice activate)
  (setq hi-lock-interactive-patterns (ad-get-arg 0)))

How would I do the same with add-advice (or whatever is appropriate)?

> trouble.  Critical are changes in the sources that change syntax or
> semantic of the original function, so expect that some of your advices
> may stop working in future Emacs releases.

Yes, that´s exactly what I´m trying to avoid.  There is no way to detect
when something changes in hi-lock.el in such a way that what I´m doing
doesn´t work anymore, or is there?  Suddenly finding out that what I´m
trying to do doesn´t work anymore won´t be so great.

Taking a copy of hi-lock-mode and modify it isn´t a good solution,
either.  There may be changes to the mode which my own version wouldn´t

One change I´m thinking about is keeping the highlighting-patterns in a
separate buffer and applying them to several buffers.  That way, you can
have several files that all use the same highlighting-patterns which
were generated on the fly, centralised for the whole project (or some
files of it).  That´ll probably require quite a few modifications.

Knowledge is volatile and fluid.  Software is power.

reply via email to

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