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 #1512. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1811
-- Commit Summary --
* cli: add option to open a new, empty file
-- File Changes --
M src/libmain.c (11) M src/socket.c (18) M src/socket.h (2)
-- Patch Links --
https://github.com/geany/geany/pull/1811.patch https://github.com/geany/geany/pull/1811.diff
New cl option needs documenting
What happens if -e is given on the first/new instance when it has "new_document_after_close" set which also makes a new empty document if none are opened at startup.
According to the message output it tries to create two new documents but one is closed and so the result is still only one new empty document. Anyway, not beautiful. I will fix that and the documentation.
@LarsGit223 pushed 2 commits.
fee8468 cli: do not try to open a new file on option '-e' if 'new_document_after_close' is TRUE 56068f9 cli: added documentation for new option '-e'
I have done the announced changes. The behaviour should now be consistent. It is not trying to open a new empty document if option ```-e``` was given and ```new_document_after_close``` is set to ```TRUE```. This prevents the unnecessary message on startup in that case.
I noticed that we do get messages like the following: ``` 12:30:49: File untitled closed. 12:30:49: New file "untitled" opened. ``` This happens if a new document is opened with ```geany -e``` and there already is one empty document open in an existing instance. But the same happens if you chose "New" from the menu in that instance so IMHO the behaviour is consistent.
I think what's a bit inconsistent is, that a user can open as many empty untitled documents as he/she wants if other, not empty documents are opened. But that's out of scope of this PR.
I think what's a bit inconsistent is, that a user can open as many empty untitled documents as he/she wants if other, not empty documents are opened. But that's out of scope of this PR.
Opening lots of empty documents is not an encouraged use-case, so I wouldn't worry. Unnamed documents have no filetype and so most of Geany's functionality is missing, and even if the user manually sets the filetype, they still need filenames for some functionality.
kugel- requested changes on this pull request.
I would rather see that cl_options is amended and that send_open_command() handles that additional field.
@LarsGit223 pushed 2 commits.
25ffe66 cli: amended variable 'empty' to 'cl_options' e488101 cli: handle 'cl_options.empty' in 'send_open_command'
@kugel-: done, comitted changes.
@kugel- Please let me know if any more changes are requested here
b4n commented on this pull request.
@@ -248,6 +255,7 @@ static void check_socket_permissions(void)
* (taken from Sylpheed, thanks) * Returns the created socket, -1 if an error occurred or -2 if another socket exists and files * were sent to it. */ +//gint socket_init(gint argc, gchar **argv, gboolean empty)
what is that?
Looks mostly OK. FWIW, what's the use case for this? Opening a non-existing file is already possible, which is mostly the same but with the benefit of having filename an possibly filetype already selected. I fail to see when it's interesting to control Geany remotely for it to create a new buffer yet not knowing the destination filetype.
@b4n: There was a feature request in #1512. See end of the post for the user's reason for having this feature. This is one of the changes I did in a bunch of changes for just fixing/closing some issues some month ago.
So, I guess it could still be discussed if the feature request should be implemented/merged or rejected/closed.
@codebrainz @LarsGit223: @codebrainz used `-u`/`--untitled` in his patch attempt, but this is using `-e`/`--empty`. Is there a reasoning behind either of those? Also, now the question arises, which one do you prefer? @codebrainz @LarsGit223 @elextr @kugel- @eht16 I would tend to vote `untitled` myself, because it seems clearer and less likely to be useful for something else in the future, but I don't have a strong opinion.
@b4n: yes, ```untitled``` also sounds clearer to me :+1:
Yeah, `--untitled` sounds better, thats the point of the PR, tyo make untitled files.
@LarsGit223 pushed 2 commits.
ffaf264 Removed left-over out commented line d1fa470 Renamed cli option '--empty' to '--untitled'
LarsGit223 commented on this pull request.
@@ -248,6 +255,7 @@ static void check_socket_permissions(void)
* (taken from Sylpheed, thanks) * Returns the created socket, -1 if an error occurred or -2 if another socket exists and files * were sent to it. */ +//gint socket_init(gint argc, gchar **argv, gboolean empty)
A left-over. Will remove it.
Ok, I cleaned up/removed the left-over comment line and renamed the option to ```--untitled```. Also, I squashed all commits into one.
@b4n: ping. As @corvidism doesn't need this feature any more I leave it up to you if you like to merge it or not. I myself just wanted to close the issue. I usually don't start Geany from the command line so I personally do not require the change. But maybe it's useful for others. @elextr @codebrainz @kugel @eht16: what are your opinions?
Let's either merge this or reject the PR so that ticket #1512 can be closed.
I still don't think its needed. The cl already has too many interdependencies between options, leaving out one would be good.
@LarsGit223 OK, as nobody currently really wants this feature in, I'll close this until people ask for this again with a rationale. Thanks for the work though :)
Closed #1811.
github-comments@lists.geany.org