Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-04

Autocomplete with procedure varibles

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd

I have something like this:

var
  some_external_func: function(foo: bar): baz; cdecl;
  some_external_proc: procedure(bla: blub); cdecl;

and later I will assign them with pointers received with GetProcAddress() from a dynamically loaded library. There are a lot of these functions and I need to call most of them a lot of times all over my code. It all works perfectly well with only one little annoyance: Whenever I invoke the code completion when writing a function call it will complete like a "normal" variable:

some_external_func :=

I have to backspace and remove the := manually so I can proceed with the opening bracket. From this moment on everything is ok again, with Ctrl+Schift+Space I will have a calltip hint exactly like with normal functions. The problem is only the autocompletion.

Is this intentional? At least in my current case in 90% of all times when I start typing the name of a procedure variable I actually want to call it. (actually in my current project I don't even assign them all individually with := anymore either, I have factored this one assignment out to a place where I don't have to touch it anymore, so its actually 99.9%)

Would it be possible to change the behavior of autocomplete for procedure variables (maybe even make it a config option with) or would this be considered as a wontfix because other uses happen more often than my special case here?

Bernd

Reply by email

Mattias Gaertner
to Bernd
Show quoted text 31 lines
I have something like this: var some_external_func: function(foo: bar): baz; cdecl; some_external_proc: procedure(bla: blub); cdecl; and later I will assign them with pointers received with GetProcAddress() from a dynamically loaded library. There are a lot of these functions and I need to call most of them a lot of times all over my code. It all works perfectly well with only one little annoyance: Whenever I invoke the code completion when writing a function call it will complete like a "normal" variable: some_external_func := I have to backspace and remove the := manually so I can proceed with the opening bracket. From this moment on everything is ok again, with Ctrl+Schift+Space I will have a calltip hint exactly like with normal functions. The problem is only the autocompletion. Is this intentional? At least in my current case in 90% of all times when I start typing the name of a procedure variable I actually want to call it. (actually in my current project I don't even assign them all individually with := anymore either, I have factored this one assignment out to a place where I don't have to touch it anymore, so its actually 99.9%) Would it be possible to change the behavior of autocomplete for procedure variables (maybe even make it a config option with) or would this be considered as a wontfix because other uses happen more often than my special case here?

Please create a feature request in the bug tracker.

Mattias

Reply by email

Sven Barth
to Bernd: I have something like this: var some_external_func: function(foo: bar): baz; cdecl;…
Bernd wrote 31 lines
I have something like this: var some_external_func: function(foo: bar): baz; cdecl; some_external_proc: procedure(bla: blub); cdecl; and later I will assign them with pointers received with GetProcAddress() from a dynamically loaded library. There are a lot of these functions and I need to call most of them a lot of times all over my code. It all works perfectly well with only one little annoyance: Whenever I invoke the code completion when writing a function call it will complete like a "normal" variable: some_external_func := I have to backspace and remove the := manually so I can proceed with the opening bracket. From this moment on everything is ok again, with Ctrl+Schift+Space I will have a calltip hint exactly like with normal functions. The problem is only the autocompletion. Is this intentional? At least in my current case in 90% of all times when I start typing the name of a procedure variable I actually want to call it. (actually in my current project I don't even assign them all individually with := anymore either, I have factored this one assignment out to a place where I don't have to touch it anymore, so its actually 99.9%) Would it be possible to change the behavior of autocomplete for procedure variables (maybe even make it a config option with) or would this be considered as a wontfix because other uses happen more often than my special case here?

Your case is not so special... the same happens e.g. when using OpenGL functions which are procedural variables as well.

Regards,
Sven

Reply by email

Alexander Klenin
to Mattias Gaertner: On Mon, 23 Apr 2012 22:20:18 +0200 Please create a feature request in the bug tracker.…

While calling the procedure via variable is probably more frequent, assigning to it is a valid case too.
I can suggest several alternatives:
1) Output both "myproc(params)" and "myproc:=" items in the completion dropdown
2) Choose call vs. assignment based on the key pressed to select from the completion list:
"(" for call, ":" or "=" for assignment.

Alexander S. Klenin

Reply by email

Martin
to Alexander Klenin
Alexander Klenin wrote 8 lines
While calling the procedure via variable is probably more frequent, assigning to it is a valid case too. I can suggest several alternatives: 1) Output both "myproc(params)" and "myproc:=" items in the completion dropdown 2) Choose call vs. assignment based on the key pressed to select from the completion list: "(" for call, ":" or "=" for assignment.

3)
Simple insert it without either ( or :=. Then one can continue typing as one likes.

Only this needs to be configurable separate from the := for other variables.

Reply by email

Alexander Klenin
to Martin
Martin wrote
3) Simple insert it without either ( or :=. Then one can continue typing as one likes.

Excellent thinking! I agree.

Only this needs to be configurable separate from the := for other variables.

I think this is too rare a case to deserve a separate option. There are far too many of them already :)
Just do not insert ':=' after procedure variables -- for other cases, preserve the current behaviour.

Alexander S. Klenin

Reply by email

Martin
to Alexander Klenin
Alexander Klenin wrote
On Wed, Apr 25, 2012 at 01:33, Martin wrote: > 3) Simple insert it without either ( or :=. Then one can continue typing as one likes. Excellent thinking! I agree.

or even better:
as long as there is a dropdown, ue to other variables (different name, same start) display both (or all 3: none; (; :=). But if there would be only this var, complete the name only

Show quoted text 7 lines
> Only this needs to be configurable separate from the := for other variables. I think this is too rare a case to deserve a separate option. There are far too many of them already :) Just do not insert ':=' after procedure variables -- for other cases, preserve the current behaviour.
What I meant is: the := is configurable.

and in proc var, you do not want it to follow the config for other var. Never mind, if that is haldcoded or has an option

Reply by email