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

Use read command instead of regular variable assignment #17

Open
kaushalmodi opened this issue May 24, 2017 · 7 comments
Open

Use read command instead of regular variable assignment #17

kaushalmodi opened this issue May 24, 2017 · 7 comments
Labels

Comments

@kaushalmodi
Copy link
Owner

This would allow the use of back-quotes and single quotes (and everything in general) without needing to use escapes for constructing the whole emacs config blob.

Reference: http://crowding.github.io/blog/2014/08/16/replace-less-with-emacs/

@kaushalmodi
Copy link
Owner Author

Briefly experimented with using read, but it did not work as the elisp code being read in contains a `, thus giving this error:

bad substitution: no closing "" in [ *]" (buffer-name buf)) ;Do not count buffers with names starting with space or *

It is this line:

(unless (string-match "\\`[ *]" (buffer-name buf)) ;Do not count buffers with names starting with space or *

@kaushalmodi
Copy link
Owner Author

An alternative is to use this trick by @alphapapa as suggested here.

@alphapapa
Copy link
Contributor

Found it on StackOverflow. Works really well! :)

@kaushalmodi
Copy link
Owner Author

@alphapapa Looks like you need to escape just the `, right?

@alphapapa
Copy link
Contributor

I'm not completely sure what you're referring to, but if you mean what I think you do, then yes, I think that's right. :)

@kaushalmodi
Copy link
Owner Author

@alphapapa
Copy link
Contributor

Right, the backquote is a metacharacter, even inside quoted strings and heredocs. I forget about that, because I always use $(). That bit me today when working on https://github.com/alphapapa/makem.sh, inside an elisp docstring.

If I were to rewrite the code at that URL, I would probably use (list... instead of backquoting and unquoting in that list.

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

No branches or pull requests

2 participants