bugGNU nano - Bugs: bug #62269, [Wish] a way to save and restore...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #62269: [Wish] a way to save and restore anchors

Submitted by:  Shi Yanling <sylphenix>
Submitted on:  Fri 08 Apr 2022 02:42:52 PM UTC
 
Severity:  1 - Wish Status:  None
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Sun 08 May 2022 02:33:30 PM UTC, comment #5: 

Interesting mechanism: an anchor at the first line "magically" making nano save the anchors (when --positionlog or 'set positionlog' is active).  This "invisible" mechanism kind of fits the anchors that themselves are normally invisible too.  But from a usability point of view... I doubt that anyone would like this.

However, if you are willing to work on the code for saving an restoring the anchors, then I will help.  And when we get it working, and you've used it privately for a while and are content, you could post the patch to nano-devel and see if anyone else is interested in the feature.

Benno Schulenberg <bens>
Project Administrator
Fri 06 May 2022 06:40:28 AM UTC, comment #4: 

Automatically saving/restoring anchors is better. But if there's an option to activate such feature, I won't turn it on by default. As my routine editor, I don't need it to save anchors in most cases, and do not want it to scan over all the lines every time I close a file. So I have to decide whether to turn the option on or not before I open a file.

How about this way. When I insert an anchor at the first line, the feature that automatically save anchors would be activated. When I remove the anchor from the first line, the feature would be deactivated, and the saved anchor data (if exist) would be cleared. Since the first line never needs an anchor, it is a good place to be used as an indicator. I could turn it on or off whenever I want. To restore anchors, just use -P option. While open a file with -P option, the saved anchors (if exist) would be restored, and if anchors are restored, the feature that automatically save anchors would be activated again. Logically, anchors and cursor's position are the same kind of data. I think they could share the same log file and the same option.

In this way, no extra option or keybinding is needed, and doesn't add any action to nano when anchor is not used. To clear all anchors in current file, just remove the anchor from the first line, and reopen the file.

Shi Yanling <sylphenix>
Fri 15 Apr 2022 01:45:03 PM UTC, comment #3: 

Having two functions (one to save anchors, and one to reload them) would require two keybindings.  Of course, the functions could be unbound by default, but that would make them undiscoverable -- unless they are mentioned listed the main ^G list of shortcuts, but I really don't want to burden that list with such exotic functions.

When saving and restoring anchors automatically (activated by an option, just like 'historylog' and 'positionlog'), no such functions are needed.  However, one would probably want to have a function to clear all existing anchors in a buffer, as it would be tedious to have to clear any present anchors one-by-one.

(One way to clear all anchors in a file when no such 'clear' function exists, would be to run 'nano --ignore --position thefile' and exit immediately.  That would resave the cursor position in the ~/.nano/filepos_history file but without the anchors because nano has not seen the 'keepanchors' option (or whatever it would be called).  Not convenient, but not too hard either: nano -IP thefile, ^X, done.)

Benno Schulenberg <bens>
Project Administrator
Mon 11 Apr 2022 02:19:40 PM UTC, comment #2: 

Thanks for thinking about my request. I didn't mean that automatically save anchors while saving a file and restore them when reopening the file. My thought was that have two functions, one could export anchors to a specified file, and the other one could import it later. The file is specified by user when the function is called. So that we could have the ability to manually export/import anchors just when we want to. I think it wouldn't add slowdowns to nano. I'm not sure that I can accomplish such a patch. But I'd like to have a try when I have time.

Shi Yanling <sylphenix>
Sun 10 Apr 2022 10:47:52 AM UTC, comment #1: 

Where should those anchors be saved?  In another file in ~/.nano?  I don't want to create any more state files for nano.  Then maybe add them in ~/.nano/filepos_history, at the end of each line?  That would create complications when an old filepos_history file does not yet contain any anchor data, but... it seems feasible to solve that.  However, saving the anchors would require running through all of the lines of the file to see whether anyone has an anchor, which takes some time (not much, but still), and I am loathe to add any more slowdowns to nano.  But you are welcome to provide a patch if this feature is important to you.  No guarantees that it will be applied, though.

Benno Schulenberg <bens>
Project Administrator
Fri 08 Apr 2022 02:42:52 PM UTC, original submission:  

I'm trying to code with nano. Anchors are very useful to me, since there are thousands of lines. But anchors can't be saved. When I reopen the code, I have to place those anchors again. I'd like to have the ability to import/export anchors. Or is there any good solution else? Thanks.

Shi Yanling <sylphenix>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by sylphenix (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-29 bens Summary[Wish] save and restore anchors => [Wish] a way to save and restore anchors
    2022-04-10 bens Severity3 - Normal => 1 - Wish
        Summary[Wish] import/export anchors => [Wish] save and restore anchors

    Back to the top


    Powered by Savane 3.9