all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: PJ Weisberg <pj@irregularexpressions.net>
To: Marc Weber <marco-oweber@gmx.de>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: window local var?
Date: Mon, 6 Sep 2010 17:34:47 -0700	[thread overview]
Message-ID: <AANLkTim4qaHTGYXGWOsOVAdBCLBySCWsCki5xJ6H3_-d@mail.gmail.com> (raw)
In-Reply-To: <1283799526-sup-6956@nixos>

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 <marco-oweber@gmx.de> 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
>
>



  reply	other threads:[~2010-09-07  0:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06 11:39 window local var? Marc Weber
2010-09-06 18:43 ` Andrea Crotti
2010-09-06 19:00   ` Marc Weber
2010-09-07  0:34     ` PJ Weisberg [this message]
2010-09-07 16:12       ` PJ Weisberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTim4qaHTGYXGWOsOVAdBCLBySCWsCki5xJ6H3_-d@mail.gmail.com \
    --to=pj@irregularexpressions.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=marco-oweber@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.