From: Navy Cheng <navych@126.com>
To: "Pascal J. Bourguignon" <pjb@informatimago.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How can I change "buffer" to "string"
Date: Wed, 5 Aug 2015 14:35:20 +0800 [thread overview]
Message-ID: <20150805063520.GA22606@debian> (raw)
In-Reply-To: <87a8u6qo14.fsf@kuiper.lan.informatimago.com>
Sorry for my ambiguous question.
For example, I have a buffer *mybuf*. The buffer contain some lines. such as
1. ...
2. /home/navy/test.c
3. ...
Now, I want to assignment the path in line 2 to a variable, *path*. And I
to (find-file path).
Thank you.
On Wed, Aug 05, 2015 at 07:53:27AM +0200, Pascal J. Bourguignon wrote:
> Navy Cheng <navych@126.com> writes:
>
> > Hi,
> > I want to change one line in a *buffer* to *string*, How can I do that ?
>
> Your question is ambiguous.
>
> Assuming you have a current buffer and a variable bound to a string,
> if you want to replace the line where the point is currently with the
> contents of your string, you could do:
>
> (delete-region (progn (beginning-of-line) (point))
> (progn (end-of-line) (point)))
> (insert string)
>
> For example, to change the first line of the *scratch* buffer, you could
> evaluate:
>
> (let ((string ";; This is a new line for a lisp buffer."))
> (with-current-buffer "*scratch*"
> (goto-line 1)
> (delete-region (progn (beginning-of-line) (point))
> (progn (end-of-line) (point)))
> (insert string)))
>
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
> “The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
next prev parent reply other threads:[~2015-08-05 6:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.7829.1438746287.904.help-gnu-emacs@gnu.org>
2015-08-05 5:53 ` How can I change "buffer" to "string" Pascal J. Bourguignon
2015-08-05 6:35 ` Navy Cheng [this message]
2015-08-05 6:49 ` Chunyang Xu
[not found] ` <mailman.7833.1438756549.904.help-gnu-emacs@gnu.org>
2015-08-05 8:10 ` Pascal J. Bourguignon
2015-08-05 3:44 Navy Cheng
2015-08-05 5:04 ` Ian Zimmerman
2015-08-05 13:34 ` Drew Adams
2015-08-05 14:24 ` Navy Cheng
[not found] ` <mailman.7846.1438784713.904.help-gnu-emacs@gnu.org>
2015-08-05 14:27 ` Rusi
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150805063520.GA22606@debian \
--to=navych@126.com \
--cc=help-gnu-emacs@gnu.org \
--cc=pjb@informatimago.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.
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.