[Top][All Lists]

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

Re: Change a symbol's plist member with (let ...)?

From: Thorsten Jolitz
Subject: Re: Change a symbol's plist member with (let ...)?
Date: Fri, 14 Mar 2014 23:25:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Nicolas Richard <address@hidden> writes:

> Thorsten Jolitz <address@hidden> writes:
>> #+begin_src emacs-lisp
>>   (plist-get (symbol-plist 'outline-mode)
>>              'derived-mode-parent) 
>> #+end_src
> (get 'outline-mode 'derived-mode-parent) looks better to me.
>> For the sake of this example, say I want to "con" the function
>> `derived-mode-p' and make it believe outline-mode is actually derived
>> from lisp-mode (or so ...).
>> How to do this with working code (not pseudo-code)?
> I'm in message-mode right now, and :
>   (derived-mode-p 'text-mode)
> returns: text-mode
> But
> (letf (((get major-mode 'derived-mode-parent) 'special-mode))
>            (derived-mode-p 'text-mode))
> returns nil.

I have to get more involved with this cl stuff it seems ... 

> You could also let-bind major-mode to whatever the code you're calling
> expects.
>> Or do I have to do it the pedestrian way: do plist-get first, store the
>> original value, do plist-put with the new value, call ad-do-it, and then
>> restore the original value again with plist-put?
> If you already know what you want the function to return, you could
> simply make
> the advice return that value and not call ad-do-it at all.

yes, I just figured out that a simple (conditional) after advice that sets
ad-return-value to t is all I need. 

Thanks for the tips.


reply via email to

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