Hi All,
As I and others have said in other threads.
In languages like C or C++ lines mostly end in punctuation, so it is unlikely that a line ends in a valid autocomplete, so pressing return to end the line is safe.
In languages like Python lines rarely end in punctuation, so it is likely that a line ends in a valid autocomplete, so pressing return is not safe, you have to check that no autocomplete is present, dismiss it if it is, then press return. Or more likely press return automatically and then go back and edit the inappropriate autocomplete that was added. All very annoying and inefficient.
The attached patch adds a hidden preference to cancel the autocomplete when return is pressed, but before it is processed, removing the problem.
Cheers Lex
PS I don't have the docutils on this machine, can someone please make the geany.html.
On 06/05/11 19:51, Lex Trotman wrote:
Hi All,
As I and others have said in other threads.
In languages like C or C++ lines mostly end in punctuation, so it is unlikely that a line ends in a valid autocomplete, so pressing return to end the line is safe.
In languages like Python lines rarely end in punctuation, so it is likely that a line ends in a valid autocomplete, so pressing return is not safe, you have to check that no autocomplete is present, dismiss it if it is, then press return. Or more likely press return automatically and then go back and edit the inappropriate autocomplete that was added. All very annoying and inefficient.
Soooo annoying.
The attached patch adds a hidden preference to cancel the autocomplete when return is pressed, but before it is processed, removing the problem.
Would it be better to add a configurable keybinding to autocomplete so that you can set it to something besides Return through the UI? We already have "Complete snippet" and "Word part completetion", it seems logical to have a "Complete word" that does a similar action. I guess the "Complete word" binding would need to be renamed to something else, maybe "Toggle completion list" or something.
Alternatively, what about checking to see if the caret is at the last (non-whitespace?) position on the line as well to decide whether Return is going to cancel auto-completion?
Patch applied & works fine BTW.
Cheers, Matthew Brush
Would it be better to add a configurable keybinding to autocomplete so that you can set it to something besides Return through the UI? We already have "Complete snippet" and "Word part completetion", it seems logical to have a "Complete word" that does a similar action. I guess the "Complete word" binding would need to be renamed to something else, maybe "Toggle completion list" or something.
Hi Matthew,
AFAIK "complete word" is the same basic behavior as return, but one happens in our code and one in Scintilla.
Its not that Geany defines return as autocomplete, it is the default GTK "activate menu item" key that makes Scintilla insert the current menu item and I can't find any way of changing it. So the point was to remove the "imposed on us unwanted definition that can't be changed". And the easiest way was just to cancel the menu before the key was processed. Note SCI_AUTOCSETSTOPS seemed to work for anything except return :-(
Alternatively, what about checking to see if the caret is at the last (non-whitespace?) position on the line as well to decide whether Return is going to cancel auto-completion?
The menu already autocancels on a whitespace so thats not needed. And if I press return I want to break the line so it now *is* the last position :-) Otherwise return behavior is inconsistent and I think thats a bad thing (tm).
Cheers Lex
On 06/05/11 22:03, Lex Trotman wrote:
Would it be better to add a configurable keybinding to autocomplete so that you can set it to something besides Return through the UI? We already have "Complete snippet" and "Word part completetion", it seems logical to have a "Complete word" that does a similar action. I guess the "Complete word" binding would need to be renamed to something else, maybe "Toggle completion list" or something.
Hi Matthew,
AFAIK "complete word" is the same basic behavior as return, but one happens in our code and one in Scintilla.
You would think, but it seems to just toggle the autocomplete list (maybe between a few lists).
Its not that Geany defines return as autocomplete, it is the default GTK "activate menu item" key that makes Scintilla insert the current menu item and I can't find any way of changing it. So the point was to remove the "imposed on us unwanted definition that can't be changed". And the easiest way was just to cancel the menu before the key was processed. Note SCI_AUTOCSETSTOPS seemed to work for anything except return :-(
I guess you tried "\n" in SCI_AUTOCSTOPS and checked in wasn't in SCI_AUTOCSETFILLUPS? I've not played with either, just curious. Might be worth asking on the scintilla-interest list.
Alternatively, what about checking to see if the caret is at the last (non-whitespace?) position on the line as well to decide whether Return is going to cancel auto-completion?
The menu already autocancels on a whitespace so thats not needed. And if I press return I want to break the line so it now *is* the last position :-) Otherwise return behavior is inconsistent and I think thats a bad thing (tm).
I meant (pseudo code):
function on_key_pressed() { if (key_pressed == Enter && caret_position == current_line.length - 1 && autocomplete_list_is_showing == True) { cancel_autocomplete() return } ... }
Not sure if that would work on not.
Anyway, I've just gotten in the habit of using the space bar to cancel the list at the end of a line and then pressing Enter. Since I have the trim trailing whitespace thing on, this works well.
Cheers, Matthew Brush
AFAIK "complete word" is the same basic behavior as return, but one happens in our code and one in Scintilla.
You would think, but it seems to just toggle the autocomplete list (maybe between a few lists).
Hmmm, works the same for me, inserts the selected completion (current svn, new config, tab keybinding)?
I guess you tried "\n" in SCI_AUTOCSTOPS and checked in wasn't in SCI_AUTOCSETFILLUPS? I've not played with either, just curious. Might be worth asking on the scintilla-interest list.
Don't remember exactly what, but linefeed, return and some others. Havn't had time to look at scintilla.
I meant (pseudo code):
Understood, what I said was that makes return behave differently at end of line vs not at eol and I think thats bad.
Cheers Lex
On 06/05/11 23:40, Lex Trotman wrote:
AFAIK "complete word" is the same basic behavior as return, but one happens in our code and one in Scintilla.
You would think, but it seems to just toggle the autocomplete list (maybe between a few lists).
Hmmm, works the same for me, inserts the selected completion (current svn, new config, tab keybinding)?
Same setup here, except not new config and the "Complete word" binding it's at the default of <Control>space. If the autocomplete list is showing, it cancels it, if it's not showing, it shows it. A few snips from the manual:
"The autocompletion list for symbols is presented when the first few characters of the symbol are typed (configurable, see Editor Completions preferences, default 4) or when the Complete word keybinding is pressed (configurable, see Editor keybindings, default Ctrl-Space)."
"...Shows the autocompletion list. If already showing tag completion, it shows document word completion instead, even if it is not enabled for automatic completion. Likewise if no tag suggestions are available, it shows document word completion."
I meant (pseudo code):
Understood, what I said was that makes return behave differently at end of line vs not at eol and I think thats bad.
Ah ok. I don't feel strongly either way if it's good or bad.
Cheers, Matthew Brush
Hmmm, works the same for me, inserts the selected completion (current svn, new config, tab keybinding)?
Same setup here, except not new config and the "Complete word" binding it's at the default of <Control>space. If the autocomplete list is showing, it cancels it, if it's not showing, it shows it. A few snips from the manual:
Ahh, I'm talking about the "word part completion", default binding tab and which inserts the completion (or as much as is unambiguous). you are talking about the misnamed "word completion" which calls the better named editor_start_auto_complete() to show or swap the menu, as it says in your quotes.
There isn't a "accept the selected autocompletion" that accepts the whole completion, Geany relies on the return going to Scintilla.
Cheers Lex