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

Opening a new tab in an existing instance from shell #1512

Closed
corvidism opened this issue Jun 8, 2017 · 18 comments
Closed

Opening a new tab in an existing instance from shell #1512

corvidism opened this issue Jun 8, 2017 · 18 comments

Comments

@corvidism
Copy link

Hi,

is it possible to start creating a new file in an existing instance from shell? I'd like to use a keyboard shortcut to start a new file, but geany with no arguments opens a new instance (not useful).

If it can't be done, how likely are you to implement it? Ideally, this would be a commandline parameter (something like the opposite of -i).

@Bfgeshka
Copy link

Bfgeshka commented Jun 8, 2017

It should be opened in an opened window if it exists. I always have only one instance.

@corvidism
Copy link
Author

Hm. When I call geany from shell (either from a new one or using geany & repeatedly) it spawns a new instance every time.

When I call geany <filename> it opens the file in the first instance that was opened. (Thinking of which, that also isn't too good - I'd expect it to appear in the last one).

@elextr
Copy link
Member

elextr commented Jun 8, 2017 via email

@codebrainz
Copy link
Member

No geany cannot open a new file from the command line, if a filename is given geany attempts to open it and complains if it doesn't exist since its most likely a typo.

Here it behaves just like nano or vim and opens a new unsaved file with the given filename.

@elextr
Copy link
Member

elextr commented Jun 9, 2017

@codebrainz weird

lex@fred7 ~ $ ./geany -c  /tmp/foo
bash: ./geany: No such file or directory
lex@fred7 ~ $

@elextr
Copy link
Member

elextr commented Jun 9, 2017

Ahh, couldn't find geany, ok, now it works :)

@elextr
Copy link
Member

elextr commented Jun 9, 2017

Although technically it opens a new buffer, it doesn't actually create the file until you save the buffer, either in the running instance by default, or in a new instance with the -i option.

@codebrainz
Copy link
Member

Yeah, that's the usual behaviour, it would be annoying if created the file, for example if you made or a typo or decided you didn't want to save the file, you'd have to go into terminal/file manager and manually delete it.

I think this issue could probably be closed as you can do what the title says already.

@vfaronov
Copy link
Contributor

vfaronov commented Jun 9, 2017

You can use the --socket-file option to open a file in a specific instance of Geany. For example, if you execute these two commands:

geany --socket-file=/tmp/geany1 /tmp/foo
geany --socket-file=/tmp/geany1 /tmp/bar

you get one instance of Geany with two open documents, /tmp/foo and /tmp/bar.

Here’s a script I use (on Linux) to have one instance of Geany per workspace: https://gist.github.com/vfaronov/6843c6bc817521bfab7e58fff139c525

@corvidism
Copy link
Author

Thanks for the replies, but none of the suggestions are helpful with what I'm trying to do, which is to open a new tab (empty "untitled" file, or a new buffer as @elextr said) in an existing instance (any existing instance, I just don't want to spawn a new one).

technically it opens a new buffer, it doesn't actually create the file until you save the buffer

And thanks for that, because I tried calling geany "" and it started editing /home/<username> which... ouch. XD

I think this issue could probably be closed as you can do what the title says already.

...no, I can't? Unless you choose to interpret it as "open existing file in a new tab" which, okay, but not what I meant.

Oh, well. Is there any official way of submitting a feature request for this?

@elextr
Copy link
Member

elextr commented Jun 9, 2017

Oh, well. Is there any official way of submitting a feature request for this?

You have 😄

@codebrainz
Copy link
Member

I don't get it, you can open a new empty file from the command line, and @vfaronov showed how to open that new file in any existing instance instead of just the first one. What more is needed?

@codebrainz
Copy link
Member

@corvidism is it that you don't want to choose a name for the new file up-front but rather later using the Save As dialog?

@codebrainz
Copy link
Member

codebrainz commented Jun 10, 2017

If so, this patch should work, but it doesn't since Geany ignores request to use existing socket file other options when no filenames are given, so it always opens a new instance. I have no idea where that code is, but something like this should work with the patch if it was fixed:

$ geany -u
# or
$ geany --socket-file=/what/ever -u

@corvidism
Copy link
Author

is it that you don't want to choose a name for the new file up-front but rather later using the Save As dialog?

Yes, that's it.

lpaulsen93 added a commit to lpaulsen93/geany that referenced this issue Mar 17, 2018
This adds a new command line option '-e' / '--empty' which opens a new empty
document on starting geany. If there is an existing instance, then that
instance will be re-used and a new empty document is openend in it.

Also see geany#1512.
@b4n
Copy link
Member

b4n commented Aug 4, 2018

@corvidism @LarsGit223 has implemented this in #1811, but I'm wondering what is the actual use case for not choosing the filename? It eludes me why one would like to create a new empty document from outside Geany without anything, be it content or even path.
Once I'm convinced it does have a use case, I'll properly test and merge the mentioned PR (which looks OK).

lpaulsen93 added a commit to lpaulsen93/geany that referenced this issue Aug 6, 2018
This adds a new command line option '-u' / '--untitled' which opens a new empty
untitled document on starting geany. If there is an existing instance, then that
instance will be re-used and a new empty untitled document is openend in it.

Also see geany#1512.
@corvidism
Copy link
Author

Well, to be honest, I abandoned Geany since then, but the use case was this:

I wanted to use a keyboard shortcut to open a new file - for notes and such. The problem was, that calling "geany" with no params would spawn a new instance, which was pretty slow (not "loading an IDE" slow, but still too much for regular use).
It would be much better to just create a new file within an existing Geany instance. But that requires a filename, which brings its own list of problems:

  • where should the file be located?
  • how to keep the file name unique?

and so on. So I would have to write an actual script to do something that I still feel is basic functionality. And if I remember correctly, when saving a new file created through the GUI, the Save as... dialog would remember last used location, whereas with an auto filename it would open at the file's location.

@b4n
Copy link
Member

b4n commented Nov 30, 2018

Closing for now, if somebody wants the feature again, there is an implementation in #1811.
Feel free to ask for it, we'll merge it then.

@b4n b4n closed this as completed Nov 30, 2018
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

6 participants