Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

emacsclient under windows

78 views
Skip to first unread message

Doug Lewan

unread,
Jun 20, 2012, 9:53:58 AM6/20/12
to help-gn...@gnu.org

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

 

 

Juanma Barranquero

unread,
Jun 20, 2012, 10:00:34 AM6/20/12
to Doug Lewan, help-gn...@gnu.org
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?

    Juanma

Juanma Barranquero

unread,
Jun 20, 2012, 10:01:49 AM6/20/12
to Doug Lewan, help-gn...@gnu.org
> What version of Emacs are you using, and which problem are you seeing
> with windows-style paths?

[Or perhaps "which version" and "what problem". Damn impersonal
interrogative pronouns.]

    Juanma

Doug Lewan

unread,
Jun 20, 2012, 10:23:08 AM6/20/12
to Juanma Barranquero, help-gn...@gnu.org
Juanma,

Thanks for catching my transgression.

emacs-version: 23.4
OS: CYGWIN on Windows 7

The symptom:

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-gn...@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?
>
>     Juanma

Juanma Barranquero

unread,
Jun 20, 2012, 10:29:14 AM6/20/12
to Doug Lewan, help-gn...@gnu.org
On Wed, Jun 20, 2012 at 4:23 PM, Doug Lewan <do...@shubertticketing.com> wrote:

> Thanks for catching my transgression.

Transgression?

> emacs-version: 23.4
> OS: CYGWIN on Windows 7

I confess I know next to nothing about the Cygwin port, but, are you
mixing Cygwin with a non-Cygwin Emacs build, perhaps?

    Juanma

Eli Zaretskii

unread,
Jun 20, 2012, 12:41:19 PM6/20/12
to help-gn...@gnu.org
> From: Doug Lewan <do...@shubertticketing.com>
> Date: Wed, 20 Jun 2012 14:23:08 +0000
>
> emacs-version: 23.4
> OS: CYGWIN on Windows 7
>
> The symptom:
>
> 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.

Doug Lewan

unread,
Jun 21, 2012, 11:57:15 AM6/21/12
to help-gn...@gnu.org

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=shuberttic...@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shuberttic...@gnu.org] On Behalf Of Doug Lewan
Sent: Wednesday, 2012 June 20 09:54
To: help-gn...@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?

Ken Goldman

unread,
Jun 21, 2012, 3:42:43 PM6/21/12
to help-gn...@gnu.org
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.

On 6/20/2012 10:23 AM, Doug Lewan wrote:
> Juanma,
>
> Thanks for catching my transgression.
>
0 new messages