I'd like to use emacsclient as an editor under windows. That is I'd like to have it be the default editor for an application that we use.
Of course, that application [sometimes] uses windows-style paths and those paths aren't handled well by either emacs or emacsclient. (It looks like both, I'm guessing.)
Is there a "correct" and "natural way" of getting emacs to recognize things like X:\your\name\here?
,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224
On Wed, Jun 20, 2012 at 3:53 PM, Doug Lewan <do...@shubertticketing.com> wrote:
> Of course, that application [sometimes] uses windows-style paths and those
> paths aren't handled well by either emacs or emacsclient. (It looks like
> both, I'm guessing.)
What version of Emacs are you using, and which problem are you seeing
with windows-style paths?
If I run emacsclient X:\your\name\here in one place, then emacs sees that as a simple filename, so it tries to find, e.g. /home/dougl/src/X:\your\name\here (if the client was run in C:\cygwin\home\dougl\src).
> -----Original Message-----
> From: Juanma Barranquero [mailto:lek...@gmail.com]
> Sent: Wednesday, 2012 June 20 10:01
> To: Doug Lewan
> Cc: help-gnu-em...@gnu.org
> Subject: Re: emacsclient under windows
> On Wed, Jun 20, 2012 at 3:53 PM, Doug Lewan
> <do...@shubertticketing.com> wrote:
> > Of course, that application [sometimes] uses windows-style paths and
> those
> > paths aren't handled well by either emacs or emacsclient. (It looks
> like
> > both, I'm guessing.)
> What version of Emacs are you using, and which problem are you seeing
> with windows-style paths?
> If I run emacsclient X:\your\name\here in one place, then emacs sees that as a simple filename, so it tries to find, e.g. /home/dougl/src/X:\your\name\here (if the client was run in C:\cygwin\home\dougl\src).
That's because you are using a Cygwin build of Emacs, which doesn't
recognize native Windows file names without help.
Use the native Windows build of Emacs, and your problems will be gone.
Well, I never found a "natural" way to handle DOS pathnames, but the following seems to do what I want.
(defun dos-find-file-hook ()
"Handle DOS path names by converting them to CYGWIN paths."
(let ((fname "dos-find-file-hook")
(dos-path-re ".+/\\(?1:.\\):\\(?2:.+$\\)")
(dos-drive)
(dos-path)
(cygwin-path)
(filename (buffer-file-name))
(dos-to-cygwin-path (lambda (p)
(let ((ret p))
(while (string-match (regexp-quote "\\") ret)
(setq ret (concat (substring ret 0 (match-beginning 0)) "/" (substring ret (match-end 0)))))
ret))))
(cond ((string-match dos-path-re filename)
(setq dos-drive (substring filename (match-beginning 1) (match-end 1)))
(setq dos-path (substring filename (match-beginning 2) (match-end 2)))
(setq cygwin-path (concat "/cygdrive/"
dos-drive
;; Ensure a '/' here.
(unless (string-match (concat "^" (regexp-quote "\\")) dos-path) "/")
(funcall dos-to-cygwin-path dos-path)))
(find-file cygwin-path)
;; emacs under CYGWIN is smart enough to know that this is the same file,
;; so we don't have to clean up.
;; I.e. No need to kill a buffer named after a DOS file.
)
(t t))))
(add-hook 'find-file-hooks 'dos-find-file-hook)
,Doug
From: help-gnu-emacs-bounces+dougl=shubertticketing....@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shubertticketing....@gnu.org] On Behalf Of Doug Lewan
Sent: Wednesday, 2012 June 20 09:54
To: help-gnu-em...@gnu.org
Subject: emacsclient under windows
I'd like to use emacsclient as an editor under windows. That is I'd like to have it be the default editor for an application that we use.
Of course, that application [sometimes] uses windows-style paths and those paths aren't handled well by either emacs or emacsclient. (It looks like both, I'm guessing.)
Is there a "correct" and "natural way" of getting emacs to recognize things like X:\your\name\here?
,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224
I stay away from cygwin. I use gnuserv/gnuclient and it works well
under windows. I set many file associations to gnuclientw, and double
click works. Drag and drop from the desktop or Windows Explorer also works. Tilde works. Etc.
> If I run emacsclient X:\your\name\here in one place, then emacs
> sees that as a simple filename, so it tries to find, e.g.
> /home/dougl/src/X:\your\name\here (if the client was run in
> C:\cygwin\home\dougl\src).