From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jorge Alberto Garcia Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] add emacsclient support to open with file:linum syntax Date: Sat, 9 Jan 2016 16:51:10 -0600 Message-ID: References: <838u40qw8j.fsf@gnu.org> <837fjkozax.fsf@gnu.org> <56900BBE.8080804@porkrind.org> <83ziwfoo1j.fsf@gnu.org> <5690139B.1050602@porkrind.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1452379932 14625 80.91.229.3 (9 Jan 2016 22:52:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Jan 2016 22:52:12 +0000 (UTC) Cc: Eli Zaretskii , Yuri Khan , Emacs developers , Kaushal Modi To: David Caldwell Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 09 23:52:11 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aI2Mi-0000qR-Pz for ged-emacs-devel@m.gmane.org; Sat, 09 Jan 2016 23:52:09 +0100 Original-Received: from localhost ([::1]:43969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aI2Mi-0000jy-48 for ged-emacs-devel@m.gmane.org; Sat, 09 Jan 2016 17:52:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aI2MU-0000jg-Gv for emacs-devel@gnu.org; Sat, 09 Jan 2016 17:51:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aI2MT-0001wE-9J for emacs-devel@gnu.org; Sat, 09 Jan 2016 17:51:54 -0500 Original-Received: from mail-ob0-x235.google.com ([2607:f8b0:4003:c01::235]:35453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aI2MR-0001vV-CM; Sat, 09 Jan 2016 17:51:51 -0500 Original-Received: by mail-ob0-x235.google.com with SMTP id py5so5530986obc.2; Sat, 09 Jan 2016 14:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=3/FHAj7K2WaAselGZ/g9hRwVJLX+OpUKGvvuCOUzW74=; b=WWTHvJs33/SYPuGQLKbeahmQ8ODOR+69sGz+MISPCVFeAOjnAa5/EosKyi525I3zdv n8PI1FYQT5XfxphYafOMZANg3oKd/YXCPsAbl1jZnb0+g4optJG1hZ6cECdmb1qSi+qy 6ZHRc+AGAz4j50zQugr3flH+PCCDZLcwWUe3B1x/qehvKZC+QjpIpYLY4cR18n325MH+ 4pZ2b7hGfzk+OB3ymiuCGeEMQppQ/vbVOuvUDM6S9q+bOmDOpvsQfBjPXPLXOlRKOfW8 j3P+J/oeND+E1KdXBeLxRi2ogYhMPiYDDOKajFor9yzmC4XIUH1hIDUeI4u43R7qgARF Kt7w== X-Received: by 10.182.221.201 with SMTP id qg9mr67549026obc.1.1452379910324; Sat, 09 Jan 2016 14:51:50 -0800 (PST) Original-Received: by 10.202.92.213 with HTTP; Sat, 9 Jan 2016 14:51:10 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c01::235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:197939 Archived-At: On Fri, Jan 8, 2016 at 2:33 PM, Jorge Alberto Garcia wrote: > On Fri, Jan 8, 2016 at 1:52 PM, David Caldwell wrote: >> On 1/8/16 11:43 AM, Eli Zaretskii wrote: >>>> Cc: Eli Zaretskii , Yuri Khan , >>>> Emacs developers >>>> From: David Caldwell >>>> 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, " "); }