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: [PATCH] add emacsclient support to open with file:linum syntax Date: Thu, 7 Jan 2016 16:35:40 -0600 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1452206197 32604 80.91.229.3 (7 Jan 2016 22:36:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Jan 2016 22:36:37 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 07 23:36:33 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 1aHJAP-0006C3-NC for ged-emacs-devel@m.gmane.org; Thu, 07 Jan 2016 23:36:25 +0100 Original-Received: from localhost ([::1]:33078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHJAO-0008UH-SK for ged-emacs-devel@m.gmane.org; Thu, 07 Jan 2016 17:36:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHJAL-0008U9-FR for emacs-devel@gnu.org; Thu, 07 Jan 2016 17:36:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHJAK-0005wC-Iy for emacs-devel@gnu.org; Thu, 07 Jan 2016 17:36:21 -0500 Original-Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:33830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHJAK-0005vp-DQ for emacs-devel@gnu.org; Thu, 07 Jan 2016 17:36:20 -0500 Original-Received: by mail-oi0-x22a.google.com with SMTP id k206so100301oia.1 for ; Thu, 07 Jan 2016 14:36:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=i+4zAoxUGMS9QTdLOp2o1JwUOsS01DWJfunVfxfte0A=; b=pshHL6xtBFgbfKC9g3j9H8O6PeYuaHyTCAQIvZkph4OYN0U5YwOcENfq/TnDHFbbCV m+QpWI2eOGu48QnNbU4bwrM21GdSY4lRej2o37uhAufMESG/nGMdGpv+3SclSKGmsKoI yi+mWLUmYok47IlwuJ1W75Un4nXANYgb4T90SbPD3HZVyrRypC3b5PJyGRAc/4AwV65X Vm61DF6h28wMsmUL5KX5xU/Tx2lVMlyq8vTr78phLibzaRDRy3Tp2aBe77M9yM2oVGoA grLfWiZeb8Zh0CQSMcMa6QAMdp31vwhpz9hQ1WSxhe3EWnOF1M5hp84V4zPIIv9cHs8B /rIA== X-Received: by 10.202.228.147 with SMTP id b141mr47886663oih.33.1452206179848; Thu, 07 Jan 2016 14:36:19 -0800 (PST) Original-Received: by 10.202.92.213 with HTTP; Thu, 7 Jan 2016 14:35:40 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::22a 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:197775 Archived-At: 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, " "); }