Questions tagged [save-excursion]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers

`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-...
phoxd's user avatar
  • 231
3 votes
1 answer

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 ‘...
shynur's user avatar
  • 5,288
1 vote
0 answers

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-...
Troy Daniels's user avatar
2 votes
1 answer

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 ...
Tian's user avatar
  • 288
1 vote
1 answer

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 ...
Juan Meleiro's user avatar
1 vote
1 answer

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-...
User12345's user avatar
  • 145
0 votes
1 answer

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 ...
Tohiko's user avatar
  • 1,649
2 votes
1 answer

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 ...
Ugur's user avatar
  • 139
0 votes
2 answers

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 ...
Sati's user avatar
  • 795
2 votes
1 answer

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 ((...
nalzok's user avatar
  • 675
0 votes
1 answer

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 ...
AndrewE's user avatar
  • 70
0 votes
0 answers

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 ...
Gabriele's user avatar
  • 1,554
5 votes
1 answer

(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 (...
jcarpenter2's user avatar
3 votes
2 answers

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 ...
Saddle Point's user avatar
8 votes
2 answers

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 ...
ebpa's user avatar
  • 7,479
5 votes
1 answer

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-...
Tianxiang Xiong's user avatar
11 votes
1 answer

`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 ...
Geradlus_RU's user avatar
3 votes
2 answers

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. ...
Geradlus_RU's user avatar
7 votes
4 answers

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 () "...
Geradlus_RU's user avatar
4 votes
2 answers

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 ...
Andrii Tykhonov's user avatar