all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacsclient: --quiet/--verbose
@ 2006-11-30  5:34 Michael Mauger
  2006-11-30 22:59 ` Juanma Barranquero
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Michael Mauger @ 2006-11-30  5:34 UTC (permalink / raw)


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

As I've moved over to emacsclient from gnuclient, I've found a couple of areas where it's behavior is awkward, although not wrong per se.  

This patch adds:
* a --quiet option to suppress informational messages from emacsclient
* In emacsclientw, defaults to --quiet and --no-wait
* adds --wait and --verbose options to override the defaults in emacsclientw

If it's deemed to be too late in pretest for these that's fine, but this is a small change and leads to better interaction.

[-- Attachment #2: ec-quiet.diff --]
[-- Type: text/plain, Size: 3493 bytes --]

Index: emacs/lib-src/emacsclient.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.96
diff -c -r1.96 emacsclient.c
*** emacs/lib-src/emacsclient.c	25 Nov 2006 00:32:40 -0000	1.96
--- emacs/lib-src/emacsclient.c	30 Nov 2006 04:50:55 -0000
***************
*** 113,118 ****
--- 113,121 ----
  /* Nonzero means don't wait for a response from Emacs.  --no-wait.  */
  int nowait = 0;
  
+ /* Nonzero means don't display informational messages.  --quiet.  */
+ int quiet = 0;
+ 
  /* Nonzero means args are expressions to be evaluated.  --eval.  */
  int eval = 0;
  
***************
*** 134,139 ****
--- 137,145 ----
  struct option longopts[] =
  {
    { "no-wait",	no_argument,	   NULL, 'n' },
+   { "wait",	no_argument,	   NULL, 'w' },
+   { "quiet",	no_argument,	   NULL, 'q' },
+   { "verbose",	no_argument,	   NULL, 'v' },
    { "eval",	no_argument,	   NULL, 'e' },
    { "help",	no_argument,	   NULL, 'H' },
    { "version",	no_argument,	   NULL, 'V' },
***************
*** 172,177 ****
--- 178,185 ----
    char *msg = buf;
    va_list args;
  
+   if (!is_error && quiet) return;
+ 
    va_start (args, message);
  
    if (is_error)
***************
*** 206,218 ****
  {
    alternate_editor = getenv ("ALTERNATE_EDITOR");
  
    while (1)
      {
        int opt = getopt_long (argc, argv,
  #ifndef NO_SOCKETS_IN_FILE_SYSTEM
! 			     "VHnea:s:f:d:",
  #else
!                              "VHnea:f:d:",
  #endif
                               longopts, 0);
  
--- 214,234 ----
  {
    alternate_editor = getenv ("ALTERNATE_EDITOR");
  
+ #ifdef WINDOWSNT
+   if (w32_window_app ())
+     {
+       nowait = 1;
+       quiet = 1;
+     }
+ #endif
+ 
    while (1)
      {
        int opt = getopt_long (argc, argv,
  #ifndef NO_SOCKETS_IN_FILE_SYSTEM
! 			     "VHqvwnea:s:f:d:",
  #else
! 			     "VHqvwnea:f:d:",
  #endif
                               longopts, 0);
  
***************
*** 248,258 ****
--- 264,287 ----
  	  nowait = 1;
  	  break;
  
+ 	case 'w':
+ 	  nowait = 0;
+ 	  break;
+ 
+ 	case 'q':
+ 	  quiet = 1;
+ 	  break;
+ 
+ 	case 'v':
+ 	  quiet = 0;
+ 	  break;
+ 
  	case 'e':
  	  eval = 1;
  	  break;
  
  	case 'V':
+ 	  quiet = 0;
  	  message (FALSE, "emacsclient %s\n", VERSION);
  	  exit (EXIT_SUCCESS);
  	  break;
***************
*** 272,277 ****
--- 301,307 ----
  void
  print_help_and_exit ()
  {
+   quiet = 0;
    message (FALSE,
  	  "Usage: %s [OPTIONS] FILE...\n\
  Tell the Emacs server to visit the specified files.\n\
***************
*** 281,287 ****
--- 311,320 ----
  \n\
  -V, --version		Just print version info and return\n\
  -H, --help   		Print this usage information message\n\
+ -q, --quiet		Do not display informational messages\n\
+ -v, --verbose		Display informational messages\n\
  -e, --eval   		Evaluate FILE arguments as Lisp expressions\n\
+ -w, --wait		Wait for the server to return\n\
  -n, --no-wait		Don't wait for the server to return\n\
  -d, --display=DISPLAY	Visit the file in the given display\n"
  #ifndef NO_SOCKETS_IN_FILE_SYSTEM
***************
*** 928,934 ****
    /* Maybe wait for an answer.   */
    if (!nowait)
      {
!       if (!eval)
          {
            printf ("Waiting for Emacs...");
            needlf = 2;
--- 961,967 ----
    /* Maybe wait for an answer.   */
    if (!nowait)
      {
!       if (!eval && !quiet)
          {
            printf ("Waiting for Emacs...");
            needlf = 2;

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

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

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

* Re: emacsclient: --quiet/--verbose
  2006-11-30  5:34 emacsclient: --quiet/--verbose Michael Mauger
@ 2006-11-30 22:59 ` Juanma Barranquero
  2006-11-30 23:20   ` Lennart Borgman
  2006-12-01  0:47   ` Michael Mauger
  2006-12-01  9:12 ` Jason Rumney
  2006-12-01 13:37 ` Richard Stallman
  2 siblings, 2 replies; 12+ messages in thread
From: Juanma Barranquero @ 2006-11-30 22:59 UTC (permalink / raw)
  Cc: Emacs Devel

On 11/30/06, Michael Mauger <mmaug@yahoo.com> wrote:

> If it's deemed to be too late in pretest for these that's fine, but this is a small change and leads to better interaction.

The patch is small and clear, but let's defer to Richard on this one.

BTW, after your previous patch I've committed a change to delay
calling AllowSetForegroundWindow; otherwise, Emacs could not grab the
focus when emacsclientw was used to connect to a remote server  (at
least, if the "remote server" was the same machine) because
emacsclientw itself grabbed it with its message box.

I don't think that change will affect this second patch of yours, but
better you check it out.

                    /L/e/k/t/u

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

* Re: emacsclient: --quiet/--verbose
  2006-11-30 22:59 ` Juanma Barranquero
@ 2006-11-30 23:20   ` Lennart Borgman
  2006-12-01 10:12     ` Eli Zaretskii
  2006-12-01  0:47   ` Michael Mauger
  1 sibling, 1 reply; 12+ messages in thread
From: Lennart Borgman @ 2006-11-30 23:20 UTC (permalink / raw)
  Cc: Michael Mauger, Emacs Devel

Juanma Barranquero wrote:
> On 11/30/06, Michael Mauger <mmaug@yahoo.com> wrote:
> 
>> If it's deemed to be too late in pretest for these that's fine, but 
>> this is a small change and leads to better interaction.
> 
> The patch is small and clear, but let's defer to Richard on this one.
> 
> BTW, after your previous patch I've committed a change to delay
> calling AllowSetForegroundWindow; otherwise, Emacs could not grab the
> focus when emacsclientw was used to connect to a remote server  (at
> least, if the "remote server" was the same machine) because
> emacsclientw itself grabbed it with its message box.
> 
> I don't think that change will affect this second patch of yours, but
> better you check it out.


Could you please send me the patches you commit for emacsclient.c so I 
can stay as much as possible in sync?

BTW, the new implementation I made for message takes care of the 
foreground problem too.

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

* Re: emacsclient: --quiet/--verbose
  2006-11-30 22:59 ` Juanma Barranquero
  2006-11-30 23:20   ` Lennart Borgman
@ 2006-12-01  0:47   ` Michael Mauger
  2006-12-01  1:10     ` Juanma Barranquero
  1 sibling, 1 reply; 12+ messages in thread
From: Michael Mauger @ 2006-12-01  0:47 UTC (permalink / raw)




Juanma Barranquero wrote:
> 
> On 11/30/06, Michael Mauger <mmaug@yahoo.com> wrote:
> 
>> If it's deemed to be too late in pretest for these that's fine, but this
>> is a small change and leads to better interaction.
> 
> The patch is small and clear, but let's defer to Richard on this one.
> 
> BTW, after your previous patch I've committed a change to delay
> calling AllowSetForegroundWindow; otherwise, Emacs could not grab the
> focus when emacsclientw was used to connect to a remote server  (at
> least, if the "remote server" was the same machine) because
> emacsclientw itself grabbed it with its message box.
> 
> I don't think that change will affect this second patch of yours, but
> better you check it out.
> 
>                     /L/e/k/t/u
> 

A couple of questions on the use of AllowSetForegroundWindow:

* Should it be used if the emacs is "remote" i.e. not at 127.0.0.1?  What if
emacsclientw is running on w32, Emacs is running on Unix, and you try to
foreground a Unix pid.  Is it possible to confirm that a remote host is
actually the local host?  Is it worthwhile to do so?

* Is the AllowSetForegroundWindow really necessary since it isn't called
when emacsclient is run on Unix to a w32 Emacs yet the w32 Emacs responds
and raises in the window stack as you'd expect.


Finally, if people could take another look at the Tramp changes I proposed
for emacsclient.  Again, I'll defer to Richard on whether they should be
committed, but they make the use of multiple remote hosts talking to a
single Emacs much easier.  I can type fc at my Unix shell prompt and edit
the command in my w32 Emacs.  BTW, I do have an updated version (minor
changes) of that patch which I can post, but I'll wait until its clear we
want to move forward.  I'm running with it and it works flawlessly.

-- 
View this message in context: http://www.nabble.com/emacsclient%3A---quiet---verbose-tf2733832.html#a7631420
Sent from the Emacs - Dev mailing list archive at Nabble.com.

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

* Re: emacsclient: --quiet/--verbose
  2006-12-01  0:47   ` Michael Mauger
@ 2006-12-01  1:10     ` Juanma Barranquero
  2006-12-01  3:39       ` Michael Mauger
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2006-12-01  1:10 UTC (permalink / raw)
  Cc: Emacs-devel

On 12/1/06, Michael Mauger <mmaug@yahoo.com> wrote:

> * Should it be used if the emacs is "remote" i.e. not at 127.0.0.1?  What if
> emacsclientw is running on w32, Emacs is running on Unix, and you try to
> foreground a Unix pid.  Is it possible to confirm that a remote host is
> actually the local host?  Is it worthwhile to do so?

Of course, it is entirely possible to have server-host set to a
non-127.0.0.1 address which is, in fact, local. What emacsclient
should do is to check the address of the server (from the server file)
and, if not 127.0.0.1, get a list of the addresses of the local
machine it is running in, and detect whether the server-host address
is in fact local or not. The code to do that amounts to 10-15 lines of
C.

However, I don't think it is necessary right now. The worst that can
happen is that emacsclient calls AllowSetForegroundWindow on the pid
of a process which doesn't expect it (and which won't grab the focus
unless it is doing something like moving a window, etc.), or on an
nonexistent pid (in which case ASFW will return an error, which is
ignored anyway).

> * Is the AllowSetForegroundWindow really necessary since it isn't called
> when emacsclient is run on Unix to a w32 Emacs yet the w32 Emacs responds
> and raises in the window stack as you'd expect.

Obviously, because the Emacs on Windows is not fighting for the focus
against the Unix emacsclient. However, it is necessary on Windows,
when called from the same machine, because Emacs and the console
session you're using to run emacsclient fight for the focus. That
doesn't happen if some other program executes emacsclient as a
subprocess, perhaps. But 99% of my uses of emasclient are from a CMD
(4NT, really) console.

> Finally, if people could take another look at the Tramp changes I proposed
> for emacsclient.

I don't have anything about emacsclient using Tramp, as long as it is
not the only way, of course. TCP sockets are fine for my uses.

                    /L/e/k/t/u

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

* Re: emacsclient: --quiet/--verbose
  2006-12-01  1:10     ` Juanma Barranquero
@ 2006-12-01  3:39       ` Michael Mauger
  2006-12-02 19:03         ` Lennart Borgman
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Mauger @ 2006-12-01  3:39 UTC (permalink / raw)




Juanma Barranquero wrote:
> 
> On 12/1/06, Michael Mauger <mmaug@yahoo.com> wrote:
> 
>> Finally, if people could take another look at the Tramp changes I
>> proposed
>> for emacsclient.
> 
> I don't have anything about emacsclient using Tramp, as long as it is
> not the only way, of course. TCP sockets are fine for my uses.
> 
> 

See http://lists.gnu.org/archive/html/emacs-devel/2006-11/msg01195.html for
the Tramp patch.

The use of Tramp doesn't impact how emacsclient and emacs communicate.  It
has to do with how does emacs addresses the file that resides on a remote
machine.  My patch allowed you on the remote machine to address the file
locally to emacsclient, but pass a filename that would appear remote to
emacs.  Obviously, if emacsclient and emacs were on the same machine, the
Tramp settings would not be set and things would work as they do now.  (The
version of gnuclient I use to use had a similar feature that spoiled me
rotten.)

An example:

me@aaa $ emacs &
me@aaa $ ssh bbb -l me

me@bbb $ scp me@aaa:.emacs.d/server/server ~/.emacs.d/server/me-aaa
me@bbb $ EMACS_SERVER_FILE=$HOME/.emacs.d/server/me-aaa
me@bbb $ export EMACS_SERVER_FILE
me@bbb $ cd /etc

(Now I want to edit the /etc/hosts file but there is no emacs available on
bbb,  so I ask to edit it in the emacs instance under me@aaa)

me@bbb $ emacsclient /me@bbb:/etc/hosts    # without Tramp support 
                      # Must specify Tramp prefix and absolute file name

me@bbb $ EMACS_TRAMP_PREFIX=/me@bbb:
me@bbb $ export EMACS_TRAMP_PREFIX
me@bbb $ emacsclient hosts                          # same as above with
Tramp support
                      # emacsclient sends Tramp prefix and makes filename
absolute

Without the Tramp support, I cannot use emacsclient on the second/remote
host as a value for EDITOR, et al..

As I mentioned, I have an updated version of this patch.  The one in the
original thread crashes when EMACS_TRAMP_PREFIX is not set, but it's easily
fixed by adding "if (tramp_prefix)" before the "SEND_QUOTED
(tramp_prefix);".  
-- 
View this message in context: http://www.nabble.com/emacsclient%3A---quiet---verbose-tf2733832.html#a7632932
Sent from the Emacs - Dev mailing list archive at Nabble.com.

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

* Re: emacsclient: --quiet/--verbose
  2006-11-30  5:34 emacsclient: --quiet/--verbose Michael Mauger
  2006-11-30 22:59 ` Juanma Barranquero
@ 2006-12-01  9:12 ` Jason Rumney
  2006-12-01 13:37 ` Richard Stallman
  2 siblings, 0 replies; 12+ messages in thread
From: Jason Rumney @ 2006-12-01  9:12 UTC (permalink / raw)
  Cc: Emacs Devel

Michael Mauger wrote:
> * In emacsclientw, defaults to --quiet and --no-wait
>   
Why? Neither of these is needed, and the second is undesirable for many 
uses of emacsclientw.

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

* Re: emacsclient: --quiet/--verbose
  2006-11-30 23:20   ` Lennart Borgman
@ 2006-12-01 10:12     ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2006-12-01 10:12 UTC (permalink / raw)
  Cc: lekktu, mmaug, emacs-devel

> Date: Fri, 01 Dec 2006 00:20:38 +0100
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> Cc: Michael Mauger <mmaug@yahoo.com>, Emacs Devel <emacs-devel@gnu.org>
> 
> Could you please send me the patches you commit for emacsclient.c so I 
> can stay as much as possible in sync?

You can subscribe to emacs-commit or emacs-diffs mailing lists, where
you will see all the changes that are committed.  If you cannot sync
with CVS yourself, that is.

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

* Re: emacsclient: --quiet/--verbose
  2006-11-30  5:34 emacsclient: --quiet/--verbose Michael Mauger
  2006-11-30 22:59 ` Juanma Barranquero
  2006-12-01  9:12 ` Jason Rumney
@ 2006-12-01 13:37 ` Richard Stallman
  2 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2006-12-01 13:37 UTC (permalink / raw)
  Cc: emacs-devel

The change is small, but what change in documentation would you
propose to go with this?

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

* Re: emacsclient: --quiet/--verbose
  2006-12-01  3:39       ` Michael Mauger
@ 2006-12-02 19:03         ` Lennart Borgman
  0 siblings, 0 replies; 12+ messages in thread
From: Lennart Borgman @ 2006-12-02 19:03 UTC (permalink / raw)
  Cc: Emacs-devel

Michael Mauger wrote:
> 
> Juanma Barranquero wrote:
>> On 12/1/06, Michael Mauger <mmaug@yahoo.com> wrote:
>>
>>> Finally, if people could take another look at the Tramp changes I
>>> proposed
>>> for emacsclient.
>> I don't have anything about emacsclient using Tramp, as long as it is
>> not the only way, of course. TCP sockets are fine for my uses.
>>
>>
> 
> See http://lists.gnu.org/archive/html/emacs-devel/2006-11/msg01195.html for
> the Tramp patch.
> 
> The use of Tramp doesn't impact how emacsclient and emacs communicate.  It
> has to do with how does emacs addresses the file that resides on a remote
> machine.  My patch allowed you on the remote machine to address the file
> locally to emacsclient, but pass a filename that would appear remote to
> emacs.  Obviously, if emacsclient and emacs were on the same machine, the
> Tramp settings would not be set and things would work as they do now.  (The
> version of gnuclient I use to use had a similar feature that spoiled me
> rotten.)
> 
> An example:
> 
> me@aaa $ emacs &
> me@aaa $ ssh bbb -l me
> 
> me@bbb $ scp me@aaa:.emacs.d/server/server ~/.emacs.d/server/me-aaa
> me@bbb $ EMACS_SERVER_FILE=$HOME/.emacs.d/server/me-aaa
> me@bbb $ export EMACS_SERVER_FILE
> me@bbb $ cd /etc
> 
> (Now I want to edit the /etc/hosts file but there is no emacs available on
> bbb,  so I ask to edit it in the emacs instance under me@aaa)
> 
> me@bbb $ emacsclient /me@bbb:/etc/hosts    # without Tramp support 
>                       # Must specify Tramp prefix and absolute file name
> 
> me@bbb $ EMACS_TRAMP_PREFIX=/me@bbb:
> me@bbb $ export EMACS_TRAMP_PREFIX
> me@bbb $ emacsclient hosts                          # same as above with
> Tramp support
>                       # emacsclient sends Tramp prefix and makes filename
> absolute


I do not think this can work. (Or am I misunderstanding something?) 
Emacsclient have to expand local file names before sending them to emacs 
server since the server and the client may have different working 
directories.

Could not your problem be solved with a shell script that adds 
EMACS_TRAMP_PREFIX to the file names before calling emacsclient?

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

* Re: emacsclient: --quiet/--verbose
@ 2006-12-02 22:02 Michael Mauger
  2006-12-03 12:25 ` Lennart Borgman
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Mauger @ 2006-12-02 22:02 UTC (permalink / raw)
  Cc: Emacs-devel

Lennart Borgman wrote:

>Michael Mauger wrote:
>> Juanma Barranquero wrote:
>>> On 12/1/06, Michael Mauger <mmaug@yahoo.com> wrote:
>>>
>>>> Finally, if people could take another look at the Tramp changes I
>>>> proposed for emacsclient.
>>> I don't have anything about emacsclient using Tramp, as long as it is
>>> not the only way, of course. TCP sockets are fine for my uses.
>> 
>> See http://lists.gnu.org/archive/html/emacs-devel/2006-11/msg01195.html for
>> the Tramp patch.
>> 
>> The use of Tramp doesn't impact how emacsclient and emacs communicate.  It
>> has to do with how does emacs addresses the file that resides on a remote
>> machine.  My patch allowed you on the remote machine to address the file
>> locally to emacsclient, but pass a filename that would appear remote to
>> emacs.  Obviously, if emacsclient and emacs were on the same machine, the
>> Tramp settings would not be set and things would work as they do now.  (The
>> version of gnuclient I use to use had a similar feature that spoiled me
>> rotten.)
>> 
>> An example:
>> 
>> me@aaa $ emacs &
>> me@aaa $ ssh bbb -l me
>> 
>> me@bbb $ scp me@aaa:.emacs.d/server/server ~/.emacs.d/server/me-aaa
>> me@bbb $ EMACS_SERVER_FILE=$HOME/.emacs.d/server/me-aaa
>> me@bbb $ export EMACS_SERVER_FILE
>> me@bbb $ cd /etc
>> 
>> (Now I want to edit the /etc/hosts file but there is no emacs available on
>> bbb,  so I ask to edit it in the emacs instance under me@aaa)
>> 
>> me@bbb $ emacsclient /me@bbb:/etc/hosts    # without Tramp support 
>>                       # Must specify Tramp prefix and absolute file name
>> 
>> me@bbb $ EMACS_TRAMP_PREFIX=/me@bbb:
>> me@bbb $ export EMACS_TRAMP_PREFIX
>> me@bbb $ emacsclient hosts                          # same as above with
>> Tramp support
>>                       # emacsclient sends Tramp prefix and makes filename
>> absolute
>
>
>I do not think this can work. (Or am I misunderstanding something?) 
>Emacsclient have to expand local file names before sending them to emacs 
>server since the server and the client may have different working 
>directories.
>
>Could not your problem be solved with a shell script that adds 
>EMACS_TRAMP_PREFIX to the file names before calling emacsclient?
>

Actually it works very nicely.  emacsclient expands the local filename into an absolute filename (as it currenty does) and prefixes that with the Tramp prefix when it sends it to Emacs.  I use emacsclient no differently than if the emacs instance were local, and it communicates the correct filename (not only in the correct directory, but on the correct remote machine).

And yes this could be done with a script around emacsclient, but the script would have to make the filename absolute itself (because the Tramp prefix will make the filename look absolute already).  Obviously, not difficult, but with a small patch, emacsclient can do all of it out-of-the-box.

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

* Re: emacsclient: --quiet/--verbose
  2006-12-02 22:02 Michael Mauger
@ 2006-12-03 12:25 ` Lennart Borgman
  0 siblings, 0 replies; 12+ messages in thread
From: Lennart Borgman @ 2006-12-03 12:25 UTC (permalink / raw)
  Cc: Emacs-devel

Michael Mauger wrote:
> Lennart Borgman wrote:
> 
>> Michael Mauger wrote:
>>> Juanma Barranquero wrote:
>>>> On 12/1/06, Michael Mauger <mmaug@yahoo.com> wrote:
>>>>
>>>>> Finally, if people could take another look at the Tramp changes I
>>>>> proposed for emacsclient.
>>>> I don't have anything about emacsclient using Tramp, as long as it is
>>>> not the only way, of course. TCP sockets are fine for my uses.
>>> See http://lists.gnu.org/archive/html/emacs-devel/2006-11/msg01195.html for
>>> the Tramp patch.
>>>
>>> The use of Tramp doesn't impact how emacsclient and emacs communicate.  It
>>> has to do with how does emacs addresses the file that resides on a remote
>>> machine.  My patch allowed you on the remote machine to address the file
>>> locally to emacsclient, but pass a filename that would appear remote to
>>> emacs.  Obviously, if emacsclient and emacs were on the same machine, the
>>> Tramp settings would not be set and things would work as they do now.  (The
>>> version of gnuclient I use to use had a similar feature that spoiled me
>>> rotten.)
>>>
>>> An example:
>>>
>>> me@aaa $ emacs &
>>> me@aaa $ ssh bbb -l me
>>>
>>> me@bbb $ scp me@aaa:.emacs.d/server/server ~/.emacs.d/server/me-aaa
>>> me@bbb $ EMACS_SERVER_FILE=$HOME/.emacs.d/server/me-aaa
>>> me@bbb $ export EMACS_SERVER_FILE
>>> me@bbb $ cd /etc
>>>
>>> (Now I want to edit the /etc/hosts file but there is no emacs available on
>>> bbb,  so I ask to edit it in the emacs instance under me@aaa)
>>>
>>> me@bbb $ emacsclient /me@bbb:/etc/hosts    # without Tramp support 
>>>                       # Must specify Tramp prefix and absolute file name
>>>
>>> me@bbb $ EMACS_TRAMP_PREFIX=/me@bbb:
>>> me@bbb $ export EMACS_TRAMP_PREFIX
>>> me@bbb $ emacsclient hosts                          # same as above with
>>> Tramp support
>>>                       # emacsclient sends Tramp prefix and makes filename
>>> absolute
>>
>> I do not think this can work. (Or am I misunderstanding something?) 
>> Emacsclient have to expand local file names before sending them to emacs 
>> server since the server and the client may have different working 
>> directories.
>>
>> Could not your problem be solved with a shell script that adds 
>> EMACS_TRAMP_PREFIX to the file names before calling emacsclient?
>>
> 
> Actually it works very nicely.  emacsclient expands the local filename into an absolute filename (as it currenty does) and prefixes that with the Tramp prefix when it sends it to Emacs.  I use emacsclient no differently than if the emacs instance were local, and it communicates the correct filename (not only in the correct directory, but on the correct remote machine).
> 
> And yes this could be done with a script around emacsclient, but the script would have to make the filename absolute itself (because the Tramp prefix will make the filename look absolute already).  Obviously, not difficult, but with a small patch, emacsclient can do all of it out-of-the-box.


Sorry, I misunderstood it totally though you described it so carefully.

Your suggestion is more portable than letting a script expand the file 
name. And as you said it would only require minimal changes to 
emacsclient.c.

But maybe EMACSCLIENT_TRAMP_PREFIX is better? It is not handled by Emacs 
itself.

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

end of thread, other threads:[~2006-12-03 12:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-30  5:34 emacsclient: --quiet/--verbose Michael Mauger
2006-11-30 22:59 ` Juanma Barranquero
2006-11-30 23:20   ` Lennart Borgman
2006-12-01 10:12     ` Eli Zaretskii
2006-12-01  0:47   ` Michael Mauger
2006-12-01  1:10     ` Juanma Barranquero
2006-12-01  3:39       ` Michael Mauger
2006-12-02 19:03         ` Lennart Borgman
2006-12-01  9:12 ` Jason Rumney
2006-12-01 13:37 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2006-12-02 22:02 Michael Mauger
2006-12-03 12:25 ` Lennart Borgman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.