bugGNU nano - Bugs: bug #62653, [Wish] "snippets" --...

 
 

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

bug #62653: [Wish] "snippets" -- allow binding macros to sequences of text

Submitter:  Marco Diego AurĂ©lio Mesquita <marcodiego>
Submitted:  Sun 19 Jun 2022 06:53:19 PM UTC
 
Severity:  1 - Wish Status:  Wont Fix
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Thu 23 Jun 2022 07:47:40 AM UTC, comment #3: 

@Tasos: It's fine what you do.  I like your style.  :)

As for the nanosnippet script: it takes one more keystroke because one would have to type [Enter] at the end.  And needing to type a key combo like [Alt+S] instead of a plain slash (or whatever symbol the snippet uses) I would count as at least a key-and-a-half.  So it's definitely more typing.  But the script idea is cool.

Benno Schulenberg <bens>
Project Administrator
Wed 22 Jun 2022 04:10:22 PM UTC, comment #2: 

Dear Marco,

I agree with Benno; nano is already versatile enough that you can achieve this kind of thing very easily without asking for such features to be built-in.

If I may suggest an easy solution to your wish:

1. Create a simple bash script, which checks the first argument against a 'case' switch, and outputs the desired output. E.g.:

#!/bin/bash

case "$1" in
    ("for")    echo "for(;;)" ;;
esac

2. Create a single string macro, which brings up the 'execute' menu and the name of your command, and awaits for your input. Add this to your .nanorc file. E.g.:

bind M-S "^T^[fnanosnippet " main

(note, ^T above means you pressed Alt-V in nano to allow verbatim input, and then Ctrl-T; ^[f similarly means verbatim Alt-F). 

This gives you your desired behaviour in exactly the same number of keystrokes. (i.e. you'll type "[Alt-S]for" at the terminal and you'll get "for(;;)" out).

(PS. Benno, sorry to be hanging around the nano tickets. I'm just bored and I like nano. I hope you're not too annoyed by it! :p  )

Tasos Papastylianou <tpapastylianou>
Wed 22 Jun 2022 07:13:55 AM UTC, comment #1: 

This is horrendous.  For every keystroke nano would have to check whether the character is the same as the last one in any of the stored "snippets", and if so, check the preceding characters, and if all match, replace the matched characters with something else.  In addition it would require a new "snippet" nanorc command.  Jesus!  This is what string binds are for:

bind F4 "for (;;)" main
bind Sh-M-R "Requested-by: " main

Please stop wasting my time with absurd requests.  When you want something, make it, use it for a year, and then see if it really is worth the trouble, and whether nano users are the target audience for this.

Benno Schulenberg <bens>
Project Administrator
Sun 19 Jun 2022 06:53:19 PM UTC, original submission:  

It would be a simple (I think) modification for nano to keep a list of macros which instead of bound to a key combo could be bound to a sequence. This would allow the implementation of snippets allowing me to, for examples, typing:

  \for

get nano to replace it by:

  for(;;)

and even correctly position the cursor at the correct spot.

I know this can introduce a check for every key press, but I think the cost is worth.

Marco Diego Aurélio Mesquita <marcodiego>

 

(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 tpapastylianou (Posted a comment)
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by marcodiego (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-07-04 bens Open/ClosedOpen Closed
    2022-06-22 bens Severity3 - Normal 1 - Wish
        StatusNone Wont Fix
        Summary[Wish] Snippets: allow binding macros to sequences of text [Wish] "snippets" -- allow binding macros to sequences of text

    Back to the top


    Powered by Savane 3.9