[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: And while we're at it...
From: |
Tassilo Horn |
Subject: |
Re: And while we're at it... |
Date: |
Wed, 01 Dec 2010 12:57:43 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) |
Gary <help-gnu-emacs@garydjones.name> writes:
> 'insert' and friends insert their arguments at the current point. If
> I'm at a different point in the file to where I want to actually
> insert the text?
Then you need to do something like:
(let ((text (compute-text-to-be-inserted)))
(save-excursion
(goto-buffer-position-where-text-should-be-inserted)
(insert text)))
The `save-excursion' will restore the current position after its body
has been executed.
,----[ C-h f save-excursion RET ]
| save-excursion is a special form in `C source code'.
|
| (save-excursion &rest BODY)
|
| Save point, mark, and current buffer; execute BODY; restore those things.
| Executes BODY just like `progn'.
| The values of point, mark and the current buffer are restored
| even in case of abnormal exit (throw or error).
| The state of activation of the mark is also restored.
|
| This construct does not save `deactivate-mark', and therefore
| functions that change the buffer will still cause deactivation
| of the mark at the end of the command. To prevent that, bind
| `deactivate-mark' with `let'.
|
| If you only want to save the current buffer but not point nor mark,
| then just use `save-current-buffer', or even `with-current-buffer'.
`----
Bye,
Tassilo
- Re: And while we're at it...,
Tassilo Horn <=
- Message not available