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

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

Re: hijack C function, use it transparently with in-between layer


From: Phillip Lord
Subject: Re: hijack C function, use it transparently with in-between layer
Date: Mon, 06 Jun 2016 12:30:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux)

Barry Margolin <barmar@alum.mit.edu> writes:

> In article <868tyjnghn.fsf@student.uu.se>,
>  Emanuel Berg <embe8573@student.uu.se> wrote:
>
>> The truth is down there!
>> 
>> (defvar old-message)
>> (fset 'old-message (symbol-function #'message))
>> 
>> (defun message (format-string &rest args)
>>   (unless (member format-string
>>                   '(
>>                     "It was just another system of control."
>>                     "Mark set"
>>                     ))
>>       (apply `(old-message ,format-string ,@args) )))
>> 
>> ;; test:
>> ;;
>> ;;  (message "%s - %s" "1" "2")
>> ;;  (message "Break on thru to the other side.")
>> ;;  (message "It was just another system of control.")
>> ;;  (message "Mark set")
>
> Shouldn't you do this using advice?


Advice only works partially (as I expect this will). The message
function is also called directly in the C layer. Advice will not capture
those cases.

Phil



reply via email to

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