Feature request/suggestion about file saving lazarus / 9-Editor ---------------------------------------------------------------------- 440bx · 2024-07-27 02:39 Hello, It would be nice to be able to configure Lazarus to automatically save any file that has been modified when it loses focus (that is, the user is switching to another app.) That would enable the other app to detect any changes that were made to the files using Lazarus. Comments welcome. ---------------------------------------------------------------------- MarkMLl · 2024-07-27 07:29 Two thoughts: i) Does Lazarus save files (or make temporary copies) when it gets a power-failure signal? ii) Could automatic saving be handled by an IDE plugin? MarkMLl ---------------------------------------------------------------------- 440bx · 2024-07-27 08:16 I don't know the answers to those two questions but, I am under the impression that there is no plugin support in Lazarus.  Is that impression incorrect ? ---------------------------------------------------------------------- MarkMLl · 2024-07-27 08:57 Quote from: 440bx on July 27, 2024, 10:16:37 amI don't know the answers to those two questions but, I am under the impression that there is no plugin support in Lazarus.  Is that impression incorrect ? OK, "compiled-in package" then. Poor terminology on my part. In this particular case I can't speak for Linux (or other unices), but my experience is that Windows handles the "SHUT DOWN NOW" triggered by e.g. a UPS fairly well. MarkMLl ---------------------------------------------------------------------- DomingoGP · 2024-07-27 13:10 Quoteii) Could automatic saving be handled by an IDE plugin? Hi, the attached zip contains a barely tested ide plugin that save the files when the ide is deactivated. I hope it solves your feature request. How to use: Menu -> Package -> Open package file (lpk). Button Compile Button Use/Install. If you don't like it  then: Open package file (lpk) Button Use/Uninstall. Regards Domingo. ---------------------------------------------------------------------- 440bx · 2024-07-27 13:41 Domingo, Thank you very much. It works but not quite the way it should work.  For some reason when switching, Lazarus does save the file but, it takes several seconds and multiple switchings before my editor sees the changes in the file. That does not happen when using the normal "Save" (ctrl_s) or "Save all".  When using "Save"/"Save all"/"Ctrl-s" my editor sees the changes instantly. As strange as it may sound, it looks like the line:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   LazarusIDE.DoSaveAll([]);is not equivalent to manually doing a "Save all" or "Save". The problem I described above occurs when switching from Lazarus directly to my editor.  Strangely, if I switch back to my editor by clicking on my editor's icon on the taskbar then the changes appear immediately. Summary: when switching directly something isn't quite right, it looks like the file's modified date and time are not updated immediately.  when switching by means of the taskbar then the changes appear immediately. ---------------------------------------------------------------------- DomingoGP · 2024-07-27 14:58 I think that the problem is in the sequence of events. Your Editor becomes active and checks for changed files before lazarus becomes inactive and saves the files, whereas saving in the IDE ‘Save all’ saves the files and when your editor becomes active it detects the changes. Changing using taskbar: TaskBar becomes active, lazarus becomes inactive and save the files,  taskbar becomes inactive, editor becomes active and see the changes. Right now I have no idea how to fix it, sorry. ---------------------------------------------------------------------- 440bx · 2024-07-27 18:20 Quote from: DomingoGP on July 27, 2024, 04:58:43 pmRight now I have no idea how to fix it, sorry. That's fine.  I appreciate your efforts and switching using the taskbar is just a small extra step, no big deal. Thank you again. ---------------------------------------------------------------------- JuhaManninen · 2024-07-28 07:57 Quote from: 440bx on July 27, 2024, 08:20:28 pm... and switching using the taskbar is just a small extra step, no big deal. Yes, using the OS taskbar or using the "Save All" button in Lazarus main window coolbar or the same button placed in the editor toolbar. They all require just one click. I am a little curious why you want to use another editor. Programming is not only writing code but also studying existing code and IMO Lazarus editor is very good for that. You can quickly jump to definitions and ancestors etc. and then back. The integrated help system is rather good, too. ---------------------------------------------------------------------- Joanna · 2024-07-28 15:08 I’m also curious about the desire to save file everytime focus is lost. It’s easy to save all . If you are using a computer without battery backup  and your concern is a sudden power outage wouldn’t you also want to save work every minute or something? I vaguely remember word processors doing this. ---------------------------------------------------------------------- 440bx · 2024-07-28 15:54 Quote from: JuhaManninen on July 28, 2024, 09:57:45 amI am a little curious why you want to use another editor. Programming is not only writing code but also studying existing code and IMO Lazarus editor is very good for that. You can quickly jump to definitions and ancestors etc. and then back. The integrated help system is rather good, too. It's difficult to show why I prefer the editor I use over any other editor (not just Lazarus'.) Lazarus' editor is reasonably good, take that as high praise because I consider the majority of editors out there as being unfit for text editing. As far as the facilities that Lazarus provides, such as function definition hints and code navigation, I completely agree that those are great but, the problem I face is they stop working as the code gets more complex.  Codetools doesn't seem to handle the way I structure code.  In the project I'm working on currently I cannot get function definition hints, jumping to function definitions/implementation does not work, code completion does not work, hints (if and when they appear, which is unusual) are sometimes yellow and sometimes grey, they grey ones are a pain because it's not possible to scroll them causing them to rarely show the information that is of interest.  The only feature that causes me to do _some_ editing in Lazarus is that I can edit while debugging and _that_ is occasionally extremely convenient (and obviously a feature I cannot get from a "text editing only" editor such as the one I use.) It is not an exaggeration to state that I edit, at least, 10 times faster using Multi-Edit (the editor I use) than any other editor including the Lazarus editor (which I consider to be usable - again, that's high praise) Having Lazarus save the files when I switch back to my editor is great.  Also great is that Lazarus detects and reloads the file when it has been modified by an external tool (that feature is pure gold.) You may be wondering why I don't report these bugs.  The reason is, they normally start happening after the program has grown to be of "some size".  That makes it difficult to create a short program that exhibits the problem(s) because I don't know what in the code is causing the problem(s). There reasons I use Lazarus are two:  1. it's an excellent front end to FPC.  2. FpDebug is a debugging jewel. and when/while it works the codetools facilities (code completion, code "exploration", hints) but, I cannot list that as a reason because those features eventually eventually stop working (which I have to admit, is a bit frustrating.) ---------------------------------------------------------------------- Joanna · 2024-07-28 16:01 It’s very seldom that I save a file in Lazarus because the files are saved automatically everytime I compile which I do a lot. ---------------------------------------------------------------------- Martin_fr · 2024-07-28 16:24 If I may, I would like to join in on the editor part. And specifically with questions towards 440bx. Let me start with, I am not trying to convince you of anything. And I know that even between 2 editors with equal features, the one that has been used in the past will be preferable (And if only due to the exact key combos, some layout diff ....). So to switch to another editor it does have to be more than equal. That said, if Lazarus has any features deemed missing, I will point that out. At least for educational purposes. If it is missing some, I may (at my leisure) consider, if I would find it interesting to add them. (no promise there, and again, I understand that even if they were added, that would not necessary change your preferences). So, I am still interested in what (if any) the difference are? - Any features (such as navigation, modifications, ...) available (or available in less keystrokes)? - Any display features (such as highlight, wordbreak, margin indicators...) - Management: arrangement of tabs, switching, overviews (files, content), menu, .... - Just more convenient key combos? - ... ---------------------------------------------------------------------- 440bx · 2024-07-28 18:52 @Martin, One of the characteristics that make the editor I use much more efficient to use is that it does _not_ use control keys.  It may sound strange but the control key might very well be the most difficult and inconvenient key to reach in the keyboard, that makes its use highly inefficient (and consequently undesirable.)  The editor I use is more function-key centric (function keys combined with mostly shift and alt - more WordPerfect-like than Wordstar-like.) The ability to change the key mappings is great and I've used it to make the Lazarus editor use the same keys for some functions as my editor but, unfortunately that is limited by the fact that Lazarus implements a lot of other features which use key mappings that I would normally use for text editing.  That makes those key combinations unavailable for editing.  That's one general problem, which likely has no ideal solution. After that, a lot of subtleties that, at first seem insignificant but make a noticeable difference.  The following is going to sound unreasonable but, I find that the speed at which the cursor moves left and right barely adequate (actually, that part is faster in Lazarus than in the majority of editors out there - I suspect the cursor/caret movement is done in software which is why it's faster than in most other editors), I estimate it's half the speed of ME (Multi-Edit, the editor I use.)  Moving the cursor vertically (up/down) is paintfully slow particularly when it has to scroll the window at the same time. That's probably somewhere between 1/8 to 1/4 (at best) the speed of ME.  When I need to scroll more than a few lines, I switch back to ME, it takes less time to switch back and do what I need there than scrolling to the line of interest in Lazarus.  It's amazing how small details can make a big difference.  When I bookmark something in ME and "retrieve" the bookmark, what is shown in the window is _exactly_ what was there when I set the bookmark.  That means, the top line is what it was when I set the bookmark, the cursor is in exactly the same place.  This means that, when I retrieve the bookmark, I don't have to get acquainted with what's displayed because it is exactly the same as what was there when the bookmark was set.  (strangely bookmark setting in ME is one of the few functions that is control-key driven.) What makes an editor good is the combination of the features it supports, how they are implemented (which determines if they are fast or slow) and how they are managed (how do you "reach" them.)  Those are the characteristics that make the VS editor a total disgrace and most other editors, literally, intellectually painful to use. Considering that the Lazarus editor has to inhabit the Lazarus IDE and, therefore share the environment (key mappings among other things) with other functionality, it is remarkably good. As far as "wishing for a feature upon a star", I'd like to see retrieving a bookmark cause what's displayed in the window to be _exactly_ what it was when the bookmark was set, meaning top line , cursor position, everything.  (I've already made a feature request for that, this is just to let it be known that I still wish for that.) Thank you for reading. ---------------------------------------------------------------------- Martin_fr · 2024-07-28 19:09 The caret speed may come down to 2 things. 1) key repetition rate. Though that would be the same, an editor could instead register the down event, and start its own internal timer.... 2) repaint. Technically just moving the caret, does not repaint anything (its an xor paint of just the few pixels). But SynEdit will likely redraw the current line. (Not checked), since often Highlights change (current word,...). Also it needs to check what may have changed. Moving up down, changes display in the gutter, and so there also is a repaint. And it searches for the "top line hint / proc header". Probably other stuff too. ---------------------------------------------------------------------- 440bx · 2024-07-28 19:17 Yes, there are a number of subtleties involved in scrolling (horizontal and vertical) The Lazarus editor does a reasonably good job in that area, better than most editors. ---------------------------------------------------------------------- Martin_fr · 2024-07-28 20:03 One thing that highly disrupts scrolling (especially vertical) are highlight changes. You may consider disabling them, if you have them on, don't need them, and maybe scrolling improves (little bit) E.g. "Markup and Matches": "Keyword brackets". Highlight Begin/End pairs etc. If you scroll up/down, and go through a begin/end (or other word that has a match), then the other word is highlighted, causing invalidation in the middle of the editor. So instead of just painting the one (or few) scrolled in lines, the invalidation forces a repaint of all lines from the border to the keyword. The probably should have a timer (at least if the key is kept down, or if scrolling).... Brackets can do that too, if they are multiline.... Though that is rare (you have to also hit the bracket while scrolling). Oh, and disable the scroll hint: That small bubble with the linenumber when using the scrollbar.... It overlaps the editor, and causes invalidations that lead to extra painting. Worse, the latest addition (though IIRC by default off). A 2nd color for the fold gutter, to indicate the fold containing the caret. As you keep moving up/down to scroll, the caret changes, and that line needs to be repainted. Again causing a lot of extra painting. I don't know if that gets "used" by people while scrolling, or if a delay (remove, and restore after scrolling ends) would be acceptable. But then its a very special feature, and if it is not enabled, it does not interfere. ---------------------------------------------------------------------- MarkMLl · 2024-07-28 20:34 Multi-Edit was one of the earliest full-screen editors in the DOS era, and one of the earliest to be designed around drop-down menus etc. rather than having them be a visually-convenient wrapper around underlying control key combinations. It's competitors were Brief, Epsilon, Point (from Logitech), Turbo (Pascal etc.), and of course MS Quick-Basic. The Windows variant somehow wasn't quite as good, and was up against MS Visual (Basic etc.) and Delphi which in combination elbowed practically everything else out of their way. I mention the two variants (which co-existed fairly comfortably in the early 1990s) intentionally, since at this point I think we have to wonder what would happen if somebody (440bx, I'm looking pointedly at you) did a side-by-side comparison of the Lazarus editor on Windows and Linux, and then possibly on Linux+X11 vs Linux+Wayland: performance differences might be platform specific and if they could be highlighted they might turn out to be fixable. MarkMLl ---------------------------------------------------------------------- 440bx · 2024-07-28 22:34 @Martin, Thank you for all those tips.  The only setting I have set that may impact scrolling speed is highlighting open and close parentheses and brackets.  Since it is somewhat rare for the cursor to be on one of those, it probably doesn't make a perceptible difference. Everything else you mentioned is turned off. @MarkMLI, Since I do not use Linux, I cannot compare the Lazarus editor in Windows and Linux. general comment(s): One of the things that is often a topic in the forum is how to make FPC/Pascal more popular.  That always reminds me of how I got initially hooked on Multi-Edit.  At the time (MS-DOS) Multi-Edit was the _only_ editor that when you pressed the shift or ctrl (which used to be located above the shift key, not below as it is now) or alt key, small labels (8 of them) at the bottom of the screen would appear showing what action pressing the given function key in combination with that key would do. For someone learning how to use the editor, that "training wheel" was incredibly useful.  It gave you "instant help" on what ctrl/alt/shift F1..F8 did.  That combined with the fact that ME was programmable in a language that was quite similar to Pascal was another big plus, not to mention that the editor itself is coded in that language.  The executable is basically/mostly an interpreter for that language.  It was/is like having the editor's source code and customizing it on the fly.  When I see the compiler emit an "illegal expression" message which is about as unhelpful a message can get or, "semicolon expected" when a semicolon is the last thing you need in that location, it makes me think about the frustration someone trying to learn Pascal using FPC (or Delphi) may experience.   This is true of most compilers, their error messages _very often_ leave a great deal to be desired.  I believe that if someone designed a capable language (FPC qualifies) that emitted precise and accurate error messages, that would go a long ways into making that language popular. I've been programming for 48 years now and there are still occasions when I read an FPC error message and look at the code and do not see what it is the compiler is complaining about because the message is as informative about the situation as finding a newspaper ad in a Mongolian desert.  Then I think, a beginner faces a tough learning curve because the message(s) is often of little to no help in solving the problem.  All that said, at least it's an indication there is a problem (early C compilers would simply assume there is an integer there and keep compiling... and they have the gall of calling a binary disgrace like that a "compiler"... sure... that's a compiler like the Pope is a Victoria Secret lingerie model.) Time for me to get off my soap box... ---------------------------------------------------------------------- MarkMLl · 2024-07-29 07:45 Quote from: 440bx on July 29, 2024, 12:34:13 amSince I do not use Linux, I cannot compare the Lazarus editor in Windows and Linux. Since you're the one commenting on performance issues, it's time for you to do so for the sake of comparison. MarkMLl ---------------------------------------------------------------------- 440bx · 2024-07-29 09:06 Quote from: MarkMLl on July 29, 2024, 09:45:00 amSince you're the one commenting on performance issues, it's time for you to do so for the sake of comparison. MarkMLl I could and can do so for Windows editors but not for Linux editors. (though I have used vi, emacs and other editors that are available in both unix and Windows.) That said, it isn't my intention nor desire to prove something.  IOW, I have no incentive whatsoever to make the comparison and, much less to spend any time performing a task that is of no interest to me.  In addition to that ME is now a defunct product, even if I demonstrated it is better than sliced bread, it is no longer being sold, therefore it has become irrelevant to anyone who isn't using already using it. The reason I requested the feature in this thread is because if I forget to save the file edited in Lazarus then any edits made in ME will not be seen by Lazarus. Lazarus doesn't attempt to reload a file that it hasn't saved, i.e, has edits pending, that has caused me to occasionally lose some edits.  I seldom forget to save the files (usually simply by doing a recompile which causes all files to be saved) but, it has happened and it is something that I have to always keep in the back of my mind. Now, with the package from Domingo (thank you again Domingo), the only thing I have to keep in mind is to switch to ME using the taskbar, small thing and easily remedied (without any loss of edits) if I forget. ---------------------------------------------------------------------- JuhaManninen · 2024-07-29 09:34 Quote from: 440bx on July 28, 2024, 05:54:43 pm... such as function definition hints and code navigation, I completely agree that those are great but, the problem I face is they stop working as the code gets more complex.  Codetools doesn't seem to handle the way I structure code.  In the project I'm working on currently I cannot get function definition hints, jumping to function definitions/implementation does not work, code completion does not work, That sounds bad, especially because when a problem cannot be reproduced with a small code snippet, it will be very difficult to fix. Known issues with Codetools happen with lots of conditional compilation, complex generics syntax and maybe other new Pascal syntax like type helpers. Code for the Lazarus IDE itself can be navigated quite nicely. Quotehints (if and when they appear, which is unusual) are sometimes yellow and sometimes grey, they grey ones are a pain because it's not possible to scroll them causing them to rarely show the information that is of interest. Yes, that is a strange bug. You have reported it here : https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41008 Somebody should debug it. ---------------------------------------------------------------------- 440bx · 2024-07-29 10:21 Quote from: JuhaManninen on July 29, 2024, 11:34:49 amThat sounds bad, especially because when a problem cannot be reproduced with a small code snippet, it will be very difficult to fix. I agree.  I'll try to come up with a small code snippet at some point. ---------------------------------------------------------------------- MarkMLl · 2024-07-29 10:32 I'm reminded of the situation 15 or so years ago, where Lazarus- and a number of other apps including Mozilla- was virtually unusable remotely over X11 but worked fine over VNC. Now this sort of thing is clearly a platform problem: in that particular case I believe it turned out to be because GTK was doing a wildly excessive amount of input device polling. The problems currently being discussed could similarly turn out to be platform-specific, but the only person who stands a chance of making sensible decisions about them is somebody who can distinguish between "nothing wrong" and "I can still see it but it's not as bad". MarkMLl ---------------------------------------------------------------------- PascalDragon · 2024-07-31 20:53 Quote from: 440bx on July 29, 2024, 12:34:13 amWhen I see the compiler emit an "illegal expression" message which is about as unhelpful a message can get or, "semicolon expected" when a semicolon is the last thing you need in that location, it makes me think about the frustration someone trying to learn Pascal using FPC (or Delphi) may experience.   This is true of most compilers, their error messages _very often_ leave a great deal to be desired.  I believe that if someone designed a capable language (FPC qualifies) that emitted precise and accurate error messages, that would go a long ways into making that language popular. The problem is that in the majority of these situations the compiler really has no better idea what to complain about instead. Especially “semicolon expected” is usually a last resort message when it can't safely do an error recovery and continue on. ---------------------------------------------------------------------- MarkMLl · 2024-07-31 21:30 Quote from: PascalDragon on July 31, 2024, 10:53:53 pmThe problem is that in the majority of these situations the compiler really has no better idea what to complain about instead. Especially “semicolon expected” is usually a last resort message when it can't safely do an error recovery and continue on. Having cut my teeth on punched-card FORTRAN where just about every error message was MISMATCHED PARENTHESES, I assure you that I sympathise :-) MarkMLl ---------------------------------------------------------------------- 440bx · 2024-07-31 22:17 Quote from: MarkMLl on July 31, 2024, 11:30:44 pmHaving cut my teeth on punched-card FORTRAN where just about every error message was MISMATCHED PARENTHESES, I assure you that I sympathise :-) MarkMLl That's one of the problems created by the lack of a formal grammar definition that is strictly adhered to.  When there is a formal grammar, emitting good, precise, accurate error messages is quite often easy.  Of course, there are errors that can create ambiguities that prevent emitting a precise and accurate message but, "semicolon expected" or "illegal expression" would _never_ be necessary, not even in ambiguous situations. The absence of a formal grammar is the reason the compiler doesn't know what the appropriate message to emit is. ---------------------------------------------------------------------- Martin_fr · 2024-07-31 22:43 Quote from: 440bx on August 01, 2024, 12:17:32 amThe absence of a formal grammar is the reason the compiler doesn't know what the appropriate message to emit is. Well even then... The expected grammar for the following should be clear (not sure if it is formalized, but that could be done, and the ambiguity would remain): if true then A := b c What is the error? Is there a semicolon missing, and c is a function that can be called (next statement)? Or is there an operator missing? b + c Or a dot b.c ? Or a parenthesis? b is a function and should take c as argument? b(c ...) Or a begin of comment? "// c" and the expression continues on the next line? Or a space that shouldn't be bc is an identifier? Or an "else"? Yes there are simple cases, where more distinct errors could be given. But the more specific an error gets, the more misleading will it be, if it was incorrectly given. And in that light, I actually agree "semicolon expected" is bad. It is to specific. As it can (in most cases) not be known what is expected (or it is to long a list), it shouldn't state something to be expected. It should just say, that something unexpected was found. In the above example: "Unexpected identifier c was found". Or "Identifier 'b' can not directly be followed by another identifier." Though, I don't know how much more that would help. And other than this, many other errors are helpful, at least to me. Like type mismatches, missing/extra parameters.... ---------------------------------------------------------------------- lainz · 2024-07-31 22:46 There's AutoSave plugin in OPM. https://github.com/lainz/LazAutoSave ---------------------------------------------------------------------- 440bx · 2024-07-31 23:27 Quote from: Martin_fr on August 01, 2024, 12:43:51 amThe expected grammar for the following should be clear (not sure if it is formalized, but that could be done, and the ambiguity would remain): if true then A := b c What is the error? Is there a semicolon missing, and c is a function that can be called (next statement)? Or is there an operator missing? b + c Or a dot b.c ? Or a parenthesis? b is a function and should take c as argument? b(c ...) Or a begin of comment? "// c" and the expression continues on the next line? Or a space that shouldn't be bc is an identifier? Or an "else"? I'm going to take this on just for fun... Before anything, I have and still acknowledge that some errors can lead to syntactic ambiguities that will make issuing an accurate error message very difficult and, in a few cases, even impossible. In the example you provided and given a formal grammar, the compiler can unambiguously resolve most of your questions.  Here is how: 1.  The compiler should know whether or not "b" is a function, if "b" is a function that takes parameters (the compiler should know that too) then a parenthesis is missing. 2. if "b" is a record (something the compiler should know) then, if there is a field in the record named "c" then the compiler emit an error stating that a dot is missing.  if "b" is not a record and not a function and "b" and "c" are compatible types then the compiler can presume an operator is missing an emit a message to that effect. 3. The compiler requesting a semicolon after "b" is _always_ incorrect because adding a semicolon after "b" does _not_ make the statement correct (unlike requesting a dot or parenthesis or operator) 4. Complaining about an additional space would be incorrect because if that was the error then "b c" should be followed by one of: a semicolon, an "end" or "else" and it is not, therefore that is ruled out. The compiler should know, at all times, no exception _ever_,  where it is standing in the grammar.  It also knows the type of every identifier (an unknown identifier has an unknown type, therefore it knows it's an unknown identifier, therefore an unknown type.) In the great majority of cases, in the presence of a formal grammar, the compiler has all the information it needs to emit a crystal clear, unambiguous error message. That said, yes, there are times when a syntactic error can create ambiguities that are not decidable.  In that case the compiler should emit a message stating a couple of possible alternatives (yes, it should be able to do that too.) ---------------------------------------------------------------------- 440bx · 2024-07-31 23:31 Quote from: lainz on August 01, 2024, 12:46:12 amThere's AutoSave plugin in OPM. https://github.com/lainz/LazAutoSave What I need is not just automatic saving.  What I need is automatic saving when Lazarus loses focus, that's when I want automatic saving to be triggered.  I don't care to have automatic saving in any other situation. Does that package you linked to save files when Lazarus loses focus ? ---------------------------------------------------------------------- lainz · 2024-07-31 23:49 Quote from: 440bx on August 01, 2024, 01:31:51 amQuote from: lainz on August 01, 2024, 12:46:12 amThere's AutoSave plugin in OPM. https://github.com/lainz/LazAutoSave What I need is not just automatic saving.  What I need is automatic saving when Lazarus loses focus, that's when I want automatic saving to be triggered.  I don't care to have automatic saving in any other situation. Does that package you linked to save files when Lazarus loses focus ? It saves always, not just when you switch tabs. But try to adapt it to your needs. Regards. ---------------------------------------------------------------------- Martin_fr · 2024-07-31 23:50 Quote from: 440bx on August 01, 2024, 01:27:13 amI'm going to take this on just for fun... Yep, just fun and games 1) That assumes there are - no optional param / param with default value - overloads - () are mandatory for functions 2) "if b is a record" => does not exclude the other cases, if we consider operator overloads (as then a record + some_other_type would be possible) 3) Yes a semicolon could make that correct, if the following "c" is a function (since the result does not need to be consumed, it would be a statement) 4) Yes the "extra space" wasn't serious / so is the missing comment- start So for the given    if true then A := b c consider b and c are functions b is overloaded (or has a default param) b returns a structure there is an overloaded + for that structure type Ok, yes: not the average case.... However, on the more serious note, if trying to narrow it down... I uphold an unspecific error ("semicolon missing" is not unspecific) is better that the wrong specific. Some of your suggestion on finding the error assume that the error is in the next token. But if "b" was already wrong, then any specific error found will sent the user on the wrong path. And for a user, especially a not-so-expert it does not matter what rules the compiler used to determine the error, if he mistyped the b. E.g.    A := no b;  / - meant to be "not b" - "no" may be a defined identifier No error, whatsoever would help the user here. And any attempt to get a specific error will make it worse. Well ChatGpt actually includes this "The no operator is not valid in Pascal. Pascal uses not for logical negation." and even an example on the correct usage of "not". ---------------------------------------------------------------------- 440bx · 2024-08-01 00:14 The driving force behind emitting an error messages is for the message to provide a remedy that makes the statement correct.  That said, if the statement has multiple problems, such as a missing operator between two identifiers and a semicolon missing separating the last identifier from the next statement, then the compiler would be wise to emit a single error message and once that error is corrected then concern itself with any errors that may have followed that one. Personally, I think Borland made the right choice when they decided to stop compilation upon finding an error.  Error recovery is fraught with problems stemming from possible ambiguities caused by syntactic errors.  For the most part, FPC seems to behave the same way. My personal choice is: give me the fastest possible compiler that emits a _single_ precise, accurate error message.  The deficiencies, in the form of omissions, you pointed out in the possibilities I mentioned are completely valid but, the compiler can take those omissions into account and, in most cases, resolve to a precise error message.  IOW, the compiler knows (or, at the very least, should know), if a function has optional parameters, if an operator has been overloaded or whatever else may apply and take those things into consideration when determining what action makes the syntactically incorrect statement, correct. ---------------------------------------------------------------------- Joanna · 2024-08-01 02:09 On the topic of errors, what is with those runtime error messages that give an error number that you have to look up or have memorized instead of saying what the error is? Wouldn’t it be just as easy to say what it is in text ? Also some error messages don’t really take you to where the error is and you still need to put in breakpoints and trace to where the error happens manually... I wish there could be better runtime error messages. ---------------------------------------------------------------------- DomingoGP · 2024-08-01 10:29 Quote from: 440bx on July 29, 2024, 11:06:55 amNow, with the package from Domingo (thank you again Domingo), ... You are welcome!.  I have tried on windows 7 with Notepad++ and the behavior is de same. The attached zip contains a hacked version for Windows that here (windows7 64 bits) works as desired with Notepad++, i hope it also works well with multiedit for You. As a curiosity, using TEDNotepad (http://jsimlo.sk/notepad/) the first version worked fine. Best Regards Domingo. ---------------------------------------------------------------------- 440bx · 2024-08-01 10:37 Quote from: DomingoGP on August 01, 2024, 12:29:21 pmThe attached zip contains a hacked version for Windows that here (windows7 64 bits) works as desired with Notepad++, i hope it also works well with multiedit for You. I'll try it very soon (I want to finish some things I'm currently doing before recompiling the IDE/installing a new package.) And thanks again! ---------------------------------------------------------------------- munair · 2025-05-10 08:32 Quote from: 440bx on July 28, 2024, 05:54:43 pmAs far as the facilities that Lazarus provides, such as function definition hints and code navigation, I completely agree that those are great but, the problem I face is they stop working as the code gets more complex.  Codetools doesn't seem to handle the way I structure code.  In the project I'm working on currently I cannot get function definition hints, jumping to function definitions/implementation does not work, code completion does not work, hints (if and when they appear, which is unusual) are sometimes yellow and sometimes grey, they grey ones are a pain because it's not possible to scroll them causing them to rarely show the information that is of interest. One of the few issues I currently have with Codetools is that it reports "TStringBuilder not found" while typing, despite the project compiling without errors. It also seems unable to locate TStringBuilder's definition unit/line. But going by my own experience, the Lazarus IDE is quite capable of handling larger projects. No need for me to turn to external editors. The only thing buggy is the debugger when I try to get a variable's value, especially with record or class references. So I use writeln() frequently and hit ctrl+alt+o after execution end to check the output. That works very well. ---------------------------------------------------------------------- Martin_fr · 2025-05-10 10:19 Quote from: munair on May 10, 2025, 10:32:26 amOne of the few issues I currently have with Codetools is that it reports "TStringBuilder not found" while typing, despite the project compiling without errors. It also seems unable to locate TStringBuilder's definition unit/line. But going by my own experience, the Lazarus IDE is quite capable of handling larger projects. No need for me to turn to external editors. The only thing buggy is the debugger when I try to get a variable's value, especially with record or class references. So I use writeln() frequently and hit ctrl+alt+o after execution end to check the output. That works very well. Please see https://forum.lazarus.freepascal.org/index.php/topic,71099.0.html ---------------------------------------------------------------------- 440bx · 2025-05-10 13:30 Quote from: munair on May 10, 2025, 10:32:26 amBut going by my own experience, the Lazarus IDE is quite capable of handling larger projects. In general, I agree with that but, my personal experience so far is, codetools eventually stops working and, in a project that's over 100K lines, figuring out why is not easy.  That said, so far, in v4.0rc3 it seems to be doing better than in previous versions (or maybe it's just that it likes the project I'm currently working on better than other projects of mine.) Quote from: munair on May 10, 2025, 10:32:26 amNo need for me to turn to external editors. I consider most editors available on PCs to be unusable.  This is probably because decades ago I had access to a dedicated Wang word processor.  That Wang machine was a lean, mean, text editing machine.  It puts each and every one of today's text editors (with the exception of Multi-Edit) to shame. I use the Lazarus editor for minor editing while debugging.  I've tried to configure it to work more like M.E but, it that doesn't go very far (to my great chagrin.) That autosave from Domingo is a wonderful thing.  One less thing for me to worry about when programming.  Just in case someone else is interested in that package, I recommend version 1 because version 2 causes a console to flash on the screen and also causes having to alt-tab twice (instead of once) to switch from Lazarus to another app back and forth. v1 is great stuff.   Can't thank Domingo enough for it. ---------------------------------------------------------------------- Martin_fr · 2025-05-10 13:47 Quote from: 440bx on May 10, 2025, 03:30:00 pmI've tried to configure it to work more like M.E but, it that doesn't go very far (to my great chagrin.) If you feel like it, open a thread and describe the missing features... I am always interested in what other editors do different. That said, I am not always able (e.g. time) or even willing (e.g. prioritize) to implement all the stuff (and I still have a list of items to be done). Of course if it's obvious stuff, like - speed: Well that's already known. (Not that SynEdit is that terrible slow, but certain parts are, and any part can always be improved) - bugs... - codetools (for the purpose of my interest not part of the editor, despite being needed, and despite no shortage of interesting ideas) Some of my personal todo: - Major and minor keyboard modes like Emacs. - Control commands via "edit at bottom" (also like Emacs, but could be vi like too) - Some yet to be determined much more flexible bookmark system. - [EDIT/ADDED] configurable editor commands   e.g. cursor-left-next-____ => user can create any amount of such commands by selecting which "stoppoints" to stop at: word-start, word- end, at snake _ in word, after snake, before CamelCase, before symbol with/without lead space, after symbol, ... But none of them is in the works, not now, likely not soon... ---------------------------------------------------------------------- 440bx · 2025-05-10 15:29 Quote from: Martin_fr on May 10, 2025, 03:47:37 pmIf you feel like it, open a thread and describe the missing features... I am always interested in what other editors do different. I probably won't open a thread because what's missing feels like it's caused by a different editing philosophy instead of simply missing features. One example that hopefully will make the statement above a bit clearer.   In M.E, the user doesn't need to press keys to copy a block of text into a buffer.  In M.E, you simply select text, usually using the arrow key(s), page-up, page-down, etc.  Once the text is selected, it's ready to be manipulated.  No need to copy it to a buffer. A common editing task is to copy some text.  In most editors, it goes 1. select the text, 2. copy the text into a buffer, 3. paste the text in the target spot.  In M.E, it goes, 1. select the text, 2. copy the text in the target spot. In that simple and common operation, no keystrokes were needed to copy the text into a buffer.  The selected text is persistent and typing does not overwrite/replace the text (Lazarus can do that part too.) As you are aware, telling Lazarus to make the text persistent changes some of its cursor movement behavior.  That's already a deal breaker.  The fact that text is selected shouldn't change anything at all as far as caret movement goes. What makes M.E so good (and desirable to me) is that it takes _very few_ keystrokes to get the job done and, the reason for that is rooted, not so much in its feature set but, in an editing philosophy that cannot be fully duplicated in "normal editors". Since you mentioned bookmarks and, the setting and recovery of bookmarks is more "feature" than philosophy.  In Lazarus, it's not really straightforward to see which bookmarks have been set and which are still available (seems like the only way is by opening menus.) Contrast that with setting and recovery of bookmarks in M.E, please refer to the attachment.  When setting a bookmark (ctrl-s), a little popup shows up showing me which bookmarks are already used and suggesting what the next bookmark should be.  I can accept that or press a number and that's it (no need to press an ok button or return or anything else.  When recovering a bookmark (ctrl-g) I get the little popup showing which bookmarks are set, therefore ready to be recovered by just pressing the number. In the case of bookmarks, Lazarus' method is reasonably succinct (it doesn't take a bunch of keys to set/recover them) but, seeing which bookmarks are available is, as previously stated, not straightforward and that subtracts from the feature's usefulness.  I really need to mention that the bookmark improvement you made recently (exact recovery of bookmark state), greatly enhanced the usefulness of bookmarks in Lazarus.  Thank you for that. There are dozens of small details like that, that in every day use, make a considerable difference. One problem the Lazarus editor faces, which I doubt can be fully overcome is that, it shares key combinations with a whole lot of other functions.  That removes those key combinations for the editor's use, that's a handicap and as I mentioned in another thread, I don't see a good solution for that.  A partial solution would be to make key combinations context sensitive but, that may not be easy to do (depends on how things are already coded/implemented.) ---------------------------------------------------------------------- Martin_fr · 2025-05-10 16:19 Quote from: 440bx on May 10, 2025, 05:29:17 pmA common editing task is to copy some text.  In most editors, it goes 1. select the text, 2. copy the text into a buffer, 3. paste the text in the target spot.  In M.E, it goes, 1. select the text, 2. copy the text in the target spot. Sounds like the old Turbo Pascal block. Using a persistent block, and then Ctrl K B  set block begin Ctrl K K  set block end and some other place Ctrl K C  insert a copy of that block QuoteAs you are aware, telling Lazarus to make the text persistent changes some of its cursor movement behavior.  That's already a deal breaker.  The fact that text is selected shouldn't change anything at all as far as caret movement goes. Agreed to be a bug. The behaviour come (probably) from changing the selection. And by accident applies to having a selection. Quote  In Lazarus, it's not really straightforward to see which bookmarks have been set and which are still available (seems like the only way is by opening menus.) Yes, you can however use a key-combo to get this as popup menu. That allows you to look which are free. QuoteContrast that with setting and recovery of bookmarks in M.E, please refer to the attachment.  When setting a bookmark (ctrl-s), a little popup shows up showing me which bookmarks are already used and suggesting what the next bookmark should be.  I can accept that or press a number and that's it (no need to press an ok button or return or anything else. We have "Set a free bookmark". But it wont ask, it just does. You then see in the gutter which one it was. This "Set a free bookmark" is also in the popupmenu that you can pop up via keycombo. QuoteIn the case of bookmarks, Lazarus' method is reasonably succinct (it doesn't take a bunch of keys to set/recover them) but, seeing which bookmarks are available is, as previously stated, not straightforward and that subtracts from the feature's usefulness. What is imho missing is a tool-window that stays open, and keeps the info visible. There is a package "stacked bookmarks" or similar, but its a different concept. QuoteOne problem the Lazarus editor faces, which I doubt can be fully overcome is that, it shares key combinations with a whole lot of other functions.  That removes those key combinations for the editor's use, that's a handicap and as I mentioned in another thread, I don't see a good solution for that.  A partial solution would be to make key combinations context sensitive but, that may not be easy to do (depends on how things are already coded/implemented.) Some keycombos are context sensitive already. Either - Depend on which window is focused (but Anchordock sometimes breaks that) - What the editor currently does (e.g. syncro edit) Of course you got stuff that the OS does, like Alt-T opens the tools menu.... (not sure if the editor keymap would overrule that). As for other stuff, like keys that control the debugger, well yes: currently that is: if you want to use them for debugging, then you can't have them for editing. That would be the "major mode". A major mode, is a separet keymap, that can either be toggled according to the "mode" of the IDE (modes would need to be defined). Minor modes are also keymaps, that can be user toggled within each major mode. I have to look at the emacs docs again (its long since I last used it) to remind myself of the exact distinction. But the goal is, different keymaps for different tasks. ---------------------------------------------------------------------- 440bx · 2025-05-10 16:47 Just for the record, The little popups in the snapshot I posted don't stay open.  The moment the bookmark is set or recovered they go away (as they should, otherwise they would obscure text which is undesirable.) ---------------------------------------------------------------------- dsiders · 2025-05-10 17:16 Quote from: 440bx on May 10, 2025, 05:29:17 pmSince you mentioned bookmarks and, the setting and recovery of bookmarks is more "feature" than philosophy.  In Lazarus, it's not really straightforward to see which bookmarks have been set and which are still available (seems like the only way is by opening menus.) Contrast that with setting and recovery of bookmarks in M.E, please refer to the attachment.  When setting a bookmark (ctrl-s), a little popup shows up showing me which bookmarks are already used and suggesting what the next bookmark should be.  I can accept that or press a number and that's it (no need to press an ok button or return or anything else.  When recovering a bookmark (ctrl-g) I get the little popup showing which bookmarks are set, therefore ready to be recovered by just pressing the number. In the case of bookmarks, Lazarus' method is reasonably succinct (it doesn't take a bunch of keys to set/recover them) but, seeing which bookmarks are available is, as previously stated, not straightforward and that subtracts from the feature's usefulness.  I really need to mention that the bookmark improvement you made recently (exact recovery of bookmark state), greatly enhanced the usefulness of bookmarks in Lazarus.  Thank you for that. Are you aware of Ctrl+Shift+B to set or toggle a bookmark and Ctrl+B to select an existing bookmark? I see no difference (other than button versus menu item layout) when compared to your images. ---------------------------------------------------------------------- Martin_fr · 2025-05-10 17:58 Quote from: 440bx on May 10, 2025, 06:47:15 pmJust for the record, The little popups in the snapshot I posted don't stay open.  The moment the bookmark is set or recovered they go away (as they should, otherwise they would obscure text which is undesirable.) Well then try ctrl-shift B   (keymapping: "toggle bookmark ...") The menu pops up. You see which ones are free, you press 0..9 to select one of them. Only missing bit "Set a free bookmark" has no key inside the menu. That ought a be changed. And going to a bookmark Ctrl-B You even see file + line before you choose the number. ---------------------------------------------------------------------- 440bx · 2025-05-10 18:19 Quote from: Martin_fr on May 10, 2025, 07:58:50 pmWell then try ctrl- shift B   (keymapping: "toggle bookmark ...") Good suggestion, thank you Martin. If find it's not quite as easy to visualize as M.E's popup but, it is definitely a substantial improvement over having to navigate to the menu to see what bookmarks are set. Thanks again. ---------------------------------------------------------------------- Martin_fr · 2025-05-10 18:22 Quote from: 440bx on May 10, 2025, 08:19:29 pmQuote from: Martin_fr on May 10, 2025, 07:58:50 pmWell then try ctrl-shift B   (keymapping: "toggle bookmark ...") Good suggestion, thank you Martin. If find it's not quite as easy to visualize as M.E's popup but, it is definitely a substantial improvement over having to navigate to the menu to see what bookmarks are set. Well its a question of how it can be visualized in a popup menu. Maybe Icons could be greyed (not sure if for those already set, or those not yet set). That would need to be done before the menu is called, since all the menu entries must be kept enabled. Maybe the text could contain a hint. Maybe a checkbox or radio or ... can be added as indicator. ---------------------------------------------------------------------- Martin_fr · 2025-05-10 18:24 Otherwise, any one can write a 3rd party add on...