From: Jorge Alberto Garcia <jorge.garcia.gonzalez@gmail.com>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, John Wiegley <johnw@gnu.org>,
Emacs developers <emacs-devel@gnu.org>,
Yuri Khan <yuri.v.khan@gmail.com>
Subject: Re: [PATCH] add emacsclient support to open with file:linum syntax
Date: Tue, 29 Mar 2016 11:30:42 -0600 [thread overview]
Message-ID: <CAPfrtUcfsi6RQ7n-kvuEenJycOeff6xUiSJtmG7oJRyJ6R08PA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY3XytCY3+dXch7cFFiy-1_kZdJfiKcZnSX+Wn9FtE_dyg@mail.gmail.com>
[-- 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
next prev parent reply other threads:[~2016-03-29 17:30 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 22:35 [PATCH] add emacsclient support to open with file:linum syntax 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 [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2017-02-09 9:58 Toon Claes
2017-02-09 13:22 ` Stefan Monnier
2017-02-14 13:57 ` Toon Claes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPfrtUcfsi6RQ7n-kvuEenJycOeff6xUiSJtmG7oJRyJ6R08PA@mail.gmail.com \
--to=jorge.garcia.gonzalez@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=johnw@gnu.org \
--cc=kaushal.modi@gmail.com \
--cc=yuri.v.khan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.