all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Template substitution in Emacs?
@ 2014-11-09 23:15 Marcin Borkowski
  2014-11-10  2:13 ` Eric Abrahamsen
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Marcin Borkowski @ 2014-11-09 23:15 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi there,

assume that I want to insert an (almost) constant string in Emacs
buffer.  For instance, it may be a string of the form

"I am a {my-variable}."

However, I want the "{my-variable}" part to be, well, variable: I want
to substitute the current value of `my-variable' for this.  So that

(setq my-variable "sentence")
(insert (template-substitute "I am a {my-variable}."))

would insert "I am a sentence." at point.

Of course, I could just use (format "I am a %s." my-variable), or even
define a function to do this.  The drawback would be that if the
"template" is a user-customizable thing, then the user would have to
supply %s's and not meaningful names.  What's more, the /order/ of the
substituted strings would be hardcoded in the "template".

Obviously, I could come up with such a function within 10-15 minutes or
so.  But why reinvent the wheel?  Is there anything like this in Emacs?

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



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

end of thread, other threads:[~2014-11-12 19:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09 23:15 Template substitution in Emacs? Marcin Borkowski
2014-11-10  2:13 ` Eric Abrahamsen
2014-11-10  2:16 ` Paul W. Rankin
2014-11-10  4:18 ` Pierre Lorenzon
2014-11-12  3:31 ` Robert Thorpe
2014-11-12 19:58   ` Pierre Lorenzon

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.