Recent

Author Topic: Find in files... Lazarus IDE improvement  (Read 7288 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Find in files... Lazarus IDE improvement
« on: August 10, 2023, 10:08:59 am »
Lazarus IDE has a menu entry at Search/Find in files ... Clicking the entry will make a Find in Files window appear. In this window, the default file mask is *.pas;*.pp;*.inc.
The improvement is to replace that default mask text with *.pas;*.pp;*.inc;*.lpr because libraries are saved using the lpr extension. For example, now, when you search in directories for "library" you'll notice that the libraries won't appear, as their file extension is ignored.

wp

  • Hero Member
  • *****
  • Posts: 12299
Re: Find in files... Lazarus IDE improvement
« Reply #1 on: August 10, 2023, 10:40:31 am »
I almost never search in libraries, and the default is fine for me.

But did you know that you can extend the search list? Simply add ";*.lpr" and you have the .lpr extension in the search mask list. Anything you type here goes into the history list of the combobox. You can select any previously used search mask settings from the combobox dropdown. Since all this is stored in the user profile, it will be available in the next session as well. What more can you want?

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: Find in files... Lazarus IDE improvement
« Reply #2 on: August 10, 2023, 11:48:25 am »
I almost never search in libraries, and the default is fine for me.

But did you know that you can extend the search list? Simply add ";*.lpr" and you have the .lpr extension in the search mask list. Anything you type here goes into the history list of the combobox. You can select any previously used search mask settings from the combobox dropdown. Since all this is stored in the user profile, it will be available in the next session as well. What more can you want?
Why would the default mask ignore the lpr files!? It's the default extension when writing libraries and these files are created by Lazarus, too.
If you ask somebody to search for library xxx in a directory, most likely you'll have a false negative answer. This means that you also have to say that the search should be done by another application(not the Lazarus IDE), or you have to say that the default file mask of Lazarus has to be modified by adding the lpr extension.
Why would Lazarus developers force another developer to give additional instructions for such a simple task!? It complicates something that should be done straight forward, using default settings.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10250
  • Debugger - SynEdit - and more
    • wiki
Re: Find in files... Lazarus IDE improvement
« Reply #3 on: August 10, 2023, 11:50:10 am »
It's a catch 22...

If you edit a project with forms (GUI / project type "Application") then the ".lpr" contains pascal code generated by the IDE. So in this case many people don't wont to search in the lpr file. It isn't code they wrote.

Of course, as soon as the search includes lcl (or any package the user did not wrote themself), then the lpr file would be of interest.

And if you create a non-gui "simple program" or a "library", then the lpr also contains your code.


So there are cases were lpr is better not in the list, and cases were it should be...


-----EDIT
Clarification: This is meant to say, there likely was some though (the lpr for gui app) in setting the current default.

I do not say anything about, if this reason is(still)/was proper.
« Last Edit: August 10, 2023, 11:53:46 am by Martin_fr »

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: Find in files... Lazarus IDE improvement
« Reply #4 on: August 10, 2023, 01:14:59 pm »
Regarding the default file mask, I still don't see a reason why lpr files should be treated differently than pas files. Here is why.
Searching for the text "This file was automatically created by Lazarus. Do not edit!" in the lazarus directory shows many pas files. If these files are not obsolete, it means that the default file mask doesn't protect the search results against automatically inserted data in files by the IDE. However, because the IDE ignores by default the lpr files, the code written by developers won't be found using default settings, which leads to having false negative search results by default. This can't be something good.

vangli

  • New Member
  • *
  • Posts: 46
Re: Find in files... Lazarus IDE improvement
« Reply #5 on: August 10, 2023, 03:06:08 pm »
While not recommending it, because it will be lost in next update of Lazarus, you may fit the default search list to whatever you want by:

Open the file "findinfilesdlg.lfm" for editing. You find it in the source directory "ide" of Lazarus. In the object FileMaskComboBox just change the "Text" option to your preference, like "'*.pas;*.pp;*.inc;*.lpr'", and save it. Then rebuild your IDE.

IMHO it is not wise to change the default value due to what me or other may like. It is better then to argue if this should be a configurable option in the standard IDE option choices.

Bent  ;D
Regards Bent

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10250
  • Debugger - SynEdit - and more
    • wiki
Re: Find in files... Lazarus IDE improvement
« Reply #6 on: August 10, 2023, 03:10:44 pm »
Well, first of all:
- I am not trying to convince you [1]. I simple describe what I guess to be  the probable cause for the current situation.

- Equally I do not express my opinion on if that should be kept or not (or should have been at all to begin with)

I will refine my previous description in reply to your post. This is not meant as a "defence of it" (for I have nothing to defend).
It may however read as if it was, because (assuming the current mask wasn't a result of randomness) it attempts to clarify what I think the reason may have been (i.e. therefore it defends that there was a reason / but not the quality of that reason).

Every sentence of the explanation should be read as "it was probably thought that..."
--------------
The lazarus directory is not a (typical) project directory. It includes lots of packages. (and the files founds belong to those packages.)
The project is in the "ide" directory. Yet, this directory is not just the project, but also hosting further packages.

If you edit a project with forms (GUI / project type "Application") then the ".lpr" contains pascal code generated by the IDE. So in this case many people don't wont to search in the lpr file. It isn't code they wrote.

Of course, as soon as the search includes lcl (or any package the user did not wrote themself), then the lpr file would be of interest.

And if you create a non-gui "simple program" or a "library", then the lpr also contains your code.


So there are cases were lpr is better not in the list, and cases were it should be...

So add to this

1) "if you work on a (e.g., your own) package, then the filter is insufficient as there are generated pas files."

2) Yet still, if you work on gui-app, it may  (or may at the time) have been thought to better leave lpr out of the list.

3) If such filtering was thought as better, and could not be achieved completely for packages, then partially achieving it may still have been thought better than nothing.

4) Additionally the "exceptions/flaws" may not have existed at that time.... (don't know in which order things were added).




[1]
"not convince you" of the content => that is just a guess. I have no problem if you think it was introduced for a different reason.

If you think so, then still, at this very moment "I guess as I have described". Therefore in terms of "convince you", I would hope to convince you that the above is indeed what I do guess at the moment of writing this.
« Last Edit: August 10, 2023, 03:13:50 pm by Martin_fr »

n7800

  • Full Member
  • ***
  • Posts: 134
Re: Find in files... Lazarus IDE improvement
« Reply #7 on: November 06, 2023, 08:52:59 pm »
I'm all for adding this file extension by default. More results are better than fewer. I even recently found a similar issue on GitLab. I thought the files were missing from the repository, but it turned out that this was a "feature" of the search (which is definitely a bug).

When searching, you always get extra results, this is normal. Moreover, in how many situations will the searched text be found in the LPR file? Usually there is nothing "specific" contained there.

And from the point of view of the compiler, LPR are files containing source code, this is also part of the program.

In the end, if it is so critical for the user, then he will be able to remove the unnecessary extension. I think this is required much less often.

Bart

  • Hero Member
  • *****
  • Posts: 5349
    • Bart en Mariska's Webstek
Re: Find in files... Lazarus IDE improvement
« Reply #8 on: November 06, 2023, 10:19:37 pm »
Lazarus IDE has a menu entry at Search/Find in files ... Clicking the entry will make a Find in Files window appear. In this window, the default file mask is *.pas;*.pp;*.inc.
On my machine (Lazarus 3.99 (rev main_3_99-538-g7c055798ef) FPC 3.2.2 i386-win32-win32/win64) the dropdownlist is as folows:
*.*
*.pas;*.pp;*.inc;*.cfg;*.xml
*.pas;*.pp;*.inc;*.cfg;*.xml;*.lpi


I would suggest extending the latter with *.lpr
The lpi is autogenerated, as almost always is the lpr.
So it would fit there?

Bart

MarkMLl

  • Hero Member
  • *****
  • Posts: 7511
Re: Find in files... Lazarus IDE improvement
« Reply #9 on: November 07, 2023, 08:17:58 am »
I would suggest extending the latter with *.lpr
The lpi is autogenerated, as almost always is the lpr.
So it would fit there?

.lpr should be in there, since there are plenty of cases where even with a GUI-based app it needs to be tweaked (and the IDE is tolerant of this).

If .lpi is in there, then so should .lps and arguably .lpg; however in practice I don't think there's a good argument for needing to manipulate any of these directly particularly if one isn't entirely sure in advance where to find what one wants to modify.

Same argument applies to .lfm: there's cases where it has to be cleaned up (e.g. if using frames) but if one has to use a brute-force search to find the stuff one needs to change one probably doesn't have the experience to do it safely.

Arguably, if .lpi etc. are in there then so should the IDE's state with "recent project" lists etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

n7800

  • Full Member
  • ***
  • Posts: 134
Re: Find in files... Lazarus IDE improvement
« Reply #10 on: November 07, 2023, 03:31:38 pm »
Now there is a list of files with Pascal source code, so it is logical to add LPR there, which also contains the source code. But LPI, LPS and LPK are already XML files, LFM is also a different format, CFG files can generally be of any format.

And regarding the contents of these files:
LPS is a session file (list of open files, cursor position, jump history).
LPI, LPK - project settings file (compilation and debugging parameters, files list).
It's hard to imagine what you can look for in these files.
PS: what kind of LPG extension is this?

In addition, it is unlikely that anyone will have to search for something simultaneously among the source code files and among the configuration files. For example, if I'm looking for a variable, then I only need the source code. If this is a project option, then project files.
Therefore, if the list "LPI, LPS, LPK" is needed, then only in a separate line of the drop-down list.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7511
Re: Find in files... Lazarus IDE improvement
« Reply #11 on: November 07, 2023, 03:59:39 pm »
LPS is a session file (list of open files, cursor position, jump history).

Yes, but it has a great deal of overlap with .lpi so they can usefully be considered together.

Quote
PS: what kind of LPG extension is this?

Project group.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

n7800

  • Full Member
  • ***
  • Posts: 134
Re: Find in files... Lazarus IDE improvement
« Reply #12 on: November 07, 2023, 04:49:16 pm »
Quote
PS: what kind of LPG extension is this?

Project group.

Thanks, I did a quick search on the internet and couldn't find anything. It would be nice to add this to the pages:
https://wiki.freepascal.org/File_extensions
https://wiki.freepascal.org/Alphabetical_list_of_file_extensions

TRon

  • Hero Member
  • *****
  • Posts: 3159
Re: Find in files... Lazarus IDE improvement
« Reply #13 on: November 07, 2023, 05:13:11 pm »
Thanks, I did a quick search on the internet and couldn't find anything.
It is mentioned but not where you'd be looking or expecting it (especially not if you do now know anything about groups).
All software is open source (as long as you can read assembler)

n7800

  • Full Member
  • ***
  • Posts: 134
Re: Find in files... Lazarus IDE improvement
« Reply #14 on: January 22, 2024, 08:59:01 pm »
I was looking for one variable today and couldn't find it. It turned out that among all the "graphical" projects there was one console project, the code of which was in the LPR-file. And I remembered this topic.

Martin, perhaps you will decide to add this extension? I think this will be especially useful for beginners who are starting with console applications.

In general, I don't see any cases where this will harm anyone.

 

TinyPortal © 2005-2018