perl-quote.el v.1

View: New views
3 Messages — Rating Filter:   Alert me  

perl-quote.el v.1

by Kevin Ryde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is a bit of code I've been using to convert perl strings between
single quotes 'foo' and double quote "foo".

I use it mostly to automatically flip the backslashing needed, so
'xx"yy' -> "xx\"yy" or vice versa.  I've also found the gettext style
__"" -> __('') good because adding parens manually is a bit tedious.
The q{} and qq{} support may be a bit superfluous, and might be
imperfect too.




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQBKKGmxLFMCIV9q3ToRAsO5AJ9RSelyGtKDK8PZ/oG1TNSQBk3KZgCfbT5R
h6nonw/IgEzo3M/yKvVPTko=
=rfTa
-----END PGP SIGNATURE-----

_______________________________________________
gnu-emacs-sources mailing list
gnu-emacs-sources@...
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

perl-quote.el (8K) Download Attachment

Parent Message unknown Re: perl-quote.el v.1

by Ilya Zakharevich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-06-05, Kevin Ryde <user42@...> wrote:

>   "Convert a Perl \"\" double-quoted string to '' single-quotes.

I would find the opposite conversion more often useful...

...
>     __\"\"   ->  __('')
>     N__\"\"  ->  N__('')

> Parens are added for __ and N__ because __'' doesn't work, a
> quote there is the old-style package name separator, it must be
> __('').

Do not know: would not SPACE (instead of parens) be a better alternative?

> Control characters in your sources probably aren't a great idea,
> but at least it gives a conversion.  However remember Emacs will
> in fact save a newline in the buffer as CRLF or CR under DOS or
> Mac coding systems.

I think this should not be relevant (unless with very old version of Perl...)

Thanks,
Ilya
_______________________________________________
gnu-emacs-sources mailing list
gnu-emacs-sources@...
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Re: perl-quote.el v.1

by Kevin Ryde-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ilya Zakharevich <nospam-abuse@...> writes:
>
> I would find the opposite conversion more often useful...

It's there too :).  Incidentally even when there's no backslashing to
de-mangle I quite like having the two quotes changed in one keystroke.

>> Parens are added for __ and N__ because __'' doesn't work, a
>> quote there is the old-style package name separator, it must be
>> __('').
>
> Do not know: would not SPACE (instead of parens) be a better alternative?

Personal preference no doubt :).  When I started it I think I found
parens clearer, and I don't think I knew __ was prototyped.  N__ might
be prototyped only in the next upcoming Locale::TextDomain, which could
be a compatibility consideration if still using an older one.
_______________________________________________
gnu-emacs-sources mailing list
gnu-emacs-sources@...
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources