Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [save-excursion]

The tag has no usage guidance.

1
vote
1answer
38 views

What's the point of `save-excursion` twice in `copy-to-buffer`?

Here is the official definition of copy-to-buffer in Emacs 26.1 (the doc string part is omitted for brevity) (defun copy-to-buffer (buffer start end) (interactive "BCopy to buffer: \nr") (let ((...
0
votes
1answer
31 views

Save excursion in an Org Agenda buffer?

I have a function that executes save-excursion from within an Org Agenda buffer, but it doesn't return the point to the agenda buffer once the body of the excursion finishes executing. Here is the ...
0
votes
0answers
42 views

Function acts differently when I call it by M-x and when I call it by load-file/library

I've got this function: (defun move-pointer () (interactive) (let ((enable-recursive-minibuffers t)) (read-string "Go to the main buffer, Move cursor where you like. Come back in the ...
5
votes
1answer
117 views

(progn (scroll-up 1) (goto-char 0)) is different from (scroll-up 1) then (goto-char 0)

In any buffer, try to eval-expression the expression (scroll-up 1) and then eval (goto-char 0). The window scrolls up, then point is moved to the beginning of the buffer. Now, try eval-ing (progn (...
3
votes
2answers
95 views

save-excursion does not work with `org-sort-entries`

Say we have a org buffer with content: * top-level heading some text $ # $ denote cursor ** heading 3 ** heading 2 ** heading 1 ** heading 0 Now evaluate (save-excursion (org-sort-entries ...
4
votes
2answers
513 views

save-excursion doesn't restore the currently visible buffer?

From the save-excursion docstring: Save point, mark, and current buffer; execute BODY; restore those things. My understanding was that the restored buffer would again be visible following the ...
4
votes
1answer
118 views

save-excursion and find-function-at-point

The find-function-at-point command finds a function and displays its definition in the other window, while moving point to the other window as well. I'd like to have a version of find-function-at-...
7
votes
1answer
381 views

`looking-back` performance

I have some code using (looking-back … (line-beginning-position)). Doc string of looking-back states that it's better to avoid this function because of slowness. I'm curious will following approach ...
2
votes
2answers
401 views

How to move point to the end of another buffer, using `with-current-buffer` and `goto-char`?

I'm trying to implement «effective append» for log buffer, e.g. if a point is at point-max position then insert text and move point to new point-max, otherwise append text and preserve point position. ...
5
votes
3answers
940 views

select text to end of line, without moving point

I often want to quickly mark everything from point to the end of line, leaving point at the same place. I tried to write simple function for that purpose: (defun mark-from-point-to-end-of-line () "...
3
votes
2answers
773 views

Why save-excursion doesn't save point position?

I have the following code: (defun test-save-excursion () (interactive) (let ((buffer "*test*") (text "Lorem Ipsum is simply dummy text Lorem Ipsum has |been the industry's standard dummy ...