From e2eff00a9c0d89a196bb297b4958473a681ddfee Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 30 Dec 2024 05:00:44 +0300 Subject: support +line[,column] and filename:line:column syntaxes when opening files * This is done via the new opener.tes in the standard library. * Some programs that use $EDITOR expect the +line syntax to work. * You can copy filename:line:column directly from GCC error messages and filename:line from grep output. * Since there may be safe file names beginning with "+" or containing colons, there needs to be a way to turn this off, especially for scripts that don't know anything about the filenames to open. This is done with "--". Unfortunately, the first "--", that stops parameter processing, is always removed from the command line and not passed down into TECO land. This is not a problem for stand-alone scripts, since the script filename is already stopping option processing, so "--" would get passed down. But when calling the profile via `sciteco -- ...`, you could prevent leading minus signs to cause problems but since the `--` is removed, opener.tes cannot use it as a hint. Therefore, we introduced `-S` as a new alternative to `--`, that's always passed down as `--` (i.e. it is equivalent to "-- --"). In other words, `sciteco -S *` will always open exactly the specified files without any danger of misinterpreting certain file names. Should we ever switch to a custom option parsing algorithm, we might preserve "--" (unless after --mung) and thus get rid of "-S". * This advanced behavior can be tweaked by the user relatively easily. In the easiest case, we could replace M[opener] with <:L;R 0X.f [* @EB/^EN.f/ ]* L> in ~/.teco_ini to completely disable the special syntax. --- sample.teco_ini | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sample.teco_ini') diff --git a/sample.teco_ini b/sample.teco_ini index 0fbf40d..a9caf26 100644 --- a/sample.teco_ini +++ b/sample.teco_ini @@ -7,6 +7,7 @@ EMQ[$SCITECOPATH]/color.tes !* Load lexer and buffer session libraries *! EMQ[$SCITECOPATH]/lexer.tes EMQ[$SCITECOPATH]/session.tes +EMQ[$SCITECOPATH]/opener.tes !* Automatic lexing and session management using ED hooks *! @#ED{ @@ -81,8 +82,5 @@ Z"= M[session.load] | [session.path] !* disables session saving *! - [.f - <:L;R 0X.f [* EBN.f ]* L> - ].f - -EF + M[opener] -EF ' -- cgit v1.2.3