Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add variable substitution to snippets #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ravenx99
Copy link
Contributor

Lee,

This has worked well in my testing, but I'm sure there are edge cases where it can act weird.
It doesn't depend on any new tools. I tried to make it as simple and elegant as possible within that constraint.

I tried using zenity -forms mode, but enter does nothing on that screen... it requires tabbing between fields and either tabbing to OK or using the mouse. I felt this was unacceptable, so I prompt for each variable separately to allow just hitting enter.

I look forward to your feedback.

@ravenx99
Copy link
Contributor Author

I'm confused as to why git thinks this is a conflict, it's a simple merge.

@beckerpascal
Copy link
Contributor

Checked out your branch but didn't work so far. It just copied the text of the whole snippet together with the replacement snippet. Just used the example you gave in the readme file (%filltext:name=DIRECTORY:default=root_tmpdir%).
Is there anything you have to install to get it running?

@ravenx99
Copy link
Contributor Author

ravenx99 commented Jul 2, 2018

No, I made sure it didn't add any new requirements. Is it getting far enough to prompt you for the substitution value? Meaning it's found and deciphered the filltext, but then fails to do the replacement, in that case.

@beckerpascal
Copy link
Contributor

No, unfortunately not. I get the list with all files, then choose one by start typing the name, press enter than the text is directly pasted to the cursor's position.

When I execute the texpander.sh script directly on the console, I get the sentence with the variable twice. First separately before the text and once in the text.

@ravenx99
Copy link
Contributor Author

ravenx99 commented Jul 2, 2018

Hm. I found that the underscore in the default value keeps the default value from getting used, but otherwise substitution works as expected. I wonder if there's a difference in how our grep or sed work.

grep (GNU grep) 2.27
sed (GNU sed) 4.4

Can you try it with this snippet?:

echo TEST1 %filltext:name=foo:default=fred fish% TEST2 %filltext:name=bar% END1
echo TEST3 %filltext:name=qux% END3
echo TEST4 %filltext:name=foo% END4

(test1 and test2 are on the same line.)

@beckerpascal
Copy link
Contributor

Okay, got a little bit further: When I start the script from console, I get the forms for entering the values. But not if I start it with my shortcut. But this could be a problem not related to this issue.

So it seems like it is working :) Thanks for the help!

@beckerpascal
Copy link
Contributor

Is working now. May have been some issue with an older lib. Thanks for the work!

@ravenx99
Copy link
Contributor Author

ravenx99 commented Jan 7, 2019

Oh, sweet. I figured you'd given up on it as being too complicated.

@MyriaCore
Copy link

Is this going to be merged at all?

@leehblue
Copy link
Owner

leehblue commented May 7, 2019 via email

@NicoWeio
Copy link

NicoWeio commented May 7, 2019

Sounds like we should establish a branch or a fork for Texpander-"powerusers" 🤔

@leehblue
Copy link
Owner

leehblue commented May 7, 2019 via email

@MyriaCore
Copy link

@NicoWeio No joke, I had a few more ideas of my own for this kinda stuff. Where do you think we should have it?

@ravenx99
Copy link
Contributor Author

I've been trying to decide if I want to take on maintaining a fork. I guess I might as well, since I wrote the complicated patch.

@MyriaCore
Copy link

Fair enough, let us know if you do decide to make it.

@MyriaCore
Copy link

MyriaCore commented Apr 9, 2020

I've made enough changes to the base script that it's basically a fork already. I'm hosting it here on gitlab if any of you are interested.

Notable changes so far:

  • Now using dmenu for the 'Chose Abbreviation' menu
  • Spaces are now preserved in filenames
  • Ships with a script that allows map entries in YAML and JSON documents to be emitted to the ~/.texpander directory as abbreviations
  • Snippets can now expand to the contents of the clipboard using the %clipboard macro
  • Snippets can now expand to the output of specified shell scripts, and take user input for those shell scripts with the %script macro.
  • Snippets can now expand to other snippets with the %snippet macro.

I have a bunch of plans, for future features, and I add to it when the opportunity arises. It's a nice way for me to practice bash anyway. MR's are welcome, check it out if you're interested!

@MyriaCore
Copy link

If you guys are interested, I can try to get this merged into a poweruser branch. Ping me & let me know if this is the case.

@NicoWeio
Copy link

NicoWeio commented Apr 9, 2020

Looks awesome! I would definitely like to see that in a poweruser branch.
Anyway, I'll try out your version for myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants