From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: .dir-locals.el Date: Thu, 08 Jan 2009 11:30:46 -0500 Message-ID: References: <200812271713.mBRHDnU3019200@mothra.ics.uci.edu> <87hc4ak6b9.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1231432265 20544 80.91.229.12 (8 Jan 2009 16:31:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Jan 2009 16:31:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Eric Schulte" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 08 17:32:17 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LKxnq-0007CY-DB for ged-emacs-devel@m.gmane.org; Thu, 08 Jan 2009 17:32:14 +0100 Original-Received: from localhost ([127.0.0.1]:59364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LKxma-0003Jo-DS for ged-emacs-devel@m.gmane.org; Thu, 08 Jan 2009 11:30:56 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LKxmV-0003Jg-KT for emacs-devel@gnu.org; Thu, 08 Jan 2009 11:30:51 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LKxmS-0003JT-Kq for emacs-devel@gnu.org; Thu, 08 Jan 2009 11:30:49 -0500 Original-Received: from [199.232.76.173] (port=35916 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LKxmS-0003JQ-FC for emacs-devel@gnu.org; Thu, 08 Jan 2009 11:30:48 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:5043 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LKxmS-0001Ix-6V for emacs-devel@gnu.org; Thu, 08 Jan 2009 11:30:48 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhIHANe4ZUlFxJt//2dsb2JhbACBbDHNH4V1gWk X-IronPort-AV: E=Sophos;i="4.37,235,1231131600"; d="scan'208";a="32027500" Original-Received: from 69-196-155-127.dsl.teksavvy.com (HELO pastel.home) ([69.196.155.127]) by ironport2-out.teksavvy.com with ESMTP; 08 Jan 2009 11:30:46 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 6A9A886E5; Thu, 8 Jan 2009 11:30:46 -0500 (EST) In-Reply-To: <87hc4ak6b9.fsf@gmail.com> (Eric Schulte's message of "Wed, 07 Jan 2009 16:08:42 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:107710 Archived-At: > (defadvice cd (after dir-locals-on-cd activate) > "Apply the variables defined in .dir-locals.el when changing > into and outof a directory in eshell." > (hack-dir-local-variables)) If you do (defadvice cd (after dir-locals-on-cd activate) (let ((buffer-file-name default-directory)) (hack-dir-local-variables))) it might get you a bit further. But note that it still won't do what you want: it'll only give you file-local-variables-alist, which you then have to apply to the buffer. Furthermore, before applying it, you'll need to un-apply those settings you had applied earlier and which were relevant to the directory in which you were before `cd'. So you'll want something like (100% guaranteed untested) (defadvice cd (around dir-locals-on-cd activate) (while eshell-previous-values (let ((x (pop eshell-previous-values))) (if (consp x) (set (car x) (cdr x)) (kill-local-variable x)))) ad-do-it (let ((buffer-file-name default-directory)) (hack-dir-local-variables)) (dolist (x file-local-variables-alist) (let ((var (car x)) (val (cdr x))) (push (if (buffer-local-p var) (cons var (symbol-value var)) var) eshell-previous-values) (set (make-local-variable var) val)))) > Is there a supported way to do this? Not. > If not should I write a new function for this? Your call. > If so should it be included in the dir-locals.el functionality? Not sure. > If not is there a reason to only allow setting local variables for > buffers visiting files? It's not obviously clear that applying .dir-locals.el to eshell like you suggest is a good idea. It seems consistent with the idea that "cd /ssh:foo:" ends up behaving like "ssh foo", tho. Maybe your suggestion to change hack-dir-local-variables so it uses default-directory rather than buffer-file-name is a good one. It seems like it would be a safe change and would allow the above advice to feel a tiny bit less hackish. Stefan