unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* extensions for emacsclient (CVS version)
@ 2003-09-10  8:26 Andreas Büsching
  2003-09-10  8:44 ` Miles Bader
  2003-09-11 13:16 ` Richard Stallman
  0 siblings, 2 replies; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10  8:26 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

Hi,

I've posted a similar article to the newsgroup comp.emacs, but did not
get an answer, so I thought I'll try it here.

,----
| I'm working on a little script, which uses the server functionality of
| emacs. The old version of this script used the gnuserv/gnudoit tools
| for the communication. The current CVS version of emacs contains a more
| advanced emacsclient and uses a different (IMHO much better) technique
| for the server communication. To use emacsclient in my script I would
| really like to have two new features in emacsclient.
| 
| - Using standard input: when no filename or '-' is specified standard
|   input is read.
| - --socket-name: With this option the default UNIX socket filename can
|   be overwritten to be able to have more than one socket per host.
| 
| If I would know that there is any chance that these features would get
| into CVS I would supply a patch myself.
| 
| RFC
`----

After a short period of time I couldn't hold it back, so I posted the
following

,----
| Okay I couldn't wait, so here is the first patch enabling emacsclient
| to use a different socket filename.
`----


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacsclient.c.patch --]
[-- Type: text/x-patch, Size: 1891 bytes --]

--- emacsclient.c.orig	Tue Sep  9 09:21:31 2003
+++ emacsclient.c	Tue Sep  9 09:55:16 2003
@@ -67,6 +67,9 @@
    is not running.  --alternate-editor.   */
 const char * alternate_editor = NULL;
 
+/* If non-NULL, thefilename of the UNIX socket */
+const char * socket_name = NULL;
+
 void print_help_and_exit ();
 
 struct option longopts[] =
@@ -76,6 +79,7 @@
   { "help",	no_argument,	   NULL, 'H' },
   { "version",	no_argument,	   NULL, 'V' },
   { "alternate-editor", required_argument, NULL, 'a' },
+  { "socket-name",	required_argument, NULL, 's' },
   { "display",	required_argument, NULL, 'd' },
   { 0, 0, 0, 0 }
 };
@@ -91,7 +95,7 @@
   while (1)
     {
       int opt = getopt_long (argc, argv,
-			     "VHnea:d:", longopts, 0);
+			     "VHnea:s:d:", longopts, 0);
 
       if (opt == EOF)
 	break;
@@ -109,6 +113,10 @@
 	  alternate_editor = optarg;
 	  break;
 
+	case 's':
+	  socket_name = optarg;
+	  break;
+
 	case 'd':
 	  display = optarg;
 	  break;
@@ -152,6 +160,8 @@
 -n, --no-wait           Don't wait for the server to return\n\
 -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
 -d, --display=DISPLAY   Visit the file in the given display\n\
+-s, --socket-name=FILENAME\n\
+                        Set the filename of the UNIX socket for communication\n\
 -a, --alternate-editor=EDITOR\n\
                         Editor to fallback to if the server is not running\n\
 \n\
@@ -347,7 +357,14 @@
   {
     int sock_status = 0;
 
-    sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
+    if (socket_name)
+      {
+	sprintf (server.sun_path, "%s", socket_name);
+      }
+    else
+      {
+	sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
+      }
 
     /* See if the socket exists, and if it's owned by us. */
     sock_status = socket_status (server.sun_path);

[-- Attachment #3: Type: text/plain, Size: 287 bytes --]


So please I just want any answer: Yes or No or 'bad idea' or whatever.

thanks in advance. Could you please send a direct reply to me, because
I didn't subscribe to the list.

crunchy


-- 
Sogar Shakespeare kannte also das "Werk" Windows schon, nur unter dem
Namen "Comedy of Errors".

[-- Attachment #4: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10  8:26 extensions for emacsclient (CVS version) Andreas Büsching
@ 2003-09-10  8:44 ` Miles Bader
  2003-09-10  9:00   ` Andreas Büsching
  2003-09-11 13:16 ` Richard Stallman
  1 sibling, 1 reply; 34+ messages in thread
From: Miles Bader @ 2003-09-10  8:44 UTC (permalink / raw)
  Cc: emacs-devel

Andreas Büsching <crunchy@tzi.de> writes:
> -    sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
> +	sprintf (server.sun_path, "%s", socket_name);
> +	sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);

Hmmm, no bounds checking when writing into server.sun_path (the old code
didn't either, but the constructed path is probably less likely to
overflow).

-Miles
-- 
`Suppose Korea goes to the World Cup final against Japan and wins,' Moon said.
`All the past could be forgiven.'   [NYT]

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10  8:44 ` Miles Bader
@ 2003-09-10  9:00   ` Andreas Büsching
  2003-09-10  9:30     ` Miles Bader
  0 siblings, 1 reply; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10  9:00 UTC (permalink / raw)
  Cc: emacs-devel

Hi,

Miles Bader <miles@lsi.nec.co.jp> wrote:

> Andreas Büsching <crunchy@tzi.de> writes:
>> -    sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
>> +	sprintf (server.sun_path, "%s", socket_name);
>> +	sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
>
> Hmmm, no bounds checking when writing into server.sun_path (the old code
> didn't either, but the constructed path is probably less likely to
> overflow).

If this is the only problem that is simple to fix! So we will replace
'sprintf(' with 'snprintf( sizeof server.sun_path, '. Is that what you
mean?

crunchy

-- 
Hard work never killed anyone, but why give it a chance?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10  9:00   ` Andreas Büsching
@ 2003-09-10  9:30     ` Miles Bader
  2003-09-10 10:56       ` Andreas Büsching
  0 siblings, 1 reply; 34+ messages in thread
From: Miles Bader @ 2003-09-10  9:30 UTC (permalink / raw)
  Cc: emacs-devel

Andreas Büsching <crunchy@tzi.de> writes:
> > Hmmm, no bounds checking when writing into server.sun_path (the old code
> > didn't either, but the constructed path is probably less likely to
> > overflow).
> 
> If this is the only problem that is simple to fix! So we will replace
> 'sprintf(' with 'snprintf( sizeof server.sun_path, '. Is that what you
> mean?

Well, it would probably be better to print an error message in the case
of a user-specified socket name.  The size of sun_path is fairly small,
actually, so an error is not all that unlikely.

Also I'm not sure whether you're allowed to use snprintf, since it's not
entirely portable, which emacs tries to be (I don't know if emacs
contains its own version of snprintf for this purpose or not).

-Miles
-- 
A zen-buddhist walked into a pizza shop and
said, "Make me one with everything."

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10  9:30     ` Miles Bader
@ 2003-09-10 10:56       ` Andreas Büsching
  2003-09-10 11:36         ` Miles Bader
  0 siblings, 1 reply; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10 10:56 UTC (permalink / raw)
  Cc: emacs-devel

Hi,

Miles Bader <miles@lsi.nec.co.jp> wrote:

> Andreas Büsching <crunchy@tzi.de> writes:
>> > Hmmm, no bounds checking when writing into server.sun_path (the old code
>> > didn't either, but the constructed path is probably less likely to
>> > overflow).
>> 
>> If this is the only problem that is simple to fix! So we will replace
>> 'sprintf(' with 'snprintf( sizeof server.sun_path, '. Is that what you
>> mean?
>
> Well, it would probably be better to print an error message in the case
> of a user-specified socket name.  The size of sun_path is fairly small,
> actually, so an error is not all that unlikely.
>
> Also I'm not sure whether you're allowed to use snprintf, since it's not
> entirely portable, which emacs tries to be (I don't know if emacs
> contains its own version of snprintf for this purpose or not).

Okay, I understand, we _would_ need to find good and emacs like method
to handle this potential problem, but what I would like to know first is,
if this patch has any chance to get into CVS.

crunchy

-- 
BREAKFAST.COM halted... cereal port not responding!

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 10:56       ` Andreas Büsching
@ 2003-09-10 11:36         ` Miles Bader
  2003-09-10 11:40           ` Andreas Büsching
  0 siblings, 1 reply; 34+ messages in thread
From: Miles Bader @ 2003-09-10 11:36 UTC (permalink / raw)
  Cc: emacs-devel

Andreas Büsching <crunchy@tzi.de> writes:
> Okay, I understand, we _would_ need to find good and emacs like method
> to handle this potential problem, but what I would like to know first is,
> if this patch has any chance to get into CVS.

It seems perfectly reasonable to me.

-Miles
-- 
80% of success is just showing up.  --Woody Allen

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 11:36         ` Miles Bader
@ 2003-09-10 11:40           ` Andreas Büsching
  2003-09-10 12:38             ` Stefan Monnier
  0 siblings, 1 reply; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10 11:40 UTC (permalink / raw)
  Cc: emacs-devel

Miles Bader <miles@lsi.nec.co.jp> wrote:

> Andreas Büsching <crunchy@tzi.de> writes:
>> Okay, I understand, we _would_ need to find good and emacs like method
>> to handle this potential problem, but what I would like to know first is,
>> if this patch has any chance to get into CVS.
>
> It seems perfectly reasonable to me.

This sounds great. So I will work on some security stuff and user
feedback, when this error occurs.

Is there also a chance to get a patch into CVS which enables
emacsclient to read from stdin?

crunchy

-- 
Microsoft Certified Angry OS Rebooter

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 11:40           ` Andreas Büsching
@ 2003-09-10 12:38             ` Stefan Monnier
  2003-09-10 13:45               ` Andreas Büsching
  0 siblings, 1 reply; 34+ messages in thread
From: Stefan Monnier @ 2003-09-10 12:38 UTC (permalink / raw)
  Cc: emacs-devel, Miles Bader

>>> Okay, I understand, we _would_ need to find good and emacs like method
>>> to handle this potential problem, but what I would like to know first is,
>>> if this patch has any chance to get into CVS.
>> It seems perfectly reasonable to me.
> This sounds great. So I will work on some security stuff and user
> feedback, when this error occurs.

I also like it (actually, in the past, I've suggested to obey $TMP
so as to be able to use different sockets, but an explicit socket-name
argument sounds much better).

> Is there also a chance to get a patch into CVS which enables
> emacsclient to read from stdin?

Sounds good to me (especially for the -eval case).


        Stefan

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 12:38             ` Stefan Monnier
@ 2003-09-10 13:45               ` Andreas Büsching
  2003-09-10 14:37                 ` Miles Bader
  2003-09-10 14:41                 ` Stefan Monnier
  0 siblings, 2 replies; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10 13:45 UTC (permalink / raw)
  Cc: emacs-devel, Miles Bader

[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]

"Stefan Monnier" <monnier@IRO.UMontreal.CA> wrote:

>>>> Okay, I understand, we _would_ need to find good and emacs like method
>>>> to handle this potential problem, but what I would like to know first is,
>>>> if this patch has any chance to get into CVS.
>>> It seems perfectly reasonable to me.
>> This sounds great. So I will work on some security stuff and user
>> feedback, when this error occurs.
>
> I also like it (actually, in the past, I've suggested to obey $TMP
> so as to be able to use different sockets, but an explicit socket-name
> argument sounds much better).
>
>> Is there also a chance to get a patch into CVS which enables
>> emacsclient to read from stdin?
>
> Sounds good to me (especially for the -eval case).

Okay, I used the time to extend the first patch with a buffer overflow
check and I also added the feature to use stdin for input if:

1. -e or --eval is given on the command line
   (I think it does not make sense for filenames)
2. there is no argument after the options

RFC

crunchy



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacsclient.c.patch --]
[-- Type: text/x-patch, Size: 3611 bytes --]

--- emacsclient.c.orig	Tue Sep  9 09:21:31 2003
+++ emacsclient.c	Wed Sep 10 15:39:34 2003
@@ -67,6 +67,9 @@
    is not running.  --alternate-editor.   */
 const char * alternate_editor = NULL;
 
+/* If non-NULL, the filename of the UNIX socket */
+const char * socket_name = NULL;
+
 void print_help_and_exit ();
 
 struct option longopts[] =
@@ -76,6 +79,7 @@
   { "help",	no_argument,	   NULL, 'H' },
   { "version",	no_argument,	   NULL, 'V' },
   { "alternate-editor", required_argument, NULL, 'a' },
+  { "socket-name",	required_argument, NULL, 's' },
   { "display",	required_argument, NULL, 'd' },
   { 0, 0, 0, 0 }
 };
@@ -91,7 +95,7 @@
   while (1)
     {
       int opt = getopt_long (argc, argv,
-			     "VHnea:d:", longopts, 0);
+			     "VHnea:s:d:", longopts, 0);
 
       if (opt == EOF)
 	break;
@@ -109,6 +113,10 @@
 	  alternate_editor = optarg;
 	  break;
 
+	case 's':
+	  socket_name = optarg;
+	  break;
+
 	case 'd':
 	  display = optarg;
 	  break;
@@ -152,6 +160,8 @@
 -n, --no-wait           Don't wait for the server to return\n\
 -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
 -d, --display=DISPLAY   Visit the file in the given display\n\
+-s, --socket-name=FILENAME\n\
+                        Set the filename of the UNIX socket for communication\n\
 -a, --alternate-editor=EDITOR\n\
                         Editor to fallback to if the server is not running\n\
 \n\
@@ -300,7 +310,7 @@
   /* Process options.  */
   decode_options (argc, argv);
 
-  if (argc - optind < 1)
+  if ((argc - optind < 1) && !eval)
     {
       fprintf (stderr, "%s: file name or argument required\n", progname);
       fprintf (stderr, "Try `%s --help' for more information\n", progname);
@@ -347,7 +357,22 @@
   {
     int sock_status = 0;
 
-    sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
+    if (socket_name)
+      {
+	if (strlen (socket_name) > sizeof server.sun_path )
+	  {
+	    fprintf (stderr, "Invalid socket name (%s): the socket name is too long (max. %d)\n", socket_name, sizeof server.sun_path);
+	    exit (1);
+	  }
+        else
+	  {
+	    sprintf (server.sun_path, "%s", socket_name);
+	  }
+      }
+    else
+      {
+	sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
+      }
 
     /* See if the socket exists, and if it's owned by us. */
     sock_status = socket_status (server.sun_path);
@@ -457,22 +482,33 @@
   if (display)
     fprintf (out, "-display %s ", quote_file_name (display));
 
-  for (i = optind; i < argc; i++)
+  if ((argc - optind > 0))
     {
-      if (eval)
-	; /* Don't prepend any cwd or anything like that.  */
-      else if (*argv[i] == '+')
+      for (i = optind; i < argc; i++)
 	{
-	  char *p = argv[i] + 1;
-	  while (isdigit ((unsigned char) *p) || *p == ':') p++;
-	  if (*p != 0)
+	  if (eval)
+	    ; /* Don't prepend any cwd or anything like that.  */
+	  else if (*argv[i] == '+')
+	    {
+	      char *p = argv[i] + 1;
+	      while (isdigit ((unsigned char) *p) || *p == ':') p++;
+	      if (*p != 0)
+		fprintf (out, "%s/", quote_file_name (cwd));
+	    }
+	  else if (*argv[i] != '/')
 	    fprintf (out, "%s/", quote_file_name (cwd));
-	}
-      else if (*argv[i] != '/')
-	fprintf (out, "%s/", quote_file_name (cwd));
 
-      fprintf (out, "%s ", quote_file_name (argv[i]));
+	  fprintf (out, "%s ", quote_file_name (argv[i]));
+	}
+    }
+  else
+    {
+      while ((str = fgets (string, BUFSIZ, stdin)))
+	{
+	  fprintf (out, "%s ", quote_file_name (str));
+	}
     }
+  
   fprintf (out, "\n");
   fflush (out);
 

[-- Attachment #3: Type: text/plain, Size: 181 bytes --]



-- 
What happens if a big asteroid hits the Earth? Judging from realistic
simulations involving a sledge hammer and a common laboratory frog, we
can assume it will be pretty bad.

[-- Attachment #4: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 13:45               ` Andreas Büsching
@ 2003-09-10 14:37                 ` Miles Bader
  2003-09-10 15:00                   ` Andreas Büsching
  2003-09-11  6:57                   ` Andreas Büsching
  2003-09-10 14:41                 ` Stefan Monnier
  1 sibling, 2 replies; 34+ messages in thread
From: Miles Bader @ 2003-09-10 14:37 UTC (permalink / raw)
  Cc: emacs-devel, Stefan Monnier, Miles Bader

On Wed, Sep 10, 2003 at 03:45:34PM +0200, Andreas B?sching wrote:
+      while ((str = fgets (string, BUFSIZ, stdin)))
+       {
+         fprintf (out, "%s ", quote_file_name (str));
+       }

I think that there shouldn't be a space after the %s -- that will cause each
line of input to be evaluated independantly, which is probably not what you
want, as well as being the wrong thing if a line is longer than BUFSIZ.
Also, you don't free the result from quote_file_name (it's only only going to
matter for extremely long input -- but that's probably more likely for stuff
being fed from stdin).

Hmmm, this isn't really your fault, but I notice that _every_ call to
quote_file_name immediately just prints the result, like:

    fprintf (out, "-display %s ", quote_file_name (display));

where quote_file_name mallocs a new string.

It would be nicer to just change quote_file_name to something like
`output_quoted_string (char *str, FILE *stream)', which just copies STR to
STREAM with appropriate quoting (doing away with all the mallocing).

Then expressions like the above could be changed to:

   {
     fputs ("-display ", out);
     output_quoted_string (display, out);
   }

and your loop would be:

   while ((str = fgets (string, BUFSIZ, stdin)))
     output_quoted_string (str, out);

-Miles
-- 
Would you like fries with that?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 13:45               ` Andreas Büsching
  2003-09-10 14:37                 ` Miles Bader
@ 2003-09-10 14:41                 ` Stefan Monnier
  2003-09-10 15:02                   ` Andreas Büsching
  1 sibling, 1 reply; 34+ messages in thread
From: Stefan Monnier @ 2003-09-10 14:41 UTC (permalink / raw)
  Cc: emacs-devel, Miles Bader

[ Please pass the -b option to diff for patches that are ment to be read
  by humans. ]

> +  else
> +    {
> +      while ((str = fgets (string, BUFSIZ, stdin)))
> +	{
> +	  fprintf (out, "%s ", quote_file_name (str));
> +	}

Have you tested it to see if it works with a large multiline
(and with long lines) stdin ?
I think the space after %s might pose problems (if the input line
is long and is cut in the middle of a symbol for example).
I suggest to use just "%s" instead.

Other than that, it looks fine to me.  In order to be able to install
this change in Emacs-CVS, we need to make sure you have signed the relevant
paperwork (ideally an assignment of copyright covering all your changes to
Emacs, IIRC you want to ask assign@gnu.org to get the relevant form).


        Stefan

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 14:37                 ` Miles Bader
@ 2003-09-10 15:00                   ` Andreas Büsching
  2003-09-10 15:09                     ` Miles Bader
  2003-09-11  6:57                   ` Andreas Büsching
  1 sibling, 1 reply; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10 15:00 UTC (permalink / raw)
  Cc: Stefan Monnier, emacs-devel

Miles Bader <miles@gnu.org> wrote:

> On Wed, Sep 10, 2003 at 03:45:34PM +0200, Andreas B?sching wrote:
> +      while ((str = fgets (string, BUFSIZ, stdin)))
> +       {
> +         fprintf (out, "%s ", quote_file_name (str));
> +       }
>
> I think that there shouldn't be a space after the %s -- that will cause each
> line of input to be evaluated independantly, which is probably not what you
> want, as well as being the wrong thing if a line is longer than BUFSIZ.
> Also, you don't free the result from quote_file_name (it's only only going to
> matter for extremely long input -- but that's probably more likely for stuff
> being fed from stdin).
>
> Hmmm, this isn't really your fault, but I notice that _every_ call to
> quote_file_name immediately just prints the result, like:
>
>     fprintf (out, "-display %s ", quote_file_name (display));
>
> where quote_file_name mallocs a new string.
>
> It would be nicer to just change quote_file_name to something like
> `output_quoted_string (char *str, FILE *stream)', which just copies STR to
> STREAM with appropriate quoting (doing away with all the mallocing).

I think it's a great idea to clean up the memory and to add the second
argument, but I would still prefer to do the copying and write the
string at once into the stream and not character by character.

> Then expressions like the above could be changed to:
>
>    {
>      fputs ("-display ", out);
>      output_quoted_string (display, out);
>    }
>
> and your loop would be:
>
>    while ((str = fgets (string, BUFSIZ, stdin)))
>      output_quoted_string (str, out);

I'm already working on it.

crunchy

-- 
If God is dead, who will save the Queen?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 14:41                 ` Stefan Monnier
@ 2003-09-10 15:02                   ` Andreas Büsching
  2003-09-10 15:08                     ` Stefan Monnier
  0 siblings, 1 reply; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10 15:02 UTC (permalink / raw)
  Cc: emacs-devel, Miles Bader

"Stefan Monnier" <monnier@IRO.UMontreal.CA> wrote:

> [ Please pass the -b option to diff for patches that are ment to be read
>   by humans. ]
>
>> +  else
>> +    {
>> +      while ((str = fgets (string, BUFSIZ, stdin)))
>> +	{
>> +	  fprintf (out, "%s ", quote_file_name (str));
>> +	}
>
> Have you tested it to see if it works with a large multiline
> (and with long lines) stdin ?
> I think the space after %s might pose problems (if the input line
> is long and is cut in the middle of a symbol for example).
> I suggest to use just "%s" instead.

D'oh! I just tested it with a short expression, so you are right. I
will fix this.

> Other than that, it looks fine to me.  In order to be able to install
> this change in Emacs-CVS, we need to make sure you have signed the relevant
> paperwork (ideally an assignment of copyright covering all your changes to
> Emacs, IIRC you want to ask assign@gnu.org to get the relevant form).

I guess there is no easier way to contribute to the emacs project?

crunchy


-- 
"We're back to the times when men were men and wrote their own device 
 drivers"
     -- Linus Torvalds

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 15:02                   ` Andreas Büsching
@ 2003-09-10 15:08                     ` Stefan Monnier
  2003-09-10 16:13                       ` David Kastrup
  0 siblings, 1 reply; 34+ messages in thread
From: Stefan Monnier @ 2003-09-10 15:08 UTC (permalink / raw)
  Cc: emacs-devel, Miles Bader

>> Other than that, it looks fine to me.  In order to be able to install
>> this change in Emacs-CVS, we need to make sure you have signed the relevant
>> paperwork (ideally an assignment of copyright covering all your changes to
>> Emacs, IIRC you want to ask assign@gnu.org to get the relevant form).
> I guess there is no easier way to contribute to the emacs project?

Other than limiting yourself to a total of about 10 lines of new code, no.
Note that it's still pretty easy if you sign the above mentioned form since
it covers future changes as well, so you do it once and then you can forget
about it.
Of course, if you have to do that for a hundred different projects, it's
still annoying.


        Stefan

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 15:00                   ` Andreas Büsching
@ 2003-09-10 15:09                     ` Miles Bader
  0 siblings, 0 replies; 34+ messages in thread
From: Miles Bader @ 2003-09-10 15:09 UTC (permalink / raw)
  Cc: emacs-devel, Stefan Monnier, Miles Bader

On Wed, Sep 10, 2003 at 05:00:45PM +0200, Andreas B?sching wrote:
> I think it's a great idea to clean up the memory and to add the second
> argument, but I would still prefer to do the copying and write the
> string at once into the stream and not character by character.

stdio _is_ buffered...

-Miles
-- 
Would you like fries with that?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 15:08                     ` Stefan Monnier
@ 2003-09-10 16:13                       ` David Kastrup
  2003-09-10 16:22                         ` Andreas Büsching
  0 siblings, 1 reply; 34+ messages in thread
From: David Kastrup @ 2003-09-10 16:13 UTC (permalink / raw)
  Cc: Miles Bader, Andreas Büsching, emacs-devel

"Stefan Monnier" <monnier@IRO.UMontreal.CA> writes:

> >> Other than that, it looks fine to me.  In order to be able to
> >> install this change in Emacs-CVS, we need to make sure you have
> >> signed the relevant paperwork (ideally an assignment of copyright
> >> covering all your changes to Emacs, IIRC you want to ask
> >> assign@gnu.org to get the relevant form).

> > I guess there is no easier way to contribute to the emacs project?
> 
> Other than limiting yourself to a total of about 10 lines of new
> code, no.  Note that it's still pretty easy if you sign the above
> mentioned form since it covers future changes as well, so you do it
> once and then you can forget about it.  Of course, if you have to do
> that for a hundred different projects, it's still annoying.

Not as annoying as some company claiming you have stolen their code
and demanding licensing fees for using Free Software, like SCO is
currently doing for Linux.  While it is hardly likely that they will
succeed in the long run with their claims, they cast a doubt on the
legality and morality of Free Software users and authors that we
could much better do without.

The copyright assignments make it much less likely that stunts like
that can be pulled off with software that is copyrighted by the Free
Software Foundation.

Call it paranoia if you really want to, but today's world is a place
where paranoia as a capacity has its place, unfortunately.

The form is just a one-time thing, and easy enough to do.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 16:13                       ` David Kastrup
@ 2003-09-10 16:22                         ` Andreas Büsching
  2003-09-10 16:50                           ` David Kastrup
                                             ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Andreas Büsching @ 2003-09-10 16:22 UTC (permalink / raw)
  Cc: Miles Bader, Stefan Monnier, emacs-devel

David Kastrup <dak@gnu.org> wrote:

> "Stefan Monnier" <monnier@IRO.UMontreal.CA> writes:
>
>> >> Other than that, it looks fine to me.  In order to be able to
>> >> install this change in Emacs-CVS, we need to make sure you have
>> >> signed the relevant paperwork (ideally an assignment of copyright
>> >> covering all your changes to Emacs, IIRC you want to ask
>> >> assign@gnu.org to get the relevant form).
>
>> > I guess there is no easier way to contribute to the emacs project?
>> 
>> Other than limiting yourself to a total of about 10 lines of new
>> code, no.  Note that it's still pretty easy if you sign the above
>> mentioned form since it covers future changes as well, so you do it
>> once and then you can forget about it.  Of course, if you have to do
>> that for a hundred different projects, it's still annoying.
>
> Not as annoying as some company claiming you have stolen their code
> and demanding licensing fees for using Free Software, like SCO is
> currently doing for Linux.  While it is hardly likely that they will
> succeed in the long run with their claims, they cast a doubt on the
> legality and morality of Free Software users and authors that we
> could much better do without.
>
> The copyright assignments make it much less likely that stunts like
> that can be pulled off with software that is copyrighted by the Free
> Software Foundation.

I fully understand the reasons for this form and just explained it to a
friend of mine with the same example.

> The form is just a one-time thing, and easy enough to do.

Looks like you know more about it. Is Stefan right with his suggestion?
I just need to send an e-mail to <assign@gnu.org> and explain that I
would like to contribute some code to GNU Emacs and they do the rest?

crunchy

-- 
Reality is for people who lack imagination.

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 16:22                         ` Andreas Büsching
@ 2003-09-10 16:50                           ` David Kastrup
  2003-09-10 19:40                           ` Alex Schroeder
  2003-09-11 23:46                           ` Richard Stallman
  2 siblings, 0 replies; 34+ messages in thread
From: David Kastrup @ 2003-09-10 16:50 UTC (permalink / raw)
  Cc: Miles Bader, Stefan Monnier, emacs-devel

Andreas Büsching <crunchy@tzi.de> writes:

[...]

> > The form is just a one-time thing, and easy enough to do.
> 
> Looks like you know more about it. Is Stefan right with his
> suggestion?  I just need to send an e-mail to <assign@gnu.org> and
> explain that I would like to contribute some code to GNU Emacs and
> they do the rest?

Worked here.  Well, obviously you will have to send them your postal
address, and then you will have to send back the form once you have
signed it (and read it! You might have to check with your employer
too: some contracts specify that even stuff you do in your freetime
belongs to them).

But that's about it.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 16:22                         ` Andreas Büsching
  2003-09-10 16:50                           ` David Kastrup
@ 2003-09-10 19:40                           ` Alex Schroeder
  2003-09-11  5:20                             ` Andreas Buesching
  2003-09-11 19:30                             ` Andreas Buesching
  2003-09-11 23:46                           ` Richard Stallman
  2 siblings, 2 replies; 34+ messages in thread
From: Alex Schroeder @ 2003-09-10 19:40 UTC (permalink / raw)
  Cc: emacs-devel

Andreas Büsching <crunchy@tzi.de> writes:

> I just need to send an e-mail to <assign@gnu.org> and explain that I
> would like to contribute some code to GNU Emacs and they do the rest?

Yes.  And if you ever plan to add more code, please specify that you
want your FUTURE CHANGES to Emacs covered, too.  I forgot that the
first time around.  ;)

Alex.
-- 
http://www.emacswiki.org/alex/
There is no substitute for experience.

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 19:40                           ` Alex Schroeder
@ 2003-09-11  5:20                             ` Andreas Buesching
  2003-09-11 19:30                             ` Andreas Buesching
  1 sibling, 0 replies; 34+ messages in thread
From: Andreas Buesching @ 2003-09-11  5:20 UTC (permalink / raw)
  Cc: emacs-devel

On Wed, 2003-09-10 at 21:40, Alex Schroeder wrote:
> Andreas Büsching <crunchy@tzi.de> writes:
> 
> > I just need to send an e-mail to <assign@gnu.org> and explain that I
> > would like to contribute some code to GNU Emacs and they do the rest?
> 
> Yes.  And if you ever plan to add more code, please specify that you
> want your FUTURE CHANGES to Emacs covered, too.  I forgot that the
> first time around.  ;)

Okay, thanks for the hint. Last night I send the request and got the
automatic reply, which told that it could last about three days until I
get an manual reply. Looks like emacsclient needs to wait for this new
cool features for soem days ;-)

> Alex.

Just by reading your name I remembered, that I wanted to send you some
of my emacs color-themes, maybe I don't forget it this time.

crunchy

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 14:37                 ` Miles Bader
  2003-09-10 15:00                   ` Andreas Büsching
@ 2003-09-11  6:57                   ` Andreas Büsching
  2003-09-11 23:47                     ` Richard Stallman
  1 sibling, 1 reply; 34+ messages in thread
From: Andreas Büsching @ 2003-09-11  6:57 UTC (permalink / raw)
  Cc: Stefan Monnier, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1551 bytes --]

Miles Bader <miles@gnu.org> wrote:

> On Wed, Sep 10, 2003 at 03:45:34PM +0200, Andreas B?sching wrote:
> +      while ((str = fgets (string, BUFSIZ, stdin)))
> +       {
> +         fprintf (out, "%s ", quote_file_name (str));
> +       }
>
> I think that there shouldn't be a space after the %s -- that will cause each
> line of input to be evaluated independantly, which is probably not what you
> want, as well as being the wrong thing if a line is longer than BUFSIZ.
> Also, you don't free the result from quote_file_name (it's only only going to
> matter for extremely long input -- but that's probably more likely for stuff
> being fed from stdin).
>
> Hmmm, this isn't really your fault, but I notice that _every_ call to
> quote_file_name immediately just prints the result, like:
>
>     fprintf (out, "-display %s ", quote_file_name (display));
>
> where quote_file_name mallocs a new string.
>
> It would be nicer to just change quote_file_name to something like
> `output_quoted_string (char *str, FILE *stream)', which just copies STR to
> STREAM with appropriate quoting (doing away with all the mallocing).
>
> Then expressions like the above could be changed to:
>
>    {
>      fputs ("-display ", out);
>      output_quoted_string (display, out);
>    }
>
> and your loop would be:
>
>    while ((str = fgets (string, BUFSIZ, stdin)))
>      output_quoted_string (str, out);

Okay, Here is another version of the patch, with a new version of
quote_file_name and the bug fix suggested by Sfefan and Miles.

and again RFC

crunchy



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacsclient.c.patch --]
[-- Type: text/x-patch, Size: 4040 bytes --]

--- emacsclient.c.orig	Tue Sep  9 09:21:31 2003
+++ emacsclient.c	Thu Sep 11 08:43:36 2003
@@ -67,6 +67,9 @@
    is not running.  --alternate-editor.   */
 const char * alternate_editor = NULL;
 
+/* If non-NULL, the filename of the UNIX socket */
+const char * socket_name = NULL;
+
 void print_help_and_exit ();
 
 struct option longopts[] =
@@ -76,6 +79,7 @@
   { "help",	no_argument,	   NULL, 'H' },
   { "version",	no_argument,	   NULL, 'V' },
   { "alternate-editor", required_argument, NULL, 'a' },
+  { "socket-name",	required_argument, NULL, 's' },
   { "display",	required_argument, NULL, 'd' },
   { 0, 0, 0, 0 }
 };
@@ -91,7 +95,7 @@
   while (1)
     {
       int opt = getopt_long (argc, argv,
-			     "VHnea:d:", longopts, 0);
+			     "VHnea:s:d:", longopts, 0);
 
       if (opt == EOF)
 	break;
@@ -109,6 +113,10 @@
 	  alternate_editor = optarg;
 	  break;
 
+	case 's':
+	  socket_name = optarg;
+	  break;
+
 	case 'd':
 	  display = optarg;
 	  break;
@@ -152,6 +160,8 @@
 -n, --no-wait           Don't wait for the server to return\n\
 -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
 -d, --display=DISPLAY   Visit the file in the given display\n\
+-s, --socket-name=FILENAME\n\
+                        Set the filename of the UNIX socket for communication\n\
 -a, --alternate-editor=EDITOR\n\
                         Editor to fallback to if the server is not running\n\
 \n\
@@ -159,14 +169,15 @@
   exit (0);
 }
 
-/* Return a copy of NAME, inserting a &
+/* Inserting a &
    before each &, each space, each newline, and any initial -.
    Change spaces to underscores, too, so that the
    return value never contains a space.  */
 
-char *
-quote_file_name (name)
+void
+quote_file_name (name, stream)
      char *name;
+     FILE *stream;
 {
   char *copy = (char *) malloc (strlen (name) * 2 + 1);
   char *p, *q;
@@ -196,7 +207,9 @@
     }
   *q++ = 0;
 
-  return copy;
+  fprintf (stream, copy);
+
+  free (copy);
 }
 
 /* Like malloc but get fatal error if memory is exhausted.  */
@@ -300,7 +313,7 @@
   /* Process options.  */
   decode_options (argc, argv);
 
-  if (argc - optind < 1)
+  if ((argc - optind < 1) && !eval)
     {
       fprintf (stderr, "%s: file name or argument required\n", progname);
       fprintf (stderr, "Try `%s --help' for more information\n", progname);
@@ -347,7 +360,22 @@
   {
     int sock_status = 0;
 
+    if (socket_name)
+      {
+	if (strlen (socket_name) > sizeof server.sun_path )
+	  {
+	    fprintf (stderr, "Invalid socket name (%s): the socket name is too long (max. %d)\n", socket_name, sizeof server.sun_path);
+	    exit (1);
+	  }
+        else
+	  {
+	    sprintf (server.sun_path, "%s", socket_name);
+	  }
+      }
+    else
+      {
     sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
+      }
 
     /* See if the socket exists, and if it's owned by us. */
     sock_status = socket_status (server.sun_path);
@@ -455,8 +483,14 @@
     fprintf (out, "-eval ");
 
   if (display)
-    fprintf (out, "-display %s ", quote_file_name (display));
+    {
+      fprintf (out, "-display ");
+      quote_file_name (display, out);
+      fprintf (out, " ");
+    }
 
+  if ((argc - optind > 0))
+    {
   for (i = optind; i < argc; i++)
     {
       if (eval)
@@ -466,13 +500,30 @@
 	  char *p = argv[i] + 1;
 	  while (isdigit ((unsigned char) *p) || *p == ':') p++;
 	  if (*p != 0)
-	    fprintf (out, "%s/", quote_file_name (cwd));
+		{
+		  quote_file_name (cwd, out);
+		  fprintf (out, "/");
+		}
 	}
       else if (*argv[i] != '/')
-	fprintf (out, "%s/", quote_file_name (cwd));
+	    {
+	      quote_file_name (cwd, out);
+	      fprintf (out, "/");
+	    }
 
-      fprintf (out, "%s ", quote_file_name (argv[i]));
+	  quote_file_name (argv[i], out);
+	  fprintf (out, " ");
     }
+    }
+  else
+    {
+      while ((str = fgets (string, BUFSIZ, stdin)))
+	{
+	  quote_file_name (str, out);
+	}
+      fprintf (out, " ");
+    }
+  
   fprintf (out, "\n");
   fflush (out);
 

[-- Attachment #3: Type: text/plain, Size: 57 bytes --]


-- 
BREAKFAST.COM halted... cereal port not responding!

[-- Attachment #4: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10  8:26 extensions for emacsclient (CVS version) Andreas Büsching
  2003-09-10  8:44 ` Miles Bader
@ 2003-09-11 13:16 ` Richard Stallman
  2003-09-11 14:15   ` Andreas Büsching
  1 sibling, 1 reply; 34+ messages in thread
From: Richard Stallman @ 2003-09-11 13:16 UTC (permalink / raw)
  Cc: emacs-devel

This change would be good, but it has a bug: if the argument
is too long, the sprintf will clobber something.

Here's a version that fixes that problem in a clean way.
Does it work?


cd ~/emacs/lib-src/
diff -c /home/rms/emacs/lib-src/emacsclient.c.\~1\~ /home/rms/emacs/lib-src/emacsclient.c
***************
*** 67,72 ****
--- 67,75 ----
     is not running.  --alternate-editor.   */
  const char * alternate_editor = NULL;
  
+ /* If non-NULL, thefilename of the UNIX socket */
+ char *socket_name = NULL;
+ 
  void print_help_and_exit ();
  
  struct option longopts[] =
***************
*** 76,81 ****
--- 79,85 ----
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
    { "alternate-editor", required_argument, NULL, 'a' },
+   { "socket-name",	required_argument, NULL, 's' },
    { "display",	required_argument, NULL, 'd' },
    { 0, 0, 0, 0 }
  };
***************
*** 91,97 ****
    while (1)
      {
        int opt = getopt_long (argc, argv,
! 			     "VHnea:d:", longopts, 0);
  
        if (opt == EOF)
  	break;
--- 95,101 ----
    while (1)
      {
        int opt = getopt_long (argc, argv,
! 			     "VHnea:s:d:", longopts, 0);
  
        if (opt == EOF)
  	break;
***************
*** 109,114 ****
--- 113,122 ----
  	  alternate_editor = optarg;
  	  break;
  
+ 	case 's':
+ 	  socket_name = optarg;
+ 	  break;
+ 
  	case 'd':
  	  display = optarg;
  	  break;
***************
*** 136,155 ****
  void
  print_help_and_exit ()
  {
!   fprintf (stderr,
! 	   "Usage: %s [OPTIONS] FILE...\n\
  Tell the Emacs server to visit the specified files.\n\
  Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
  The following OPTIONS are accepted:\n\
  -V, --version           Just print a version info and return\n\
  -H, --help              Print this usage information message\n\
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
  Report bugs to bug-gnu-emacs@gnu.org.\n", progname);
!   exit (1);
  }
  
  /* Return a copy of NAME, inserting a &
--- 149,172 ----
  void
  print_help_and_exit ()
  {
!   printf (
! 	  "Usage: %s [OPTIONS] FILE...\n\
  Tell the Emacs server to visit the specified files.\n\
  Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
+ \n\
  The following OPTIONS are accepted:\n\
  -V, --version           Just print a version info and return\n\
  -H, --help              Print this usage information message\n\
  -n, --no-wait           Don't wait for the server to return\n\
  -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
  -d, --display=DISPLAY   Visit the file in the given display\n\
+ -s, --socket-name=FILENAME\n\
+                         Set the filename of the UNIX socket for communication\n\
  -a, --alternate-editor=EDITOR\n\
                          Editor to fallback to if the server is not running\n\
+ \n\
  Report bugs to bug-gnu-emacs@gnu.org.\n", progname);
!   exit (0);
  }
  
  /* Return a copy of NAME, inserting a &
***************
*** 336,342 ****
    {
      int sock_status = 0;
  
!     sprintf (server.sun_path, "/tmp/esrv%d-%s", (int) geteuid (), system_name);
  
      /* See if the socket exists, and if it's owned by us. */
      sock_status = socket_status (server.sun_path);
--- 357,374 ----
    {
      int sock_status = 0;
  
!     if (! socket_name)
!       {
! 	socket_name = alloca (system_name_length + 100);
! 	sprintf (socket_name, "/tmp/emacs%d-%s/server",
! 		 (int) geteuid (), system_name);
!       }
! 
!     if (strlen (socket_name) < sizeof (server.sun_path))
!       strcpy (server.sun_path, socket_name);
!     else
!       fprintf (stderr, "%s: socket-name %s too long",
! 	       argv[0], socket_name);
  
      /* See if the socket exists, and if it's owned by us. */
      sock_status = socket_status (server.sun_path);

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11 13:16 ` Richard Stallman
@ 2003-09-11 14:15   ` Andreas Büsching
  0 siblings, 0 replies; 34+ messages in thread
From: Andreas Büsching @ 2003-09-11 14:15 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

Richard Stallman <rms@gnu.org> wrote:

> This change would be good, but it has a bug: if the argument
> is too long, the sprintf will clobber something.
>
> Here's a version that fixes that problem in a clean way.

You are right. This is much cleaner and fixes the bug.

So here goes the new version of the patch.

RFC

crunchy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacsclient.c.patch --]
[-- Type: text/x-patch, Size: 4075 bytes --]

--- emacsclient.c.orig	Tue Sep  9 09:21:31 2003
+++ emacsclient.c	Thu Sep 11 16:05:03 2003
@@ -67,6 +67,9 @@
    is not running.  --alternate-editor.   */
 const char * alternate_editor = NULL;
 
+/* If non-NULL, the filename of the UNIX socket */
+const char * socket_name = NULL;
+
 void print_help_and_exit ();
 
 struct option longopts[] =
@@ -76,6 +79,7 @@
   { "help",	no_argument,	   NULL, 'H' },
   { "version",	no_argument,	   NULL, 'V' },
   { "alternate-editor", required_argument, NULL, 'a' },
+  { "socket-name",	required_argument, NULL, 's' },
   { "display",	required_argument, NULL, 'd' },
   { 0, 0, 0, 0 }
 };
@@ -91,7 +95,7 @@
   while (1)
     {
       int opt = getopt_long (argc, argv,
-			     "VHnea:d:", longopts, 0);
+			     "VHnea:s:d:", longopts, 0);
 
       if (opt == EOF)
 	break;
@@ -109,6 +113,10 @@
 	  alternate_editor = optarg;
 	  break;
 
+	case 's':
+	  socket_name = optarg;
+	  break;
+
 	case 'd':
 	  display = optarg;
 	  break;
@@ -152,6 +160,8 @@
 -n, --no-wait           Don't wait for the server to return\n\
 -e, --eval              Evaluate the FILE arguments as ELisp expressions\n\
 -d, --display=DISPLAY   Visit the file in the given display\n\
+-s, --socket-name=FILENAME\n\
+                        Set the filename of the UNIX socket for communication\n\
 -a, --alternate-editor=EDITOR\n\
                         Editor to fallback to if the server is not running\n\
 \n\
@@ -159,14 +169,15 @@
   exit (0);
 }
 
-/* Return a copy of NAME, inserting a &
+/* Inserting a &
    before each &, each space, each newline, and any initial -.
    Change spaces to underscores, too, so that the
    return value never contains a space.  */
 
-char *
-quote_file_name (name)
+void
+quote_file_name (name, stream)
      char *name;
+     FILE *stream;
 {
   char *copy = (char *) malloc (strlen (name) * 2 + 1);
   char *p, *q;
@@ -196,7 +207,9 @@
     }
   *q++ = 0;
 
-  return copy;
+  fprintf (stream, copy);
+
+  free (copy);
 }
 
 /* Like malloc but get fatal error if memory is exhausted.  */
@@ -300,7 +313,7 @@
   /* Process options.  */
   decode_options (argc, argv);
 
-  if (argc - optind < 1)
+  if ((argc - optind < 1) && !eval)
     {
       fprintf (stderr, "%s: file name or argument required\n", progname);
       fprintf (stderr, "Try `%s --help' for more information\n", progname);
@@ -347,7 +360,18 @@
   {
     int sock_status = 0;
 
-    sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name);
+     if (! socket_name)
+       {
+	 socket_name = alloca (system_name_length + 100);
+	 sprintf ((char *) socket_name, "/tmp/emacs%d-%s/server",
+		  (int) geteuid (), system_name);
+       }
+ 
+     if (strlen (socket_name) < sizeof (server.sun_path))
+       strcpy (server.sun_path, socket_name);
+     else
+       fprintf (stderr, "%s: socket-name %s too long",
+		argv[0], socket_name);
 
     /* See if the socket exists, and if it's owned by us. */
     sock_status = socket_status (server.sun_path);
@@ -455,8 +479,14 @@
     fprintf (out, "-eval ");
 
   if (display)
-    fprintf (out, "-display %s ", quote_file_name (display));
+    {
+      fprintf (out, "-display ");
+      quote_file_name (display, out);
+      fprintf (out, " ");
+    }
 
+  if ((argc - optind > 0))
+    {
   for (i = optind; i < argc; i++)
     {
       if (eval)
@@ -466,13 +496,30 @@
 	  char *p = argv[i] + 1;
 	  while (isdigit ((unsigned char) *p) || *p == ':') p++;
 	  if (*p != 0)
-	    fprintf (out, "%s/", quote_file_name (cwd));
+		{
+		  quote_file_name (cwd, out);
+		  fprintf (out, "/");
+		}
 	}
       else if (*argv[i] != '/')
-	fprintf (out, "%s/", quote_file_name (cwd));
+	    {
+	      quote_file_name (cwd, out);
+	      fprintf (out, "/");
+	    }
 
-      fprintf (out, "%s ", quote_file_name (argv[i]));
+	  quote_file_name (argv[i], out);
+	  fprintf (out, " ");
+	}
     }
+  else
+    {
+      while ((str = fgets (string, BUFSIZ, stdin)))
+	{
+	  quote_file_name (str, out);
+	}
+      fprintf (out, " ");
+    }
+  
   fprintf (out, "\n");
   fflush (out);
 

[-- Attachment #3: Type: text/plain, Size: 103 bytes --]



-- 
Quitters never win, and winners never quit, but those who never quit AND  
never win are idiots.

[-- Attachment #4: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 19:40                           ` Alex Schroeder
  2003-09-11  5:20                             ` Andreas Buesching
@ 2003-09-11 19:30                             ` Andreas Buesching
  2003-09-11 21:22                               ` Miles Bader
  1 sibling, 1 reply; 34+ messages in thread
From: Andreas Buesching @ 2003-09-11 19:30 UTC (permalink / raw)
  Cc: emacs-devel

On Wed, 2003-09-10 at 21:40, Alex Schroeder wrote:
> Andreas Büsching <crunchy@tzi.de> writes:
> 
> > I just need to send an e-mail to <assign@gnu.org> and explain that I
> > would like to contribute some code to GNU Emacs and they do the rest?
> 
> Yes.  And if you ever plan to add more code, please specify that you
> want your FUTURE CHANGES to Emacs covered, too.  I forgot that the
> first time around.  ;)

It's getting complicate. I just got this mail from the copyright clerk.

| Hello Andreas,
| 
| While this is the proper contact for assignments, there is a step that
| needs to be completed beofre contacting this address.  You need to
| communicated first with the maintainer of the package to which you 
| seek to contribute at maintainer@fsf.org or to the maintainer 
| individually.

I guess sending this mail will also contact the maintainer and maybe he
or someone else know what to do now?

crunchy

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11 19:30                             ` Andreas Buesching
@ 2003-09-11 21:22                               ` Miles Bader
  2003-09-12 21:06                                 ` Richard Stallman
  0 siblings, 1 reply; 34+ messages in thread
From: Miles Bader @ 2003-09-11 21:22 UTC (permalink / raw)


Andreas Buesching <crunchy@tzi.de> writes:
> It's getting complicate. I just got this mail from the copyright clerk.
> 
> | While this is the proper contact for assignments, there is a step that
> | needs to be completed beofre contacting this address.  You need to
> | communicated first with the maintainer of the package to which you 
> | seek to contribute at maintainer@fsf.org or to the maintainer 
> | individually.
> 
> I guess sending this mail will also contact the maintainer and maybe he
> or someone else know what to do now?

Maybe it's explained by a part of the message you didn't include in this
excerpt, but I find that very confusing -- it doesn't say _why_ it's
necessary to `communicate with the maintainer,' or what to ask them.
Just, `communicate.'

I mean if someone's trying to send an assignment, surely there's a very
good chance they've already been in regular communication with the
maintainer (do people really send completely off the wall assignments?).

So if something extra is needed (an `authorization mail' from the
maintainer or whatever), it seems like the reply from <assign@gnu.org>
should say what it is.

Yeah, this is just sort of random bitching, but many people find
assignments a pain in general, so I think it's good to make the process
as streamlined as possible.

-Miles
-- 
Come now, if we were really planning to harm you, would we be waiting here, 
 beside the path, in the very darkest part of the forest?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-10 16:22                         ` Andreas Büsching
  2003-09-10 16:50                           ` David Kastrup
  2003-09-10 19:40                           ` Alex Schroeder
@ 2003-09-11 23:46                           ` Richard Stallman
  2003-09-12 15:38                             ` Stefan Monnier
  2 siblings, 1 reply; 34+ messages in thread
From: Richard Stallman @ 2003-09-11 23:46 UTC (permalink / raw)
  Cc: dak, emacs-devel, monnier, miles

    Looks like you know more about it. Is Stefan right with his suggestion?
    I just need to send an e-mail to <assign@gnu.org> and explain that I
    would like to contribute some code to GNU Emacs and they do the rest?

We don't do things that way (and we never did).

The way it works is that the package maintainer sends you a
questionaire and you mail the answers to assign@gnu.org.  The package
maintainer in this case is me, though I would not mind if some of the
other main Emacs developers sometimes do this too.

First let's see if we need to use enough of your code that we do need
papers.

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11  6:57                   ` Andreas Büsching
@ 2003-09-11 23:47                     ` Richard Stallman
  2003-09-12  5:22                       ` Andreas Buesching
  2003-09-12  7:35                       ` Andreas Büsching
  0 siblings, 2 replies; 34+ messages in thread
From: Richard Stallman @ 2003-09-11 23:47 UTC (permalink / raw)
  Cc: emacs-devel, monnier, miles

I already modified your first patch to do part of the job right,
and I will install that.  You've seen the patch I will install.

Can you show me what *additional* patch is called for, and tell
me which parts of it were written by you and which by others?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11 23:47                     ` Richard Stallman
@ 2003-09-12  5:22                       ` Andreas Buesching
  2003-09-12 21:06                         ` Richard Stallman
  2003-09-12  7:35                       ` Andreas Büsching
  1 sibling, 1 reply; 34+ messages in thread
From: Andreas Buesching @ 2003-09-12  5:22 UTC (permalink / raw)
  Cc: emacs-devel, monnier, miles

On Fri, 2003-09-12 at 01:47, Richard Stallman wrote:
> I already modified your first patch to do part of the job right,
> and I will install that.  You've seen the patch I will install.
> 
> Can you show me what *additional* patch is called for, and tell
> me which parts of it were written by you and which by others?

The last version of the patch contains my complete code plus about 11
lines from you. So now it's your decision what do as the maintainer of
emacs. I'm prepared to sign the papers if required, but I can also life
with it, if the patch is accepted without it.

crunchy

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11 23:47                     ` Richard Stallman
  2003-09-12  5:22                       ` Andreas Buesching
@ 2003-09-12  7:35                       ` Andreas Büsching
  1 sibling, 0 replies; 34+ messages in thread
From: Andreas Büsching @ 2003-09-12  7:35 UTC (permalink / raw)
  Cc: emacs-devel, monnier, miles

Richard Stallman <rms@gnu.org> wrote:

> I already modified your first patch to do part of the job right,
> and I will install that.  You've seen the patch I will install.
>
> Can you show me what *additional* patch is called for, and tell
> me which parts of it were written by you and which by others?

Looks like you decided that my chances are small enough, so that I do
not need to sign the papers. That's okay, but there is something in the
patch that you did not mention in the ChangeLog: Emacsclient is now
able to read Lisp code from stdin, which means, if the argument -e or
--eval is given and there is no further argument, than stdin is used
for input.

And you checked in a buggy comment:

/* If non-NULL, thefilename of the UNIX socket */

                   ^

It was a little complicate, but thanks that you accepted my ideas for
extending emacsclient.

crunchy

-- 
Everybody lies, but it doesn't matter since nobody listens.

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11 23:46                           ` Richard Stallman
@ 2003-09-12 15:38                             ` Stefan Monnier
  2003-09-12 22:49                               ` Alex Schroeder
  2003-09-13 13:56                               ` Richard Stallman
  0 siblings, 2 replies; 34+ messages in thread
From: Stefan Monnier @ 2003-09-12 15:38 UTC (permalink / raw)
  Cc: miles, emacs-devel, dak, g

> The way it works is that the package maintainer sends you a
> questionaire and you mail the answers to assign@gnu.org.  The package
> maintainer in this case is me, though I would not mind if some of the
> other main Emacs developers sometimes do this too.

I'd be happy to do it whenever I get the chance, but I must admit that I've
never managed to figure out how it really works (partly because it seems
that it has changed since I signed my papers).  What questionaire should
I send? where can I find it? do I need to edit it in some way before
sending it? where could I find the answers to those questions?


        Stefan

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

* Re: extensions for emacsclient (CVS version)
  2003-09-12  5:22                       ` Andreas Buesching
@ 2003-09-12 21:06                         ` Richard Stallman
  0 siblings, 0 replies; 34+ messages in thread
From: Richard Stallman @ 2003-09-12 21:06 UTC (permalink / raw)
  Cc: emacs-devel, monnier, miles

Now that I have installed one change, would you please
send a diff -c that shows the *remaining* changes you propose?

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

* Re: extensions for emacsclient (CVS version)
  2003-09-11 21:22                               ` Miles Bader
@ 2003-09-12 21:06                                 ` Richard Stallman
  0 siblings, 0 replies; 34+ messages in thread
From: Richard Stallman @ 2003-09-12 21:06 UTC (permalink / raw)
  Cc: emacs-devel

    Maybe it's explained by a part of the message you didn't include in this
    excerpt, but I find that very confusing -- it doesn't say _why_ it's
    necessary to `communicate with the maintainer,' or what to ask them.
    Just, `communicate.'

Thanks for pointing that out.  I agree, so I will get this message
clarified.

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

* Re: extensions for emacsclient (CVS version)
  2003-09-12 15:38                             ` Stefan Monnier
@ 2003-09-12 22:49                               ` Alex Schroeder
  2003-09-13 13:56                               ` Richard Stallman
  1 sibling, 0 replies; 34+ messages in thread
From: Alex Schroeder @ 2003-09-12 22:49 UTC (permalink / raw)


"Stefan Monnier" <monnier@IRO.UMontreal.CA> writes:

> I'd be happy to do it whenever I get the chance, but I must admit that I've
> never managed to figure out how it really works (partly because it seems
> that it has changed since I signed my papers).  What questionaire should
> I send? where can I find it? do I need to edit it in some way before
> sending it? where could I find the answers to those questions?

You need the info from a gnu.org machine...
See http://www.gnu.org/prep/maintain_5.html#SEC5 or the "Information
For Maintainers of GNU Software" manual (maintain.info?)

Alex.
-- 
http://www.emacswiki.org/alex/
There is no substitute for experience.

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

* Re: extensions for emacsclient (CVS version)
  2003-09-12 15:38                             ` Stefan Monnier
  2003-09-12 22:49                               ` Alex Schroeder
@ 2003-09-13 13:56                               ` Richard Stallman
  1 sibling, 0 replies; 34+ messages in thread
From: Richard Stallman @ 2003-09-13 13:56 UTC (permalink / raw)
  Cc: emacs-devel, dak, crunchy, miles

    I'd be happy to do it whenever I get the chance, but I must admit that I've
    never managed to figure out how it really works (partly because it seems
    that it has changed since I signed my papers).  What questionaire should
    I send? where can I find it? do I need to edit it in some way before
    sending it? where could I find the answers to those questions?

The file maintain.texi is supposed to answer all these questions.
It should be available in www.gnu.org/prep.
Does it make things clear?

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

end of thread, other threads:[~2003-09-13 13:56 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-10  8:26 extensions for emacsclient (CVS version) Andreas Büsching
2003-09-10  8:44 ` Miles Bader
2003-09-10  9:00   ` Andreas Büsching
2003-09-10  9:30     ` Miles Bader
2003-09-10 10:56       ` Andreas Büsching
2003-09-10 11:36         ` Miles Bader
2003-09-10 11:40           ` Andreas Büsching
2003-09-10 12:38             ` Stefan Monnier
2003-09-10 13:45               ` Andreas Büsching
2003-09-10 14:37                 ` Miles Bader
2003-09-10 15:00                   ` Andreas Büsching
2003-09-10 15:09                     ` Miles Bader
2003-09-11  6:57                   ` Andreas Büsching
2003-09-11 23:47                     ` Richard Stallman
2003-09-12  5:22                       ` Andreas Buesching
2003-09-12 21:06                         ` Richard Stallman
2003-09-12  7:35                       ` Andreas Büsching
2003-09-10 14:41                 ` Stefan Monnier
2003-09-10 15:02                   ` Andreas Büsching
2003-09-10 15:08                     ` Stefan Monnier
2003-09-10 16:13                       ` David Kastrup
2003-09-10 16:22                         ` Andreas Büsching
2003-09-10 16:50                           ` David Kastrup
2003-09-10 19:40                           ` Alex Schroeder
2003-09-11  5:20                             ` Andreas Buesching
2003-09-11 19:30                             ` Andreas Buesching
2003-09-11 21:22                               ` Miles Bader
2003-09-12 21:06                                 ` Richard Stallman
2003-09-11 23:46                           ` Richard Stallman
2003-09-12 15:38                             ` Stefan Monnier
2003-09-12 22:49                               ` Alex Schroeder
2003-09-13 13:56                               ` Richard Stallman
2003-09-11 13:16 ` Richard Stallman
2003-09-11 14:15   ` Andreas Büsching

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).