unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* elisp substitution
@ 2003-01-18  9:13 matt
  2003-01-18 17:35 ` Friedrich Dominicus
  0 siblings, 1 reply; 4+ messages in thread
From: matt @ 2003-01-18  9:13 UTC (permalink / raw)


I'm just starting to play around with emacs lisp. A quick question. How 
can I manipulate variables in elisp? For instance, I want to take a 
string and add a backslash(escape) to all whitespace. Like in a path like
"c:/Documents and settings/" I want to change it to
"c:/Documents\ and\ Settings/".

Something similar to this in perl: $var =~ s/( )/\\$1/g;

Thanks,

Matt
-- 
Remove the X's to reply directly.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: elisp substitution
  2003-01-18  9:13 elisp substitution matt
@ 2003-01-18 17:35 ` Friedrich Dominicus
  2003-01-18 22:04   ` Christopher J. White
  0 siblings, 1 reply; 4+ messages in thread
From: Friedrich Dominicus @ 2003-01-18 17:35 UTC (permalink / raw)


matt <nwzmattXX@XXnetscape.net> writes:

> I'm just starting to play around with emacs lisp. A quick
> question. How can I manipulate variables in elisp? For instance, I
> want to take a string and add a backslash(escape) to all
> whitespace. Like in a path like
> 
> "c:/Documents and settings/" I want to change it to
> "c:/Documents\ and\ Settings/".
> 
> Something similar to this in perl: $var =~ s/( )/\\$1/g;
\ are unfine in Emacs lisp but here we go
(defvar *str* "c:\\Dokumente und Einstellungen\\")

(replace-in-string *str* (regexp-quote "\\") "/" )
"c:/Dokumente und Einstellungen/"

If I would not use regexp-quote I would have to write 
"\\\\" the so calles scatterd tootpick syndrome ;-)

If you would just have nearly everything else it would be easier
Regards
Friedrich

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: elisp substitution
  2003-01-18 17:35 ` Friedrich Dominicus
@ 2003-01-18 22:04   ` Christopher J. White
  2003-01-18 22:14     ` Jesper Harder
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher J. White @ 2003-01-18 22:04 UTC (permalink / raw)


>>>>> "fd" == Friedrich Dominicus <frido@q-software-solutions.com> writes:

fd> \ are unfine in Emacs lisp but here we go
fd> (defvar *str* "c:\\Dokumente und Einstellungen\\")

fd> (replace-in-string *str* (regexp-quote "\\") "/" )
fd> "c:/Dokumente und Einstellungen/"

'replace-in-string' doesn't seem to be defined  21.2.1...
However, 'dired-replace-in-string' is if you (require 'dired)

...cj

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: elisp substitution
  2003-01-18 22:04   ` Christopher J. White
@ 2003-01-18 22:14     ` Jesper Harder
  0 siblings, 0 replies; 4+ messages in thread
From: Jesper Harder @ 2003-01-18 22:14 UTC (permalink / raw)


chris@grierwhite.com (Christopher J. White) writes:

> 'replace-in-string' doesn't seem to be defined  21.2.1...

It is called `replace-regexp-in-string' in Gnu Emacs 21.x. 
(But `replace-in-string' in XEmacs).

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-18 22:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-18  9:13 elisp substitution matt
2003-01-18 17:35 ` Friedrich Dominicus
2003-01-18 22:04   ` Christopher J. White
2003-01-18 22:14     ` Jesper Harder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).