unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Leo <sdl.web@gmail.com>
Subject: Re: Something like read-file-into-string needed
Date: Fri, 05 Jan 2007 20:06:39 +0000	[thread overview]
Message-ID: <m2ps9tb5m8.fsf@sl392.st-edmunds.cam.ac.uk> (raw)
In-Reply-To: 1168023456.119091.38300@51g2000cwl.googlegroups.com

* Haws (2007-01-05 10:57 -0800) said:
  ^^^^
> Hello everyone!
>
> I've been trying out the snippet.el package which lets you insert
> templates nicely.  But now I have a "big" template (like 100 lines)
> that I don't want to put inline in my lisp function.  Instead, I'd
> like to have it in a file, and read this file contents into a
> string.  Once in a string, I could use the regular command,
> snippet-insert, to insert my template.  I've found no way to do that
> (only to insert the file into a buffer, which doesn't solve my
> problem.)
>
> Any tips, ideas? 
>
> Thanks in advance,
>
> Hugo

(defun read-file-into-string (file)
  (interactive "f")
  (with-temp-buffer
    (insert-file-contents file)
    (buffer-string)))

-- 
Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)

  reply	other threads:[~2007-01-05 20:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-05 18:57 Something like read-file-into-string needed haws
2007-01-05 20:06 ` Leo [this message]
     [not found] ` <mailman.2789.1168027612.2155.help-gnu-emacs@gnu.org>
2007-01-05 20:41   ` haws

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ps9tb5m8.fsf@sl392.st-edmunds.cam.ac.uk \
    --to=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).