[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem
From: |
Jim Diamond |
Subject: |
Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem |
Date: |
Wed, 6 Jun 2012 17:01:48 -0300 |
User-agent: |
slrn/0.9.9p1 (Linux) |
On 2012-06-05 at 22:17 ADT, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> While using 23.4 (and some other older versions) I added a hook to
>> server-visit-hook. My hook function uses the variable "dir", which is
>> meaningful at the point where server-visit-hook is called.
> What does your hook do and how does it use this `dir'?
At the risk of boring you with an overly long story...
For a long, long time I have been using a package called saveconf.el.
(I have modified it over the years, but the first two lines are
as follows:
;;; Save Emacs buffer and window configuration between editing sessions.
;;; Copyright (C) 1987, 1988 Kyle E. Jones
)
This package, originally designed for use NOT in server/daemon mode,
saves the information about what files you were working on when you
exited emacs. Unlike (my possibly incorrect) understanding of
desktop.el, it saves this information on a per-directory basis, so
that if you were editing /a/b/c/xyz.c in directory D last week and now
cd into that directory, a script I wrote will start up emacsclient
with the appropriate file (/a/b/c/xyz.c) at the appropriate line.
(Or, if I start a new instance of emacs, the information will be read
automagically and the file I was previously editing will reappear at
the correct line.)
To clarify, in directory D a file is saved which has /a/b/c/xyz.c and
the line number of (point) when I finished editing the file.
I modified (possibly in a bad way) saveconf.el for the server/client
scenario by adding a function to server-visit-hook. This function
saves the file's directory in a buffer-local variable when the file is
initially visited. This information is used when I finish editing the
buffer, so that it knows in which directory to store my information
file.
Here is my code which I believe is relevant to your question:
(require 'server)
(defvar emacsclient-dir-for-this-buffer nil
"Name of the directory emacsclient was called from for this buffer.")
(make-variable-buffer-local 'emacsclient-dir-for-this-buffer)
(defun saveconf-server-save-emacsclient-dir ()
"Save the directory from which emacsclient was called.
This is called from a place in server.el (server-visit-files)
where the variable 'dir' is equal to the directory emacsclient
was called from."
(setq emacsclient-dir-for-this-buffer dir)
)
(add-hook 'server-visit-hook 'saveconf-server-save-emacsclient-dir)
Does that answer your question?
And, if so, do you have a suggestion on the right way to get this
information I want?
Thanks.
Jim
- 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Jim Diamond, 2012/06/04
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Stefan Monnier, 2012/06/05
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem,
Jim Diamond <=
- Message not available
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Stefan Monnier, 2012/06/11
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Jim Diamond, 2012/06/11
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Stefan Monnier, 2012/06/13
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Jim Diamond, 2012/06/24
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Stefan Monnier, 2012/06/25
- Re: 24.1.50 + lexical-binding + server.el + server-visit-hook = problem, Jim Diamond, 2012/06/26