From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: window local var? Date: Mon, 6 Sep 2010 17:34:47 -0700 Message-ID: References: <1283772789-sup-3909@nixos> <1283799526-sup-6956@nixos> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1283819722 17476 80.91.229.12 (7 Sep 2010 00:35:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Sep 2010 00:35:22 +0000 (UTC) Cc: help-gnu-emacs To: Marc Weber Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 07 02:35:19 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Osm9e-00015g-VJ for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Sep 2010 02:35:19 +0200 Original-Received: from localhost ([127.0.0.1]:39806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Osm9e-00055b-FE for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Sep 2010 20:35:18 -0400 Original-Received: from [140.186.70.92] (port=51106 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Osm9G-00055W-Tp for help-gnu-emacs@gnu.org; Mon, 06 Sep 2010 20:34:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Osm9F-0006eq-LC for help-gnu-emacs@gnu.org; Mon, 06 Sep 2010 20:34:54 -0400 Original-Received: from smtpauth16.prod.mesa1.secureserver.net ([64.202.165.22]:47423) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Osm9F-0006ee-AU for help-gnu-emacs@gnu.org; Mon, 06 Sep 2010 20:34:53 -0400 Original-Received: (qmail 5004 invoked from network); 7 Sep 2010 00:32:53 -0000 Original-Received: from unknown (209.85.215.169) by smtpauth16.prod.mesa1.secureserver.net (64.202.165.22) with ESMTP; 07 Sep 2010 00:32:52 -0000 Original-Received: by eyh5 with SMTP id 5so2548237eyh.0 for ; Mon, 06 Sep 2010 17:34:47 -0700 (PDT) Original-Received: by 10.213.31.84 with SMTP id x20mr2642855ebc.46.1283819687266; Mon, 06 Sep 2010 17:34:47 -0700 (PDT) Original-Received: by 10.213.7.17 with HTTP; Mon, 6 Sep 2010 17:34:47 -0700 (PDT) In-Reply-To: <1283799526-sup-6956@nixos> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74907 Archived-At: Note that I'm sort of am Emacs/Lisp newbie myself, so I'd appreciate it if anyone on the list who thinks there's a better way to do this would share. Frames have "parameters". You can set them with "(modify-frame-parameters frame '((var . value)))" and get them with "(frame-parameter frame var)". The current frame is "(selected-frame)". Use modify-all-frame-parameters instead of modify-frame-parameters to change the value for all existing frames and all frames created in the future. One of the properties that frames start out with is 'environment, which contains all the client's environment variables, including PWD. So, to find the current directory, you could use: (let ((env (frame-parameter (selected-frame) 'environment)) (current nil) (dir nil)) (while (and (not dir) t) (setq current (pop env)) (if (string-equal "PWD=" (subseq current 0 4)) (setq dir (subseq current 4)))) dir) There's a buffer-local variable called default-directory that you can set to control where grep gets run, like this: "(push (lambda() (setq default-directory some-directory)) grep-setup-hook)". On Mon, Sep 6, 2010 at 12:00 PM, Marc Weber wrote: > Hi Andrea, > > I know how to use grep. > > I don't want to use the buffer directory. > I want to use the directory from which I started Emacs (or emacs-client) > > In order to do so I have to remember the directory when > > a) launching Emacs > > b) launching Emacs-client > > However b) must not override the setting set in a) > a) and b) have different windows / frames (however you call them). > That's why I was asking for such a frame local var. > > Thanks > Marc Weber > >