Questions tagged [save-excursion]
The save-excursion tag has no usage guidance.
20 questions
0
votes
0
answers
30
views
`run-python` cannot hide *Python* buffer
When running
(defun my/run-python ()
(interactive)
(let ((buf (current-buffer)))
(with-current-buffer buf
(save-mark-and-excursion
(run-python (python-shell-calculate-...
3
votes
1
answer
98
views
Put “save-excursion” Outermost When Using Both “save-excursion” And “save-restriction”
I'm reading Emacs Lisp Intro by Robert J. Chassell.
In 6.1 The ‘save-restriction’ Special Form
when you use both ‘save-excursion’ and
‘save-restriction’, one right after the other, you should use
‘...
1
vote
0
answers
24
views
Does markdown-export have a bad interaction with save-excursion
I am trying to write an idle-timer to export my markdown file whenever I am idle. (I have the output loaded in a Chrome tab which is auto-reloading.)
I tried to do the following:
(defvar my--markdown-...
2
votes
1
answer
105
views
Save excursion not working for dired-find-file-other-window
I wrote this function to basically bring my cursor back to the dired buffer, after opening the file in another window. This is so that I can scroll down the buffer, pressing o to keep previewing the ...
1
vote
1
answer
469
views
Why does this function (that uses save-excursion) leave me at another buffer [duplicate]
I'm trying to write a command that allows me to search for an org-mode entry and inserts a link to it at point (using its id). Here's the code:
(defun org-link-to-entry ()
(interactive)
(let ...
1
vote
1
answer
39
views
Why does point move after executing this function from keybinding
I have the following line in my init.el:
(define-key
org-mode-map
(kbd "C-c C-p")
(lambda () (interactive) (org-publish-project "publish-website"))
)
The "publish-...
0
votes
1
answer
34
views
Function to undo point excursion
I know that I can use save-excursion to avoid changes to (point), is there a similar function to revert excursion based on the value of BODY. For example:
(revert-excursion BODY)
would revert the ...
2
votes
1
answer
537
views
How to refresh org file programatically
I am using spacemacs-light theme in Emacs and love it.
In my spacemacs-light theme, some org-files open with bullets not hidden though. In those cases I go to the top of the file and hit C-c C-c to ...
0
votes
2
answers
51
views
How to deal with unwanted cursor movement during logic test
I have a function that tests if another nested pair of parenthesis exits or not.
(defun next-pair-exists-in (func)
"Check if inner or outer pair exists.
Function employs `up-list` or `down-list` as ...
2
votes
1
answer
161
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
1
answer
144
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
0
answers
45
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
1
answer
222
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
2
answers
201
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 ...
8
votes
2
answers
2k
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 ...
5
votes
1
answer
196
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-...
11
votes
1
answer
940
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 ...
3
votes
2
answers
1k
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.
...
7
votes
4
answers
3k
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 ()
"...
4
votes
2
answers
2k
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 ...