From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Perry Smith Newsgroups: gmane.emacs.help Subject: Help needed with defadvice Date: Thu, 21 Nov 2013 20:45:26 -0600 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Content-Type: multipart/signed; boundary="Apple-Mail=_E8EA1663-3263-401C-859A-E2835A8F9F32"; protocol="application/pgp-signature"; micalg=pgp-sha1 X-Trace: ger.gmane.org 1385088354 29180 80.91.229.3 (22 Nov 2013 02:45:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Nov 2013 02:45:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 22 03:45:59 2013 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 1Vjgko-0004H2-Jq for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Nov 2013 03:45:58 +0100 Original-Received: from localhost ([::1]:36400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjgko-0001rd-4E for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Nov 2013 21:45:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjgkV-0001q6-S2 for help-gnu-emacs@gnu.org; Thu, 21 Nov 2013 21:45:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjgkM-0003Ce-DJ for help-gnu-emacs@gnu.org; Thu, 21 Nov 2013 21:45:39 -0500 Original-Received: from mail-ob0-x22d.google.com ([2607:f8b0:4003:c01::22d]:47603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjgkM-0003CJ-04 for help-gnu-emacs@gnu.org; Thu, 21 Nov 2013 21:45:30 -0500 Original-Received: by mail-ob0-f173.google.com with SMTP id gq1so710387obb.4 for ; Thu, 21 Nov 2013 18:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:message-id:date:to:mime-version; bh=dHHA8LYcS0r2jbBVRKqXE7y2E6QHpaFoqVZp8J8t1XU=; b=V+wBc8QEGXPccvj47Ym1IOtrwcN2KDGJkOjVmEzuyOWmEfhmKEmul8UY6NY/5JBD4c 9TbnG+tKQgAgVdF1RAKf7b1xvU4J8rAKOBArWxvI7qT+tbL0Z5hzKc2VbSuQcPgbnW8B X51jIh1J6V3p6csfZcCIiKmupCyGgm6m42aOR1KGi7vBFEuPzNyYd5wR9gR3FaNzsaa7 bP8N4i28j14Fzao7OzWVlRkd7CFvuVVWY3y1/Tew/I/h/tNgbT3FhlHK6gXu80GJZp5j KCUg9VXRxqJBpE62uyAbcRP/vJFdQ4DiLpQR8tZVxlMdo2kbsz87AJzj5aRyXaZ2xHkQ MBrw== X-Received: by 10.182.71.82 with SMTP id s18mr8501424obu.9.1385088329024; Thu, 21 Nov 2013 18:45:29 -0800 (PST) Original-Received: from magicbook.austin.ibm.com ([32.97.110.54]) by mx.google.com with ESMTPSA id s14sm58827371oeo.1.2013.11.21.18.45.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Nov 2013 18:45:28 -0800 (PST) X-Mailer: Apple Mail (2.1510) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::22d 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:94564 Archived-At: --Apple-Mail=_E8EA1663-3263-401C-859A-E2835A8F9F32 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I have this defadvice: (defadvice get-buffer-create (around inherit activate) (let ((set-list (mapcar '(lambda ( v ) (cons v (symbol-value v))) inherited-alist))) (with-current-buffer ad-do-it=20 (mapcar '(lambda ( c ) (message "Setting %s to %s inside %s" (car c) (cdr c) (buffer-name = (current-buffer))) (set (car c) (cdr c))) set-list)))) inherited-alist is a list of symbols that I add to. When a buffer is = created, I run through the list of variables and get their values as = seen from the current buffer. I then call get-buffer-create (via = ad-do-it) and do a set on each of the variables. The "message" is there = just for debugging. I get the messages like I expect .... e.g. "Setting = foo to dog inside cat.c" or whatever. All the symbols in = inherited-alist are buffer-local variables. When I get done and get in cat.c and ask for the value of foo, it is = always nil. I have almost the same function: (defun inherit-from-buffer ( buf ) "Set all inherited variables of current buffer to those values of BUF" (interactive "bBuffer: ") (message "Inheriting from %s to %s" buf (buffer-name = (current-buffer))) (let ((curbuf (current-buffer)) set-list) (set-buffer buf) (setq set-list (mapcar '(lambda ( v ) (cons v (symbol-value v))) inherited-alist)) (set-buffer curbuf) (mapcar '(lambda ( c ) (message "Setting %s to %s inside %s" (car c) (cdr c) (buffer-name (current-buffer))) (set (car c) (cdr c))) set-list))) which I call interactively from inside cat.c and give it an argument of = another buffer to inherit from and it works as expected. The messages = are the same, everything is the same except the function, after the = fact, works but doing roughly the same from inside a advice does not. I've been poking at this for most of today and can't figure out what is = happening. Thank you for your help, Perry --Apple-Mail=_E8EA1663-3263-401C-859A-E2835A8F9F32 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJSjsVGAAoJEIPoMwNgGirlSDYH/jR3e7BbDXsLyw7vl76t3EQg qAFbqZZ9a505D3OeR7Iuma+fY/tJqmY2ykSU+TYa4QTABZgj6YMec5CGyfUjTbll 3s+8NAjvnONqNTUymjjETRqBTOXqaOJqpvEU9kEoVvWtduHTxN3kdPDA/OSBNF45 Z5x47b5gFaidTkJ6lEWeHiIB/OEKtW7rJVs9UkV2JfEGu8UmThETiJccuisPrZz+ 0Bw19nDzOXFPoMhMW5eKn6cOpu7hbEySV4nT1YiWhuzejgTul4KHpWhij4QIkJKT +wxFsMlALhpu8xmqVPF1dadclb8YbNs9mgl/Hh4CTlFeiOuAoWvjkW8qq9/C9VQ= =edyJ -----END PGP SIGNATURE----- --Apple-Mail=_E8EA1663-3263-401C-859A-E2835A8F9F32--