help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: window local var?


From: PJ Weisberg
Subject: Re: window local var?
Date: Mon, 6 Sep 2010 17:34:47 -0700

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 <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]