From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.help Subject: Re: Change a symbol's plist member with (let ...)? Date: Fri, 14 Mar 2014 22:37:29 +0100 Message-ID: <87iorg31ie.fsf@yahoo.fr> References: <87wqfwo4yp.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1394833061 26100 80.91.229.3 (14 Mar 2014 21:37:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Mar 2014 21:37:41 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Thorsten Jolitz Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 14 22:37:50 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WOZna-0005Lj-8y for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Mar 2014 22:37:50 +0100 Original-Received: from localhost ([::1]:47192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOZnZ-0002NA-It for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Mar 2014 17:37:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOZnI-000277-NH for help-gnu-emacs@gnu.org; Fri, 14 Mar 2014 17:37:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOZnA-0002xa-VG for help-gnu-emacs@gnu.org; Fri, 14 Mar 2014 17:37:32 -0400 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:60855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOZnA-0002xR-Pb for help-gnu-emacs@gnu.org; Fri, 14 Mar 2014 17:37:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EANV1I1OkD4Xx/2dsb2JhbABZxhGBL3SCJQEBAQMBeQULCAMOEyUPAQQNPBOHZAEDCQiyQJoEAUoNhzoXh2KEbYIYB4Q4BJZYgW2GNYYxhUiDLjw Original-Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 14 Mar 2014 22:37:22 +0100 In-Reply-To: <87wqfwo4yp.fsf@gmail.com> (Thorsten Jolitz's message of "Fri, 14 Mar 2014 22:17:18 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 164.15.128.112 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96514 Archived-At: Thorsten Jolitz 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. 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. -- Nico.