unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: problems with emacsclient started by cygwin programs (mswindows)
@ 2011-06-27 20:43 layer
  2011-06-30 16:17 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: layer @ 2011-06-27 20:43 UTC (permalink / raw)
  To: emacs-devel

OK, changes below for my proposed hook.  Comments welcome.

If I've not submitted this correctly and there's a FAQ about
submitting, please point me to it and I'll gladly do it some other
way.

Thanks.

Kevin

$ diff -u /usr/share/emacs/23.2/lisp/server.el server.el
--- /usr/share/emacs/23.2/lisp/server.el	2010-04-10 12:31:19.000000000 -0700
+++ server.el	2011-06-27 13:36:14.000000000 -0700
@@ -145,6 +145,14 @@
   :group 'server
   :type 'hook)
 
+(defcustom server-filename-frob-function nil
+  "Hook run on filename passed by client (using the -file in the protocol)
+used to possibly transform the filename in a form better suited for use
+by the Emacs server.  This might include transforming Cygwin paths on
+Windows into something the Emacs server can use."
+  :group 'server
+  :type 'hook)
+
 (defvar server-process nil
   "The current server process.")
 
@@ -988,6 +996,8 @@
 		  (let ((file (pop command-line-args-left)))
 		    (if coding-system
 			(setq file (decode-coding-string file coding-system)))
+		    (when server-filename-frob-function
+		      (setq file (funcall server-filename-frob-function file)))
                     (setq file (expand-file-name file dir))
 		    (push (cons file filepos) files)
 		    (server-log (format "New file: %s %s"
$ 



^ permalink raw reply	[flat|nested] 9+ messages in thread
* problems with emacsclient started by cygwin programs (mswindows)
@ 2011-06-24 20:14 layer
  0 siblings, 0 replies; 9+ messages in thread
From: layer @ 2011-06-24 20:14 UTC (permalink / raw)
  To: emacs-devel

I have a general problem with emacsclient on mswindows, when the
program calling emacsclient is a cygwin program (e.g., git).  The
cygwin program passes command line arguments to emacsclient using
cygwin path conventions (e.g., /home/layer/...) and emacs doesn't know
what to do with them.

So, I propose and will implement the agreed upon changes to server.el
which add a hook that people can define that will take care of this
situation.

I'm mailing the list because I want to declare I'm interested in
solving this problem and give people a chance to comment.

I think the changes are pretty straightforward.  The section of the
code in question (from emacs 23.2) is:

(defun* server-process-filter (proc string)
  ...
		 ;; -file FILENAME:  Load the given file.
		 ((and (equal "-file" arg)
		       command-line-args-left)
		  (let ((file (pop command-line-args-left)))
		    (if coding-system
			(setq file (decode-coding-string file coding-system)))
                    (setq file (expand-file-name file dir))
		    (push (cons file filepos) files)
		    (server-log (format "New file: %s %s"
                                        file (or filepos "")) proc))
		  (setq filepos nil))

The place for the hook, IMO, is just before the expand-file-name.

I've read 
  http://www.gnu.org/software/emacs/elisp/html_node/Hooks.html
and regarding the name for the hook... I can't think of a really good
name, but something like

  server-filename-frob-function

is all that comes to mind.  `frob' does appear a few other times in
23.2, and my use does appear to be in line with what's there.  I'm
certainly receptive to other names.  Being an "abnormal" hook function
(according to the definition at the URL above), I suffixed it with
-function, as suggested.  The hook will take a single argument, the
filename given to -file by emacsclient, and return the new filename to
use.

Comments?  Questions?

Thanks.

Kevin



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-07-05 16:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-27 20:43 problems with emacsclient started by cygwin programs (mswindows) layer
2011-06-30 16:17 ` Stefan Monnier
2011-07-01 15:00   ` layer
2011-07-01 17:21     ` Stefan Monnier
2011-07-01 18:26       ` layer
2011-07-04 15:15         ` Stefan Monnier
2011-07-04 23:46           ` layer
2011-07-05 16:11             ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2011-06-24 20:14 layer

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).