unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] add emacsclient support to open with file:linum syntax
@ 2016-01-07 22:35 Jorge Alberto Garcia
  2016-01-08  7:42 ` Yuri Khan
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-07 22:35 UTC (permalink / raw)
  To: emacs-devel

Hi !

I wrote a little patch to emacsclient,
Could you review it ?, this is my first attempt to contribute :)

Description

With this you can do this from cmdline:
$ emacsclient -q  -c lib-src/emacsclient.c:1593

in addition to have our already trusted way
lib-src/emacsclient -q   +1593 -c lib-src/emacsclient.c


- Why I did it ?
I found myself using tools that provides text location using
filepath:line but couldn't  use it directly by emacsclient.

-Jorge

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index c3e5635..be9c9cc 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1593,7 +1593,7 @@ main (int argc, char **argv)
   char string[BUFSIZ+1];
   int start_daemon_if_needed;
   int exit_status = EXIT_SUCCESS;
-
+  char *lineDst;
   main_argv = argv;
   progname = argv[0];

@@ -1747,6 +1747,21 @@ main (int argc, char **argv)
                   continue;
                 }
             }
+
+  lineDst = index(argv[i],':');
+          if ( lineDst != NULL)
+            {
+      char *p = lineDst + 1;
+      while (isdigit ((unsigned char) *p) || *p == ':') p++;
+      if (*p == 0)
+                {
+                  send_to_emacs (emacs_socket, "-position ");
+  *lineDst='+';
+                  quote_argument (emacs_socket, lineDst);
+                  send_to_emacs (emacs_socket, " ");
+                }
+            }
+
 #ifdef WINDOWSNT
   else if (! file_name_absolute_p (argv[i])
    && (isalpha (argv[i][0]) && argv[i][1] == ':'))
@@ -1768,7 +1783,10 @@ main (int argc, char **argv)
     }
 #endif

-          send_to_emacs (emacs_socket, "-file ");
+  send_to_emacs (emacs_socket, "-file ");
+  if(lineDst != NULL){
+    *lineDst = 0;
+  }
           quote_argument (emacs_socket, argv[i]);
           send_to_emacs (emacs_socket, " ");
         }



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-07 22:35 Jorge Alberto Garcia
@ 2016-01-08  7:42 ` Yuri Khan
  2016-01-08  8:08   ` Jorge Alberto Garcia
  2016-01-08  9:03   ` Eli Zaretskii
  0 siblings, 2 replies; 43+ messages in thread
From: Yuri Khan @ 2016-01-08  7:42 UTC (permalink / raw)
  To: Jorge Alberto Garcia; +Cc: Emacs developers

On Fri, Jan 8, 2016 at 4:35 AM, Jorge Alberto Garcia
<jorge.garcia.gonzalez@gmail.com> wrote:

> With this you can do this from cmdline:
> $ emacsclient -q  -c lib-src/emacsclient.c:1593

What if you want to edit a file whose name is literally “emacsclient.c:1593”?

What if a Windows user wants to edit an NTFS stream named 1593 in file
emacsclient.c?



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08  7:42 ` Yuri Khan
@ 2016-01-08  8:08   ` Jorge Alberto Garcia
  2016-01-08  8:59     ` Yuri Khan
  2016-01-08  9:03   ` Eli Zaretskii
  1 sibling, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08  8:08 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Emacs developers

On Fri, Jan 8, 2016 at 1:42 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> On Fri, Jan 8, 2016 at 4:35 AM, Jorge Alberto Garcia
> <jorge.garcia.gonzalez@gmail.com> wrote:
>
>> With this you can do this from cmdline:
>> $ emacsclient -q  -c lib-src/emacsclient.c:1593
>
> What if you want to edit a file whose name is literally “emacsclient.c:1593”?
>
> What if a Windows user wants to edit an NTFS stream named 1593 in file
> emacsclient.c?

mm, interesting !

We could extend the meaning of  '+' to indicate a linenum:column will
be present,
So we could use one of these syntax:

(new)      emacsclient  +  filepath:LINENUM:COL
(current) emacsclient  +LINENUM:COL filepath

-Jorge



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08  8:08   ` Jorge Alberto Garcia
@ 2016-01-08  8:59     ` Yuri Khan
  2016-01-08 14:11       ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Yuri Khan @ 2016-01-08  8:59 UTC (permalink / raw)
  To: Jorge Alberto Garcia; +Cc: Emacs developers

On Fri, Jan 8, 2016 at 2:08 PM, Jorge Alberto Garcia
> We could extend the meaning of  '+' to indicate a linenum:column will
> be present,
> So we could use one of these syntax:
>
> (new)      emacsclient  +  filepath:LINENUM:COL
> (current) emacsclient  +LINENUM:COL filepath

Or, you could solve your specific use case with a wrapper script and
keep emacsclient’s CLI simple and unambiguous and avoid the need to
invent more syntax.

The script could look like this (which is not sophisticated enough to
handle :DIGITS in options and may especially interfere with the
--display option, but will get you a long way):

```
#!/usr/bin/python

import itertools
import re
import sys
import subprocess

RE_LINE_COL = re.compile(r'^(.*?)((?::[0-9]+){,2})$')

sys.exit(subprocess.call(itertools.chain(
    ['emacsclient'],
    *[['+%s' % line_col[1:], filename] if line_col else [filename]
       for arg in sys.argv[1:]
       for filename, line_col in RE_LINE_COL.findall(arg)]))
```



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08  7:42 ` Yuri Khan
  2016-01-08  8:08   ` Jorge Alberto Garcia
@ 2016-01-08  9:03   ` Eli Zaretskii
  2016-01-08 14:13     ` Jorge Alberto Garcia
  1 sibling, 1 reply; 43+ messages in thread
From: Eli Zaretskii @ 2016-01-08  9:03 UTC (permalink / raw)
  To: Yuri Khan; +Cc: jorge.garcia.gonzalez, emacs-devel

> From: Yuri Khan <yuri.v.khan@gmail.com>
> Date: Fri, 8 Jan 2016 13:42:04 +0600
> Cc: Emacs developers <emacs-devel@gnu.org>
> 
> On Fri, Jan 8, 2016 at 4:35 AM, Jorge Alberto Garcia
> <jorge.garcia.gonzalez@gmail.com> wrote:
> 
> > With this you can do this from cmdline:
> > $ emacsclient -q  -c lib-src/emacsclient.c:1593
> 
> What if you want to edit a file whose name is literally “emacsclient.c:1593”?
> 
> What if a Windows user wants to edit an NTFS stream named 1593 in file
> emacsclient.c?

Exactly the questions that went through my head when I read the patch,
thanks.

I think such a feature, if deemed useful, should be activated by a new
command-line option.  Otherwise, I don't see how can emacsclient be
sure the bunch of digits at the end of a file name is a line number.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08  8:59     ` Yuri Khan
@ 2016-01-08 14:11       ` Jorge Alberto Garcia
  0 siblings, 0 replies; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 14:11 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Emacs developers

On Fri, Jan 8, 2016 at 2:59 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> On Fri, Jan 8, 2016 at 2:08 PM, Jorge Alberto Garcia
>> We could extend the meaning of  '+' to indicate a linenum:column will
>> be present,
>> So we could use one of these syntax:
>>
>> (new)      emacsclient  +  filepath:LINENUM:COL
>> (current) emacsclient  +LINENUM:COL filepath
>
> Or, you could solve your specific use case with a wrapper script and
> keep emacsclient’s CLI simple and unambiguous and avoid the need to
> invent more syntax.
>
> The script could look like this (which is not sophisticated enough to
> handle :DIGITS in options and may especially interfere with the
> --display option, but will get you a long way):
>
> ```
> #!/usr/bin/python
>
> import itertools
> import re
> import sys
> import subprocess
>
> RE_LINE_COL = re.compile(r'^(.*?)((?::[0-9]+){,2})$')
>
> sys.exit(subprocess.call(itertools.chain(
>     ['emacsclient'],
>     *[['+%s' % line_col[1:], filename] if line_col else [filename]
>        for arg in sys.argv[1:]
>        for filename, line_col in RE_LINE_COL.findall(arg)]))
> ```

I actually like this approach, I wrote and similar wrapper some time
ago tho this one
is more sophisticate


I guess this was my reason of why I wrote this patch, this way people
don't need to write scripts for something
like that, that as you mention can be more complex due to the digits handling.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08  9:03   ` Eli Zaretskii
@ 2016-01-08 14:13     ` Jorge Alberto Garcia
  2016-01-08 15:39       ` Eli Zaretskii
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 14:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs developers, Yuri Khan

On Fri, Jan 8, 2016 at 3:03 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Yuri Khan <yuri.v.khan@gmail.com>
>> Date: Fri, 8 Jan 2016 13:42:04 +0600
>> Cc: Emacs developers <emacs-devel@gnu.org>
>>
>> On Fri, Jan 8, 2016 at 4:35 AM, Jorge Alberto Garcia
>> <jorge.garcia.gonzalez@gmail.com> wrote:
>>
>> > With this you can do this from cmdline:
>> > $ emacsclient -q  -c lib-src/emacsclient.c:1593
>>
>> What if you want to edit a file whose name is literally “emacsclient.c:1593”?
>>
>> What if a Windows user wants to edit an NTFS stream named 1593 in file
>> emacsclient.c?
>
> Exactly the questions that went through my head when I read the patch,
> thanks.
>
> I think such a feature, if deemed useful, should be activated by a new
> command-line option.  Otherwise, I don't see how can emacsclient be
> sure the bunch of digits at the end of a file name is a line number.

Hey Eli, thanks for your feedback,
would you be against using a new env var to enable it ?



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 14:13     ` Jorge Alberto Garcia
@ 2016-01-08 15:39       ` Eli Zaretskii
  2016-01-08 15:54         ` Kaushal Modi
  2016-01-08 16:10         ` Jorge Alberto Garcia
  0 siblings, 2 replies; 43+ messages in thread
From: Eli Zaretskii @ 2016-01-08 15:39 UTC (permalink / raw)
  To: Jorge Alberto Garcia; +Cc: emacs-devel, yuri.v.khan

> From: Jorge Alberto Garcia <jorge.garcia.gonzalez@gmail.com>
> Date: Fri, 8 Jan 2016 08:13:58 -0600
> Cc: Yuri Khan <yuri.v.khan@gmail.com>, Emacs developers <emacs-devel@gnu.org>
> 
> > I think such a feature, if deemed useful, should be activated by a new
> > command-line option.  Otherwise, I don't see how can emacsclient be
> > sure the bunch of digits at the end of a file name is a line number.
> 
> Hey Eli, thanks for your feedback,
> would you be against using a new env var to enable it ?

Yes.  I think changing behavior depending on environment variables is
only appropriate for debugging options, not for mainstream.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 15:39       ` Eli Zaretskii
@ 2016-01-08 15:54         ` Kaushal Modi
  2016-01-08 16:13           ` Jorge Alberto Garcia
  2016-01-08 16:10         ` Jorge Alberto Garcia
  1 sibling, 1 reply; 43+ messages in thread
From: Kaushal Modi @ 2016-01-08 15:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jorge Alberto Garcia, Yuri Khan, Emacs developers

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

As Yuri said, I just have a wrapper to provide the line number to
emacsclient appropriately.

Here's my csh alias:

=====

# (P)ercol $SEARCHLOG created by (AG)/ack and open emacs at matched (L)ine
# below alias helps quickly open one of the files from the list of files
# that matched the last 'ag'. Awesomeness is that the file opens in emacs
# at the matched line!
alias pagl  'cat ${SEARCHLOG} | percol --query=\!* | \\
      (e2 `awk -F: '"'"'{ if ( $2 ) {print "+" $2 " " $1} else {print}
}'"'"'` &)'

=====

(1)

$SEARCHLOG is a temporary file containing the output of ag[1]

Here's a sample $SEARCHLOG file:

setup-misc.el:226:  ("C-t"   toggle-theme)
setup-htmlize.el:23:      ;; theme, the squiggly underlines can either show
up in the html file
setup-fci.el:66:Running this function after changing themes updates the fci
rule color in
setup-linum.el:41:background color to that of the theme."
setup-visual.el:13:;;  Themes
setup-visual.el:46:(defvar dark-theme t
setup-visual.el:47:  "Variable to store the nature of theme whether it is
light or dark.
setup-visual.el:48:This variable is to be updated when changing themes.")

(2)

percol[2] is a command line utility to allow ido-vertical-like selection
from terminal

(3)

e2 is my alias for "emacsclient -a '' \!* >& /dev/null"

(4)

That awk snippet is what rearranges the FILE:LINENUM in $SEARCHLOG to
+LINENUM FILE when providing the arguments to e2.

[1]: https://github.com/ggreer/the_silver_searcher
[2]: https://github.com/mooz/percol

[-- Attachment #2: Type: text/html, Size: 2635 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 15:39       ` Eli Zaretskii
  2016-01-08 15:54         ` Kaushal Modi
@ 2016-01-08 16:10         ` Jorge Alberto Garcia
  1 sibling, 0 replies; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 16:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs developers, Yuri Khan

On Fri, Jan 8, 2016 at 9:39 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Jorge Alberto Garcia <jorge.garcia.gonzalez@gmail.com>
>> Date: Fri, 8 Jan 2016 08:13:58 -0600
>> Cc: Yuri Khan <yuri.v.khan@gmail.com>, Emacs developers <emacs-devel@gnu.org>
>>
>> > I think such a feature, if deemed useful, should be activated by a new
>> > command-line option.  Otherwise, I don't see how can emacsclient be
>> > sure the bunch of digits at the end of a file name is a line number.
>>
>> Hey Eli, thanks for your feedback,
>> would you be against using a new env var to enable it ?
>
> Yes.  I think changing behavior depending on environment variables is
> only appropriate for debugging options, not for mainstream.

Got it, so what about keep using '+' to indicate a line position
if a number is not followed then look for it in the filepath.

This way it uses the same flag, keeps compatibility and enables this feature
only when required.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 15:54         ` Kaushal Modi
@ 2016-01-08 16:13           ` Jorge Alberto Garcia
  2016-01-08 16:38             ` Kaushal Modi
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 16:13 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers

On Fri, Jan 8, 2016 at 9:54 AM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
> As Yuri said, I just have a wrapper to provide the line number to
> emacsclient appropriately.
>
> Here's my csh alias:
>
> =====
>
> # (P)ercol $SEARCHLOG created by (AG)/ack and open emacs at matched (L)ine
> # below alias helps quickly open one of the files from the list of files
> # that matched the last 'ag'. Awesomeness is that the file opens in emacs
> # at the matched line!
> alias pagl  'cat ${SEARCHLOG} | percol --query=\!* | \\
>       (e2 `awk -F: '"'"'{ if ( $2 ) {print "+" $2 " " $1} else {print}
> }'"'"'` &)'
>
> =====
>

Hi!, I think you got it right and I would like to provide this
awesomeness to all users
like us who will be happy to use it on emacsclient directly.


> (1)
>
> $SEARCHLOG is a temporary file containing the output of ag[1]
>
> Here's a sample $SEARCHLOG file:
>
> setup-misc.el:226:  ("C-t"   toggle-theme)
> setup-htmlize.el:23:      ;; theme, the squiggly underlines can either show
> up in the html file
> setup-fci.el:66:Running this function after changing themes updates the fci
> rule color in
> setup-linum.el:41:background color to that of the theme."
> setup-visual.el:13:;;  Themes
> setup-visual.el:46:(defvar dark-theme t
> setup-visual.el:47:  "Variable to store the nature of theme whether it is
> light or dark.
> setup-visual.el:48:This variable is to be updated when changing themes.")
>
> (2)
>
> percol[2] is a command line utility to allow ido-vertical-like selection
> from terminal
>
> (3)
>
> e2 is my alias for "emacsclient -a '' \!* >& /dev/null"
>
> (4)
>
> That awk snippet is what rearranges the FILE:LINENUM in $SEARCHLOG to
> +LINENUM FILE when providing the arguments to e2.
>
> [1]: https://github.com/ggreer/the_silver_searcher
> [2]: https://github.com/mooz/percol
>
>



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 16:13           ` Jorge Alberto Garcia
@ 2016-01-08 16:38             ` Kaushal Modi
  2016-01-08 16:44               ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Kaushal Modi @ 2016-01-08 16:38 UTC (permalink / raw)
  To: Jorge Alberto Garcia; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers

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

I personally haven't come across a file whose name end in ":NUM". So I do
not have anything against the initial patch. But as other suggested, it's
probably not a good idea.

> (new)      emacsclient  +  filepath:LINENUM:COL

But this idea is not bad IF "emacsclient + filepath" works the same as
"emacsclient filepath".
Then I can simply set my e2 alias to do "emacsclient -a '' + \!*" and then
stuff like below will work rightaway:

- e2 FILE &
- e2 FILE:LINENUM &
- e2 FILE:LINENUM:COLNUM &

[-- Attachment #2: Type: text/html, Size: 1169 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 16:38             ` Kaushal Modi
@ 2016-01-08 16:44               ` Jorge Alberto Garcia
  2016-01-08 16:54                 ` Kaushal Modi
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 16:44 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers

On Fri, Jan 8, 2016 at 10:38 AM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
> I personally haven't come across a file whose name end in ":NUM". So I do
> not have anything against the initial patch. But as other suggested, it's
> probably not a good idea.
>
>> (new)      emacsclient  +  filepath:LINENUM:COL
>
> But this idea is not bad IF "emacsclient + filepath" works the same as
> "emacsclient filepath".
> Then I can simply set my e2 alias to do "emacsclient -a '' + \!*" and then
> stuff like below will work rightaway:
>
> - e2 FILE &
> - e2 FILE:LINENUM &
> - e2 FILE:LINENUM:COLNUM &
>
got it, i like it !

Eli,  do you think this would be acceptable ?

>



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 16:44               ` Jorge Alberto Garcia
@ 2016-01-08 16:54                 ` Kaushal Modi
  2016-01-08 17:52                   ` Jorge Alberto Garcia
                                     ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Kaushal Modi @ 2016-01-08 16:54 UTC (permalink / raw)
  To: Jorge Alberto Garcia; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers

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

> Eli,  do you think this would be acceptable ?

Actually, after I replied, it made me think..

Instead of a mysterious lonely "+" argument, would it make more sense to a
descriptive argument like "--files-with-linenum-colnum"?

Eli and the emacs-dev list, feel free to suggest if this is a good idea or
if a different argument name is more appropriate.

Of course, emacsclient -help should show this new argument.

[-- Attachment #2: Type: text/html, Size: 1164 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 16:54                 ` Kaushal Modi
@ 2016-01-08 17:52                   ` Jorge Alberto Garcia
  2016-01-08 19:06                     ` Eli Zaretskii
  2016-01-08 19:05                   ` Eli Zaretskii
  2016-01-08 19:19                   ` David Caldwell
  2 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 17:52 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers

On Fri, Jan 8, 2016 at 10:54 AM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
>> Eli,  do you think this would be acceptable ?
>
> Actually, after I replied, it made me think..
>
> Instead of a mysterious lonely "+" argument, would it make more sense to a
> descriptive argument like "--files-with-linenum-colnum"?
>
maybe a shorter one based on this ?
ie :  emacsclient --file-linenum

> Eli and the emacs-dev list, feel free to suggest if this is a good idea or
> if a different argument name is more appropriate.
>
> Of course, emacsclient -help should show this new argument.
>



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 16:54                 ` Kaushal Modi
  2016-01-08 17:52                   ` Jorge Alberto Garcia
@ 2016-01-08 19:05                   ` Eli Zaretskii
  2016-01-12 21:04                     ` John Wiegley
  2016-01-08 19:19                   ` David Caldwell
  2 siblings, 1 reply; 43+ messages in thread
From: Eli Zaretskii @ 2016-01-08 19:05 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: jorge.garcia.gonzalez, yuri.v.khan, emacs-devel

> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Fri, 8 Jan 2016 11:54:22 -0500
> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs developers <emacs-devel@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>
> 
> > Eli, do you think this would be acceptable ?
> 
> Actually, after I replied, it made me think..
> 
> Instead of a mysterious lonely "+" argument, would it make more sense to a
> descriptive argument like "--files-with-linenum-colnum"?

Indeed, I think a separate new option is better.  There's no need for
us to invent any clever syntax that is half backward-compatible.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 17:52                   ` Jorge Alberto Garcia
@ 2016-01-08 19:06                     ` Eli Zaretskii
  0 siblings, 0 replies; 43+ messages in thread
From: Eli Zaretskii @ 2016-01-08 19:06 UTC (permalink / raw)
  To: Jorge Alberto Garcia; +Cc: yuri.v.khan, emacs-devel, kaushal.modi

> From: Jorge Alberto Garcia <jorge.garcia.gonzalez@gmail.com>
> Date: Fri, 8 Jan 2016 11:52:02 -0600
> Cc: Eli Zaretskii <eliz@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>,
> 	Emacs developers <emacs-devel@gnu.org>
> 
> > Instead of a mysterious lonely "+" argument, would it make more sense to a
> > descriptive argument like "--files-with-linenum-colnum"?
> >
> maybe a shorter one based on this ?
> ie :  emacsclient --file-linenum

We could have a long option and a corresponding short (one-letter)
one.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 16:54                 ` Kaushal Modi
  2016-01-08 17:52                   ` Jorge Alberto Garcia
  2016-01-08 19:05                   ` Eli Zaretskii
@ 2016-01-08 19:19                   ` David Caldwell
  2016-01-08 19:43                     ` Eli Zaretskii
  2 siblings, 1 reply; 43+ messages in thread
From: David Caldwell @ 2016-01-08 19:19 UTC (permalink / raw)
  To: Kaushal Modi, Jorge Alberto Garcia
  Cc: Eli Zaretskii, Emacs developers, Yuri Khan

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

On 1/8/16 8:54 AM, Kaushal Modi wrote:
>> Eli,  do you think this would be acceptable ?
> 
> Actually, after I replied, it made me think..
> 
> Instead of a mysterious lonely "+" argument, would it make more sense to
> a descriptive argument like "--files-with-linenum-colnum"?
> 
> Eli and the emacs-dev list, feel free to suggest if this is a good idea
> or if a different argument name is more appropriate.

Why not instead of adding the new option, rearrange the logic so that it
only tries to parse the ":linenum" part if the file doesn't exist?

ie:
emacsclient somefile:1234

tries to open "somefile:1234", then if it fails, looks for the :1234 and
tries to open "somefile" and jump to line 1234. That shouldn't surprise
anyone with weirdly named files and you don't need to learn any new
command line options.

-David




[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 19:19                   ` David Caldwell
@ 2016-01-08 19:43                     ` Eli Zaretskii
  2016-01-08 19:52                       ` David Caldwell
  0 siblings, 1 reply; 43+ messages in thread
From: Eli Zaretskii @ 2016-01-08 19:43 UTC (permalink / raw)
  To: David Caldwell
  Cc: jorge.garcia.gonzalez, yuri.v.khan, emacs-devel, kaushal.modi

> Cc: Eli Zaretskii <eliz@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>,
>         Emacs developers <emacs-devel@gnu.org>
> From: David Caldwell <david@porkrind.org>
> Date: Fri, 8 Jan 2016 11:19:26 -0800
> 
> Why not instead of adding the new option, rearrange the logic so that it
> only tries to parse the ":linenum" part if the file doesn't exist?

Because both 'filename' and 'filename:1234' could exist.

Really, I don't understand why should we come with fancy syntax when a
new option will unequivocally tell which case is it.

Learning a new option is not harder than learning a new syntax that
wasn't supported before.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 19:43                     ` Eli Zaretskii
@ 2016-01-08 19:52                       ` David Caldwell
  2016-01-08 20:33                         ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: David Caldwell @ 2016-01-08 19:52 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: jorge.garcia.gonzalez, yuri.v.khan, emacs-devel, kaushal.modi

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

On 1/8/16 11:43 AM, Eli Zaretskii wrote:
>> Cc: Eli Zaretskii <eliz@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>,
>>         Emacs developers <emacs-devel@gnu.org>
>> From: David Caldwell <david@porkrind.org>
>> Date: Fri, 8 Jan 2016 11:19:26 -0800
>>
>> Why not instead of adding the new option, rearrange the logic so that it
>> only tries to parse the ":linenum" part if the file doesn't exist?
> 
> Because both 'filename' and 'filename:1234' could exist.

Ah. Very good point.

> Really, I don't understand why should we come with fancy syntax when a
> new option will unequivocally tell which case is it.

It just seemed nicer to have it be automatic if it was possible. An
option is fine.

-David



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 19:52                       ` David Caldwell
@ 2016-01-08 20:33                         ` Jorge Alberto Garcia
  2016-01-09 22:51                           ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-08 20:33 UTC (permalink / raw)
  To: David Caldwell; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers, Kaushal Modi

On Fri, Jan 8, 2016 at 1:52 PM, David Caldwell <david@porkrind.org> wrote:
> On 1/8/16 11:43 AM, Eli Zaretskii wrote:
>>> Cc: Eli Zaretskii <eliz@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>,
>>>         Emacs developers <emacs-devel@gnu.org>
>>> From: David Caldwell <david@porkrind.org>
>>> Date: Fri, 8 Jan 2016 11:19:26 -0800
>>>
>>> Why not instead of adding the new option, rearrange the logic so that it
>>> only tries to parse the ":linenum" part if the file doesn't exist?
>>
>> Because both 'filename' and 'filename:1234' could exist.
>
> Ah. Very good point.
>
>> Really, I don't understand why should we come with fancy syntax when a
>> new option will unequivocally tell which case is it.
>
> It just seemed nicer to have it be automatic if it was possible. An
> option is fine.
David, that was actually a clever workaround.

Following Eli's observation

I will add a new flag using Yuri's suggested name
Flag name is open for feedback !

>
> -David
>
>



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 20:33                         ` Jorge Alberto Garcia
@ 2016-01-09 22:51                           ` Jorge Alberto Garcia
  2016-01-10  8:22                             ` Yuri Khan
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-09 22:51 UTC (permalink / raw)
  To: David Caldwell; +Cc: Eli Zaretskii, Yuri Khan, Emacs developers, Kaushal Modi

On Fri, Jan 8, 2016 at 2:33 PM, Jorge Alberto Garcia
<jorge.garcia.gonzalez@gmail.com> wrote:
> On Fri, Jan 8, 2016 at 1:52 PM, David Caldwell <david@porkrind.org> wrote:
>> On 1/8/16 11:43 AM, Eli Zaretskii wrote:
>>>> Cc: Eli Zaretskii <eliz@gnu.org>, Yuri Khan <yuri.v.khan@gmail.com>,
>>>>         Emacs developers <emacs-devel@gnu.org>
>>>> From: David Caldwell <david@porkrind.org>
>>>> Date: Fri, 8 Jan 2016 11:19:26 -0800
>>>>
>>>> Why not instead of adding the new option, rearrange the logic so that it
>>>> only tries to parse the ":linenum" part if the file doesn't exist?
>>>
>>> Because both 'filename' and 'filename:1234' could exist.
>>
>> Ah. Very good point.
>>
>>> Really, I don't understand why should we come with fancy syntax when a
>>> new option will unequivocally tell which case is it.
>>
>> It just seemed nicer to have it be automatic if it was possible. An
>> option is fine.
> David, that was actually a clever workaround.
>
> Following Eli's observation
>
> I will add a new flag using Yuri's suggested name
> Flag name is open for feedback !
>
>>
>> -David

Hi folks,

I added a new flag as indicated by Eli Zaretskii using Yuri Khan's
suggested flag name:

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index c3e5635..3bff612 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -151,6 +151,9 @@ int emacs_pid = 0;
    be used for the new frame.  */
 const char *frame_parameters = NULL;

+/* Nonzero means filename:line:column syntax support is enable  */
+int filename_with_line_col = 0;
+
 static _Noreturn void print_help_and_exit (void);


@@ -172,6 +175,7 @@ struct option longopts[] =
   { "server-file", required_argument, NULL, 'f' },
   { "display", required_argument, NULL, 'd' },
   { "parent-id", required_argument, NULL, 'p' },
+  { "files-with-line-col", no_argument, NULL, 'l' },
   { 0, 0, 0, 0 }
 };

@@ -461,9 +465,9 @@ decode_options (int argc, char **argv)
     {
       int opt = getopt_long_only (argc, argv,
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
-     "VHneqa:s:f:d:F:tc",
+     "lVHneqa:s:f:d:F:tc",
 #else
-     "VHneqa:f:d:F:tc",
+  "lVHneqa:f:d:F:tc",
 #endif
      longopts, 0);

@@ -537,6 +541,9 @@ decode_options (int argc, char **argv)
         case 'F':
           frame_parameters = optarg;
           break;
+ case 'l':
+  filename_with_line_col = 1;
+  break;

  default:
   message (true, "Try '%s --help' for more information\n", progname);
@@ -637,8 +644,9 @@ The following OPTIONS are accepted:\n\
  Editor to fallback to if the server is not running\n"
 " If EDITOR is the empty string, start Emacs in daemon\n\
  mode and try connecting again\n"
-"\n\
-Report bugs with M-x report-emacs-bug.\n");
+"-l --files-with-line-col\n\
+ Support embedded location syntax FILENAME[:LINE[:COLUMN]]\n"
+"Report bugs with M-x report-emacs-bug.\n");
   exit (EXIT_SUCCESS);
 }

@@ -1593,7 +1601,7 @@ main (int argc, char **argv)
   char string[BUFSIZ+1];
   int start_daemon_if_needed;
   int exit_status = EXIT_SUCCESS;
-
+  char *lineDst;
   main_argv = argv;
   progname = argv[0];

@@ -1747,6 +1755,23 @@ main (int argc, char **argv)
                   continue;
                 }
             }
+
+  if(filename_with_line_col != 0)
+    {
+      lineDst = index(argv[i],':');
+      if ( lineDst != NULL)
+ {
+  char *p = lineDst + 1;
+  while (isdigit ((unsigned char) *p) || *p == ':') p++;
+  if (*p == 0)
+    {
+      send_to_emacs (emacs_socket, "-position ");
+      *lineDst='+';
+      quote_argument (emacs_socket, lineDst);
+      send_to_emacs (emacs_socket, " ");
+    }
+ }
+    }
 #ifdef WINDOWSNT
   else if (! file_name_absolute_p (argv[i])
    && (isalpha (argv[i][0]) && argv[i][1] == ':'))
@@ -1768,7 +1793,10 @@ main (int argc, char **argv)
     }
 #endif

-          send_to_emacs (emacs_socket, "-file ");
+  send_to_emacs (emacs_socket, "-file ");
+  if(lineDst != NULL){
+    *lineDst = 0;
+  }
           quote_argument (emacs_socket, argv[i]);
           send_to_emacs (emacs_socket, " ");
         }



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-09 22:51                           ` Jorge Alberto Garcia
@ 2016-01-10  8:22                             ` Yuri Khan
  2016-01-10  8:37                               ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Yuri Khan @ 2016-01-10  8:22 UTC (permalink / raw)
  To: Jorge Alberto Garcia
  Cc: Eli Zaretskii, Kaushal Modi, Emacs developers, David Caldwell

On Sun, Jan 10, 2016 at 4:51 AM, Jorge Alberto Garcia
<jorge.garcia.gonzalez@gmail.com> wrote:

> I added a new flag as indicated by Eli Zaretskii using Yuri Khan's
> suggested flag name:

Give credit where it’s due: it was Kaushal Modi who suggested the flag name.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-10  8:22                             ` Yuri Khan
@ 2016-01-10  8:37                               ` Jorge Alberto Garcia
  2016-01-12 16:24                                 ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-10  8:37 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Eli Zaretskii, Kaushal Modi, Emacs developers, David Caldwell

On Sun, Jan 10, 2016 at 2:22 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> On Sun, Jan 10, 2016 at 4:51 AM, Jorge Alberto Garcia
> <jorge.garcia.gonzalez@gmail.com> wrote:
>
>> I added a new flag as indicated by Eli Zaretskii using Yuri Khan's
>> suggested flag name:
>
> Give credit where it’s due: it was Kaushal Modi who suggested the flag name
my bad, thanks for the clarification.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-10  8:37                               ` Jorge Alberto Garcia
@ 2016-01-12 16:24                                 ` Jorge Alberto Garcia
  0 siblings, 0 replies; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-12 16:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Yuri Khan, Kaushal Modi, Emacs developers, David Caldwell

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

On Sun, Jan 10, 2016 at 2:37 AM, Jorge Alberto Garcia
<jorge.garcia.gonzalez@gmail.com> wrote:
> On Sun, Jan 10, 2016 at 2:22 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
>> On Sun, Jan 10, 2016 at 4:51 AM, Jorge Alberto Garcia
>> <jorge.garcia.gonzalez@gmail.com> wrote:
>>
>>> I added a new flag as indicated by Eli Zaretskii using Yuri Khan's
>>> suggested flag name:
>>
>> Give credit where it’s due: it was Kaushal Modi who suggested the flag name
> my bad, thanks for the clarification.

Patch is attached, I don't have write access to the git repo so I need
help from
someone else to do it.

Let me know if I need to do something else !

[-- Attachment #2: Add-embedded-location-syntax-flag.patch --]
[-- Type: application/octet-stream, Size: 3249 bytes --]

From f029ce09f44a77b8ef9ec3ce20a18a4855ccc684 Mon Sep 17 00:00:00 2001
From: Jorge Garcia <jorge.garcia.gonzalez@gmail.com>
Date: Sat, 9 Jan 2016 16:35:01 -0600
Subject: [PATCH] Add embedded location syntax flag

---
 lib-src/emacsclient.c |   40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index c3e5635..3bff612 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -151,6 +151,9 @@ int emacs_pid = 0;
    be used for the new frame.  */
 const char *frame_parameters = NULL;
 
+/* Nonzero means filename:line:column syntax support is enable  */
+int filename_with_line_col = 0;
+
 static _Noreturn void print_help_and_exit (void);
 
 
@@ -172,6 +175,7 @@ struct option longopts[] =
   { "server-file",	required_argument, NULL, 'f' },
   { "display",	required_argument, NULL, 'd' },
   { "parent-id", required_argument, NULL, 'p' },
+  { "files-with-line-col", no_argument, NULL, 'l' },
   { 0, 0, 0, 0 }
 };
 
@@ -461,9 +465,9 @@ decode_options (int argc, char **argv)
     {
       int opt = getopt_long_only (argc, argv,
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
-			     "VHneqa:s:f:d:F:tc",
+			     "lVHneqa:s:f:d:F:tc",
 #else
-			     "VHneqa:f:d:F:tc",
+				  "lVHneqa:f:d:F:tc",
 #endif
 			     longopts, 0);
 
@@ -537,6 +541,9 @@ decode_options (int argc, char **argv)
         case 'F':
           frame_parameters = optarg;
           break;
+	case 'l':
+	  filename_with_line_col = 1;
+	  break;
 
 	default:
 	  message (true, "Try '%s --help' for more information\n", progname);
@@ -637,8 +644,9 @@ The following OPTIONS are accepted:\n\
 			Editor to fallback to if the server is not running\n"
 "			If EDITOR is the empty string, start Emacs in daemon\n\
 			mode and try connecting again\n"
-"\n\
-Report bugs with M-x report-emacs-bug.\n");
+"-l --files-with-line-col\n\
+			Support embedded location syntax FILENAME[:LINE[:COLUMN]]\n"
+"Report bugs with M-x report-emacs-bug.\n");
   exit (EXIT_SUCCESS);
 }
 
@@ -1593,7 +1601,7 @@ main (int argc, char **argv)
   char string[BUFSIZ+1];
   int start_daemon_if_needed;
   int exit_status = EXIT_SUCCESS;
-
+  char *lineDst;
   main_argv = argv;
   progname = argv[0];
 
@@ -1747,6 +1755,23 @@ main (int argc, char **argv)
                   continue;
                 }
             }
+
+	  if(filename_with_line_col != 0)
+	    {
+	      lineDst = index(argv[i],':');
+	      if ( lineDst != NULL)
+		{
+		  char *p = lineDst + 1;
+		  while (isdigit ((unsigned char) *p) || *p == ':') p++;
+		  if (*p == 0)
+		    {
+		      send_to_emacs (emacs_socket, "-position ");
+		      *lineDst='+';
+		      quote_argument (emacs_socket, lineDst);
+		      send_to_emacs (emacs_socket, " ");
+		    }
+		}
+	    }
 #ifdef WINDOWSNT
 	  else if (! file_name_absolute_p (argv[i])
 		   && (isalpha (argv[i][0]) && argv[i][1] == ':'))
@@ -1768,7 +1793,10 @@ main (int argc, char **argv)
 	    }
 #endif
 
-          send_to_emacs (emacs_socket, "-file ");
+	  send_to_emacs (emacs_socket, "-file ");
+	  if(lineDst != NULL){
+	    *lineDst = 0;
+	  }
           quote_argument (emacs_socket, argv[i]);
           send_to_emacs (emacs_socket, " ");
         }
-- 
1.7.9.5


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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-08 19:05                   ` Eli Zaretskii
@ 2016-01-12 21:04                     ` John Wiegley
  2016-01-12 21:26                       ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: John Wiegley @ 2016-01-12 21:04 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: jorge.garcia.gonzalez, yuri.v.khan, emacs-devel, Kaushal Modi

>>>>> Eli Zaretskii <eliz@gnu.org> writes:

> Indeed, I think a separate new option is better. There's no need for us to
> invent any clever syntax that is half backward-compatible.

+1 on everything Eli has said about environment variables being suitable only
for debug options, and using a flag rather than fancy new semantics for names
with colons, and for also having a short option to enable this behavior.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-12 21:04                     ` John Wiegley
@ 2016-01-12 21:26                       ` Jorge Alberto Garcia
  2016-01-13  0:10                         ` John Wiegley
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-12 21:26 UTC (permalink / raw)
  To: John Wiegley, Eli Zaretskii, Kaushal Modi,
	jorge alberto garcia gonzalez, Yuri Khan, Emacs developers

On Tue, Jan 12, 2016 at 3:04 PM, John Wiegley <jwiegley@gmail.com> wrote:
>>>>>> Eli Zaretskii <eliz@gnu.org> writes:
>
>> Indeed, I think a separate new option is better. There's no need for us to
>> invent any clever syntax that is half backward-compatible.
>
> +1 on everything Eli has said about environment variables being suitable only
> for debug options, and using a flag rather than fancy new semantics for names
> with colons, and for also having a short option to enable this behavior.
>
Sure, actually the patch I sent, already follows Eli's suggestion to
add a new flag :)

+  { "files-with-line-col", no_argument, NULL, 'l' },

so we can use either:
emacsclient -l  somefile:[LINE]:[COLUMN]
emacsclient --files-with-line-col  somefile:[LINE]:[COLUMN]

if no line or column is provided it just open 'somefile' following
Kaushal Modi suggestion.

> --
> John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
> http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-12 21:26                       ` Jorge Alberto Garcia
@ 2016-01-13  0:10                         ` John Wiegley
  2016-01-13  0:46                           ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: John Wiegley @ 2016-01-13  0:10 UTC (permalink / raw)
  To: Jorge Alberto Garcia
  Cc: Eli Zaretskii, Yuri Khan, Emacs developers, Kaushal Modi

>>>>> Jorge Alberto Garcia <jorge.garcia.gonzalez@gmail.com> writes:

> Sure, actually the patch I sent, already follows Eli's suggestion to add a
> new flag :)
> if no line or column is provided it just open 'somefile' following Kaushal
> Modi suggestion.

Sounds great, thank you!

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-13  0:10                         ` John Wiegley
@ 2016-01-13  0:46                           ` Jorge Alberto Garcia
  2016-03-29 16:22                             ` Kaushal Modi
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-01-13  0:46 UTC (permalink / raw)
  To: John Wiegley, Jorge Alberto Garcia, Eli Zaretskii, Kaushal Modi,
	Yuri Khan, Emacs developers

On Tue, Jan 12, 2016 at 6:10 PM, John Wiegley <jwiegley@gmail.com> wrote:
>>>>>> Jorge Alberto Garcia <jorge.garcia.gonzalez@gmail.com> writes:
>
>> Sure, actually the patch I sent, already follows Eli's suggestion to add a
>> new flag :)
>> if no line or column is provided it just open 'somefile' following Kaushal
>> Modi suggestion.
>
> Sounds great, thank you!
>
Hey folks, this was fun, thanks for your  feedback :)

> --
> John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
> http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-01-13  0:46                           ` Jorge Alberto Garcia
@ 2016-03-29 16:22                             ` Kaushal Modi
  2016-03-29 17:30                               ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Kaushal Modi @ 2016-03-29 16:22 UTC (permalink / raw)
  To: Jorge Alberto Garcia
  Cc: Eli Zaretskii, John Wiegley, Emacs developers, Yuri Khan

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

Hi Jorge,

What happened to this effort? I don't see it merged yet into the master.

[-- Attachment #2: Type: text/html, Size: 204 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-29 16:22                             ` Kaushal Modi
@ 2016-03-29 17:30                               ` Jorge Alberto Garcia
  2016-03-29 21:27                                 ` Paul Eggert
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-03-29 17:30 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Eli Zaretskii, John Wiegley, Emacs developers, Yuri Khan

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

On Tue, Mar 29, 2016 at 10:22 AM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
>
> Hi Jorge,
>
Hi !
> What happened to this effort? I don't see it merged yet into the master.
Sure, sometime ago I sent it for review, there was some changes John asked.
I think is done, patch is attached.

Thank you for asking !

[-- Attachment #2: add-emacsclient-open-with-file-linum-syntax.patch --]
[-- Type: application/octet-stream, Size: 4273 bytes --]

From 4cfa1be8165283c65f4b8bcc3d4bf6cc284b580e Mon Sep 17 00:00:00 2001
From: Jorge Garcia <jorge.garcia.gonzalez@gmail.com>
Date: Tue, 29 Mar 2016 11:21:03 -0600
Subject: [PATCH] Add emacsclient support to open with file:linum syntax

---
 doc/man/emacsclient.1 |   17 +++++++++++++++++
 lib-src/emacsclient.c |   40 ++++++++++++++++++++++++++++++++++------
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/doc/man/emacsclient.1 b/doc/man/emacsclient.1
index e62fe93..4e5e82b 100644
--- a/doc/man/emacsclient.1
+++ b/doc/man/emacsclient.1
@@ -52,6 +52,23 @@ If you set the variable "server-window" to a window or a frame, "C-x
 The programs follow the usual GNU command line syntax, with long
 options starting with two dashes ("\-").
 .TP
+.BI + number
+Go to the line specified by
+.I number
+(do not insert a space between the "+" sign and
+the number).
+This applies only to the next file specified.
+.TP
+.BI + line:column
+Go to the specified
+.I line
+and
+.IR column .
+.TP
+.B \-j, \-\-files-with-line-col FILENAME[:LINE[:COLUMN]] ...
+Go to line specified by LINE and column if specified.
+You can specify a list of files separated by space.
+.TP
 .B \-a, \-\-alternate-editor=EDITOR
 if the Emacs server is not running, run the specified editor instead.
 This can also be specified via the ALTERNATE_EDITOR environment variable.
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index c3e5635..21c3b54 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -151,6 +151,9 @@ int emacs_pid = 0;
    be used for the new frame.  */
 const char *frame_parameters = NULL;
 
+/* Nonzero means filename:line:column syntax support is enable  */
+int filename_with_line_col = 0;
+
 static _Noreturn void print_help_and_exit (void);
 
 
@@ -172,6 +175,7 @@ struct option longopts[] =
   { "server-file",	required_argument, NULL, 'f' },
   { "display",	required_argument, NULL, 'd' },
   { "parent-id", required_argument, NULL, 'p' },
+  { "files-with-line-col", no_argument, NULL, 'j' },
   { 0, 0, 0, 0 }
 };
 
@@ -461,9 +465,9 @@ decode_options (int argc, char **argv)
     {
       int opt = getopt_long_only (argc, argv,
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
-			     "VHneqa:s:f:d:F:tc",
+			     "jVHneqa:s:f:d:F:tc",
 #else
-			     "VHneqa:f:d:F:tc",
+				  "jVHneqa:f:d:F:tc",
 #endif
 			     longopts, 0);
 
@@ -537,6 +541,9 @@ decode_options (int argc, char **argv)
         case 'F':
           frame_parameters = optarg;
           break;
+	case 'l':
+	  filename_with_line_col = 1;
+	  break;
 
 	default:
 	  message (true, "Try '%s --help' for more information\n", progname);
@@ -637,8 +644,9 @@ The following OPTIONS are accepted:\n\
 			Editor to fallback to if the server is not running\n"
 "			If EDITOR is the empty string, start Emacs in daemon\n\
 			mode and try connecting again\n"
-"\n\
-Report bugs with M-x report-emacs-bug.\n");
+"-j, --files-with-line-col\n\
+			Visit file at line,column using syntax FILENAME[:LINE[:COLUMN]]\n"
+"Report bugs with M-x report-emacs-bug.\n");
   exit (EXIT_SUCCESS);
 }
 
@@ -1593,7 +1601,7 @@ main (int argc, char **argv)
   char string[BUFSIZ+1];
   int start_daemon_if_needed;
   int exit_status = EXIT_SUCCESS;
-
+  char *lineDst;
   main_argv = argv;
   progname = argv[0];
 
@@ -1747,6 +1755,23 @@ main (int argc, char **argv)
                   continue;
                 }
             }
+
+	  if(filename_with_line_col != 0)
+	    {
+	      lineDst = index(argv[i],':');
+	      if ( lineDst != NULL)
+		{
+		  char *p = lineDst + 1;
+		  while (isdigit ((unsigned char) *p) || *p == ':') p++;
+		  if (*p == 0)
+		    {
+		      send_to_emacs (emacs_socket, "-position ");
+		      *lineDst='+';
+		      quote_argument (emacs_socket, lineDst);
+		      send_to_emacs (emacs_socket, " ");
+		    }
+		}
+	    }
 #ifdef WINDOWSNT
 	  else if (! file_name_absolute_p (argv[i])
 		   && (isalpha (argv[i][0]) && argv[i][1] == ':'))
@@ -1768,7 +1793,10 @@ main (int argc, char **argv)
 	    }
 #endif
 
-          send_to_emacs (emacs_socket, "-file ");
+	  send_to_emacs (emacs_socket, "-file ");
+	  if(lineDst != NULL){
+	    *lineDst = 0;
+	  }
           quote_argument (emacs_socket, argv[i]);
           send_to_emacs (emacs_socket, " ");
         }
-- 
1.7.9.5


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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-29 17:30                               ` Jorge Alberto Garcia
@ 2016-03-29 21:27                                 ` Paul Eggert
  2016-03-29 22:35                                   ` Kaushal Modi
  0 siblings, 1 reply; 43+ messages in thread
From: Paul Eggert @ 2016-03-29 21:27 UTC (permalink / raw)
  To: Jorge Alberto Garcia, Kaushal Modi
  Cc: Eli Zaretskii, John Wiegley, Yuri Khan, Emacs developers

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

It make sense to document the longstanding option syntax 'emacsclient 
+LINE:COLUMN FILE' in the man page, so I installed the attached into the 
emacs-25 branch. However, I don't see the need to add a new option 
syntax 'emacsclient --files-with-line-col FILE:LINE:COLUMN' to mean the 
same thing. Why not just use the longstanding syntax?

[-- Attachment #2: 0001-doc-man-emacsclient.1-Document-line-column-option.patch --]
[-- Type: application/x-patch, Size: 1195 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-29 21:27                                 ` Paul Eggert
@ 2016-03-29 22:35                                   ` Kaushal Modi
  2016-03-29 23:08                                     ` Paul Eggert
  0 siblings, 1 reply; 43+ messages in thread
From: Kaushal Modi @ 2016-03-29 22:35 UTC (permalink / raw)
  To: Paul Eggert
  Cc: Jorge Alberto Garcia, Eli Zaretskii, John Wiegley, Yuri Khan,
	Emacs developers

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

On Tue, Mar 29, 2016 at 5:27 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:

> However, I don't see the need to add a new option syntax 'emacsclient
> --files-with-line-col FILE:LINE:COLUMN' to mean the same thing. Why not
> just use the longstanding syntax?


Hi Paul,

As discussed earlier in the thread, this patch enables compatibility with
tools like ag/grep/etc which use the FILE:LINE format for referencing
positions. I myself, use an awk script to rearrange the arguments to work
with the current +LINE FILE format accepted by emacsclient ( Ref:
https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00541.html ).

Having this patch installed will prevent the need for such workarounds and
we will have a harmony of using FILE:LINE format of position referencing
across emacsclient/ag/grep/..


--
Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1486 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-29 22:35                                   ` Kaushal Modi
@ 2016-03-29 23:08                                     ` Paul Eggert
  2016-03-29 23:29                                       ` Jorge Alberto Garcia
  0 siblings, 1 reply; 43+ messages in thread
From: Paul Eggert @ 2016-03-29 23:08 UTC (permalink / raw)
  To: Kaushal Modi
  Cc: Jorge Alberto Garcia, Eli Zaretskii, John Wiegley, Yuri Khan,
	Emacs developers

On 03/29/2016 03:35 PM, Kaushal Modi wrote:
>
> I myself, use an awk script to rearrange the arguments to work with 
> the current +LINE FILE format accepted by emacsclient ( Ref: 
> https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00541.html ).

So the existing emacsclient implementation already works for you.

> Having this patch installed will prevent the need for such workarounds

They are not workarounds, because grep output cannot be used unchanged. 
Even with the proposed option syntax, users would need to employ a 
script such as yours to pick out the part of the grep output that they 
need, and use that information to formulate arguments for emacsclient.

The longstanding +LINE option syntax is compatible with other popular 
free editors such as 'vim' and 'nano', and there is some value in 
encouraging its usage rather than reinventing the wheel.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-29 23:08                                     ` Paul Eggert
@ 2016-03-29 23:29                                       ` Jorge Alberto Garcia
  2016-03-30  0:37                                         ` Paul Eggert
  0 siblings, 1 reply; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-03-29 23:29 UTC (permalink / raw)
  To: Paul Eggert
  Cc: Yuri Khan, Eli Zaretskii, John Wiegley, Emacs developers,
	Kaushal Modi

On Tue, Mar 29, 2016 at 5:08 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:
> On 03/29/2016 03:35 PM, Kaushal Modi wrote:
>>
>>
>> I myself, use an awk script to rearrange the arguments to work with the
>> current +LINE FILE format accepted by emacsclient ( Ref:
>> https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00541.html ).
>
>
> So the existing emacsclient implementation already works for you.
>
>> Having this patch installed will prevent the need for such workarounds
>
>
> They are not workarounds, because grep output cannot be used unchanged. Even
> with the proposed option syntax, users would need to employ a script such as
> yours to pick out the part of the grep output that they need, and use that
> information to formulate arguments for emacsclient.

It can, you just assumed you need to use a script,
If you have this patch you can copy/paste the result paths and use it
directly with emacsclient

without having to form +line:column  and select/copy/paste the path again.

>
> The longstanding +LINE option syntax is compatible with other popular free
> editors such as 'vim' and 'nano', and there is some value in encouraging its
> usage rather than reinventing the wheel.

The patch does not remove the current +LINE:COL syntax support
so it adds compatibility with a new way to specify it.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-29 23:29                                       ` Jorge Alberto Garcia
@ 2016-03-30  0:37                                         ` Paul Eggert
  2016-03-30 14:21                                           ` Kaushal Modi
  0 siblings, 1 reply; 43+ messages in thread
From: Paul Eggert @ 2016-03-30  0:37 UTC (permalink / raw)
  To: Jorge Alberto Garcia
  Cc: Yuri Khan, Eli Zaretskii, John Wiegley, Emacs developers,
	Kaushal Modi

On 03/29/2016 04:29 PM, Jorge Alberto Garcia wrote:
> It can, you just assumed you need to use a script,
> If you have this patch you can copy/paste the result paths and use it
> directly with emacsclient
Sure, but I can use copy+paste now and run emacsclient. Yes, it's a pain 
(either two pastes, or type backspace*-space-plus after the paste), but 
it's nearly equally painful to use copy+paste with the proposed change 
(type minus-j-space before the paste). Both methods are so awkward that 
few people would want to use them.

M-x grep is a much better way to use grep with Emacs, and we needn't 
bother with microoptimizations of an inferior user interface.



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-30  0:37                                         ` Paul Eggert
@ 2016-03-30 14:21                                           ` Kaushal Modi
  2016-03-30 16:42                                             ` Jorge Alberto Garcia
  2016-03-31 12:31                                             ` Stefan Monnier
  0 siblings, 2 replies; 43+ messages in thread
From: Kaushal Modi @ 2016-03-30 14:21 UTC (permalink / raw)
  To: Paul Eggert
  Cc: Jorge Alberto Garcia, Eli Zaretskii, John Wiegley, Yuri Khan,
	Emacs developers

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

>
> On 03/29/2016 03:35 PM, Kaushal Modi wrote:
> I myself, use an awk script to rearrange the arguments to work with the
> current +LINE FILE format accepted by emacsclient ( Ref:
> https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00541.html ).
> So the existing emacsclient implementation already works for you.
>
> They are not workarounds, because grep output cannot be used unchanged.
> Even with the proposed option syntax, users would need to employ a script
> such as yours to pick out the part of the grep output that they need, and
> use that information to formulate arguments for emacsclient.
> The longstanding +LINE option syntax is compatible with other popular free
> editors such as 'vim' and 'nano', and there is some value in encouraging
> its usage rather than reinventing the wheel.


> Having this patch installed will prevent the need for such workarounds
>


Jorge,

Based on the counter arguments provided by Paul, I now tend to agree to
what he says.

1. The current method (+LINE FILE and using awk to arrange stuff) has been
working well for me for quite few years.
2. It makes sense to have users stick to one convention (+LINE FILE)
instead of having users now split between "+LINE FILE" and "FILE:LINE".

I do not use copy/paste manually but instead make a shell alias using that
awk snippet do things. So with either "+LINE FILE" or "FILE:LINE", I will
need that awk script.

That said, I appreciate the effort you put in in creating this patch and
this reply, by no means, is intended to discourage you from your future
work (especially in C).

[-- Attachment #2: Type: text/html, Size: 3498 bytes --]

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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-30 14:21                                           ` Kaushal Modi
@ 2016-03-30 16:42                                             ` Jorge Alberto Garcia
  2016-03-31 12:31                                             ` Stefan Monnier
  1 sibling, 0 replies; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-03-30 16:42 UTC (permalink / raw)
  To: Kaushal Modi
  Cc: Eli Zaretskii, Paul Eggert, Yuri Khan, John Wiegley,
	Emacs developers

On Wed, Mar 30, 2016 at 8:21 AM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
>> On 03/29/2016 03:35 PM, Kaushal Modi wrote:
>> I myself, use an awk script to rearrange the arguments to work with the
>> current +LINE FILE format accepted by emacsclient ( Ref:
>> https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00541.html ).
>> So the existing emacsclient implementation already works for you.
>>
>> They are not workarounds, because grep output cannot be used unchanged.
>> Even with the proposed option syntax, users would need to employ a script
>> such as yours to pick out the part of the grep output that they need, and
>> use that information to formulate arguments for emacsclient.
>> The longstanding +LINE option syntax is compatible with other popular free
>> editors such as 'vim' and 'nano', and there is some value in encouraging its
>> usage rather than reinventing the wheel.
>>
>>
>> Having this patch installed will prevent the need for such workarounds
>
>
>
> Jorge,
>
> Based on the counter arguments provided by Paul, I now tend to agree to what
> he says.
>
> 1. The current method (+LINE FILE and using awk to arrange stuff) has been
> working well for me for quite few years.
> 2. It makes sense to have users stick to one convention (+LINE FILE) instead
> of having users now split between "+LINE FILE" and "FILE:LINE".
>
> I do not use copy/paste manually but instead make a shell alias using that
> awk snippet do things. So with either "+LINE FILE" or "FILE:LINE", I will
> need that awk script.
>
> That said, I appreciate the effort you put in in creating this patch and
> this reply, by no means, is intended to discourage you from your future work
> (especially in C).

Thanks Modi,
Folks

I agree with Paul, mx-grep is a better way but is not always possible
to use it, but
use case are different, here you already have a location specified.

Emacs users are very diverse, MX-grep/bash not always is present on
the same system
is a shame but not always is possible/confortable to have a workflow
running within emacs.

I will not push anymore for this patch but please consider this
argument before rejection.
-Jorge



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-30 14:21                                           ` Kaushal Modi
  2016-03-30 16:42                                             ` Jorge Alberto Garcia
@ 2016-03-31 12:31                                             ` Stefan Monnier
  2016-03-31 14:24                                               ` Jorge Alberto Garcia
  1 sibling, 1 reply; 43+ messages in thread
From: Stefan Monnier @ 2016-03-31 12:31 UTC (permalink / raw)
  To: emacs-devel

> That said, I appreciate the effort you put in in creating this patch and
> this reply, by no means, is intended to discourage you from your future
> work (especially in C).

FWIW, I think we should try and arrange it so that the way emacsclient and
server.el work together makes it possible to add such a new FILE:LINE
syntax via an ELPA package (even if it might require an advice).


        Stefan




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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2016-03-31 12:31                                             ` Stefan Monnier
@ 2016-03-31 14:24                                               ` Jorge Alberto Garcia
  0 siblings, 0 replies; 43+ messages in thread
From: Jorge Alberto Garcia @ 2016-03-31 14:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

On Thu, Mar 31, 2016 at 6:31 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> That said, I appreciate the effort you put in in creating this patch and
>> this reply, by no means, is intended to discourage you from your future
>> work (especially in C).
>
> FWIW, I think we should try and arrange it so that the way emacsclient and
> server.el work together makes it possible to add such a new FILE:LINE
> syntax via an ELPA package (even if it might require an advice).
>
>
>         Stefan
>
that's great thanks !
>



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
@ 2017-02-09  9:58 Toon Claes
  2017-02-09 13:22 ` Stefan Monnier
  0 siblings, 1 reply; 43+ messages in thread
From: Toon Claes @ 2017-02-09  9:58 UTC (permalink / raw)
  To: Emacs Devel; +Cc: jorge.garcia.gonzalez, eggert, monnier, kaushal.modi

On Thu, Mar 31, 2016 at 6:31 AM, Stefan Monnier <address@hidden> wrote:
> FWIW, I think we should try and arrange it so that the way emacsclient and
> server.el work together makes it possible to add such a new FILE:LINE
> syntax via an ELPA package (even if it might require an advice).
>
>
> Stefan

I am a bit sad this patch didn’t get applied, but I understand.

But I found this advice on SO: http://stackoverflow.com/a/3141456/89376

#+BEGIN_SRC emacs-lisp
;; Open files and goto lines like we see from g++ etc. i.e. file:line
(defadvice find-file (around find-file-line-number
                             (filename &optional wildcards)
                             activate)
  "Turn files like file.cpp:14 into file.cpp and going to the 14-th line."
  (save-match-data
    (let* ((matched (string-match "^\\(.*\\):\\([0-9]+\\):?$" filename))
           (line-number (and matched
                             (match-string 2 filename)
                             (string-to-number (match-string 2 filename))))
           (filename (if matched (match-string 1 filename) filename)))
      ad-do-it
      (when line-number
        ;; goto-line is for interactive use
        (goto-char (point-min))
        (forward-line (1- line-number))))))
#+END_SRC

Unfortunately it does not work with emacsclient.
So I could use some pointers on how to make it work with emacsclient.
Would it be possible to achieve this with an advice, since the original
patch was written in c.

Regards,
Toon


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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2017-02-09  9:58 [PATCH] add emacsclient support to open with file:linum syntax Toon Claes
@ 2017-02-09 13:22 ` Stefan Monnier
  2017-02-14 13:57   ` Toon Claes
  0 siblings, 1 reply; 43+ messages in thread
From: Stefan Monnier @ 2017-02-09 13:22 UTC (permalink / raw)
  To: Toon Claes; +Cc: jorge.garcia.gonzalez, kaushal.modi, eggert, Emacs Devel

> Unfortunately it does not work with emacsclient.
> So I could use some pointers on how to make it work with emacsclient.

Put the advice on `find-file-noselect`?


        Stefan



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

* Re: [PATCH] add emacsclient support to open with file:linum syntax
  2017-02-09 13:22 ` Stefan Monnier
@ 2017-02-14 13:57   ` Toon Claes
  0 siblings, 0 replies; 43+ messages in thread
From: Toon Claes @ 2017-02-14 13:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: jorge.garcia.gonzalez, kaushal.modi, eggert, Emacs Devel


> On 9 Feb 2017, at 14:22, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
> Put the advice on `find-file-noselect`?
> 
> 
>        Stefan


Thanks a lot Stefan!
This is in fact the working defadvice:

#+begin_src emacs-lisp :tangle yes
  (defadvice find-file-noselect (around find-file-noselect-at-line
                                        (filename &optional nowarn rawfile wildcards)
                                        activate)
    "Turn files like file.cpp:14 into file.cpp and going to the 14-th line."
    (save-match-data
      (let* ((matched (string-match "^\\(.*\\):\\([0-9]+\\):?$" filename))
             (line-number (and matched
                               (match-string 2 filename)
                               (string-to-number (match-string 2 filename))))
             (filename (if matched (match-string 1 filename) filename))
             (buffer-name ad-do-it))
        (when line-number
          (with-current-buffer buffer-name
            (goto-char (point-min))
            (forward-line (1- line-number)))))))
#+end_src


Enjoy!

Toon


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

end of thread, other threads:[~2017-02-14 13:57 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09  9:58 [PATCH] add emacsclient support to open with file:linum syntax Toon Claes
2017-02-09 13:22 ` Stefan Monnier
2017-02-14 13:57   ` Toon Claes
  -- strict thread matches above, loose matches on Subject: below --
2016-01-07 22:35 Jorge Alberto Garcia
2016-01-08  7:42 ` Yuri Khan
2016-01-08  8:08   ` Jorge Alberto Garcia
2016-01-08  8:59     ` Yuri Khan
2016-01-08 14:11       ` Jorge Alberto Garcia
2016-01-08  9:03   ` Eli Zaretskii
2016-01-08 14:13     ` Jorge Alberto Garcia
2016-01-08 15:39       ` Eli Zaretskii
2016-01-08 15:54         ` Kaushal Modi
2016-01-08 16:13           ` Jorge Alberto Garcia
2016-01-08 16:38             ` Kaushal Modi
2016-01-08 16:44               ` Jorge Alberto Garcia
2016-01-08 16:54                 ` Kaushal Modi
2016-01-08 17:52                   ` Jorge Alberto Garcia
2016-01-08 19:06                     ` Eli Zaretskii
2016-01-08 19:05                   ` Eli Zaretskii
2016-01-12 21:04                     ` John Wiegley
2016-01-12 21:26                       ` Jorge Alberto Garcia
2016-01-13  0:10                         ` John Wiegley
2016-01-13  0:46                           ` Jorge Alberto Garcia
2016-03-29 16:22                             ` Kaushal Modi
2016-03-29 17:30                               ` Jorge Alberto Garcia
2016-03-29 21:27                                 ` Paul Eggert
2016-03-29 22:35                                   ` Kaushal Modi
2016-03-29 23:08                                     ` Paul Eggert
2016-03-29 23:29                                       ` Jorge Alberto Garcia
2016-03-30  0:37                                         ` Paul Eggert
2016-03-30 14:21                                           ` Kaushal Modi
2016-03-30 16:42                                             ` Jorge Alberto Garcia
2016-03-31 12:31                                             ` Stefan Monnier
2016-03-31 14:24                                               ` Jorge Alberto Garcia
2016-01-08 19:19                   ` David Caldwell
2016-01-08 19:43                     ` Eli Zaretskii
2016-01-08 19:52                       ` David Caldwell
2016-01-08 20:33                         ` Jorge Alberto Garcia
2016-01-09 22:51                           ` Jorge Alberto Garcia
2016-01-10  8:22                             ` Yuri Khan
2016-01-10  8:37                               ` Jorge Alberto Garcia
2016-01-12 16:24                                 ` Jorge Alberto Garcia
2016-01-08 16:10         ` Jorge Alberto Garcia

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