Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command wildcards in snippets: line number and cursor position #1543

Open
philiprbrenan opened this issue Jul 15, 2017 · 6 comments
Open

Command wildcards in snippets: line number and cursor position #1543

philiprbrenan opened this issue Jul 15, 2017 · 6 comments

Comments

@philiprbrenan
Copy link

When executing a command wildcard in a snippet is it possible to find the current source of the file being editted, the current line and the current cursor position in that line at the invocation of the snippet?

@elextr
Copy link
Member

elextr commented Jul 16, 2017

The filename is set in an environment variable, see the manual, but AFAIK not the line and column.

@philiprbrenan
Copy link
Author

philiprbrenan commented Jul 16, 2017 via email

@ghost
Copy link

ghost commented Jul 18, 2017

Would it help if you would have additional ENV variables? Like GEANY_LINE_NUMBER and GEANY_COLUMN_POSITION or something like that?

I guess devs may be reluctant to add something with only an extremely limited use case perhaps (I assume so; I know that from the ruby core team which often asks for a use case when someone suggests a new feature).

@elextr
Copy link
Member

elextr commented Jul 18, 2017

Line number is simple, but as has been discussed in these issues before, column position has multiple possible definitions in a UTF-8 document:

. byte number
. code point number (most code points are more than one byte)
. character number (some characters are more than one code point)
. glyph number (some glyphs are more than one code point)
. visual column number (some glyphs are zero, narrow, single and double width, and then there is non-monospaced fonts)

The environment variable name therefore should be explicit what it provides. Byte number is the only one easily available.

As the command run from a snippet can only see files stored on the filesystem, they can't see anything in the buffer, so as @philiprbrenan pointed out line/column values may not match the buffer if it has been edited and not saved.

So the usefulness of adding these values would seem limited.

@philiprbrenan
Copy link
Author

philiprbrenan commented Jul 18, 2017 via email

@elextr
Copy link
Member

elextr commented Jul 18, 2017

Instead of snippets you could use custom commands, they are sent the current line or selection and the return value replaces it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants