persp-mode.el icon indicating copy to clipboard operation
persp-mode.el copied to clipboard

The point (cursor) position is saved?

Open rieje opened this issue 7 years ago • 2 comments

When a perspective is restored, the point (cursor) position is saved--is this true? I don't want it to be saved and let save-place handle that instead. I disabled save-place and removed its history file and found that with persp-mode enabled, the cursor position is saved. With it commented out, the cursor position is not.

How can I disable cursor position being saved?

Much appreciated.

rieje avatar May 19 '18 17:05 rieje

When a perspective is restored, the point (cursor) position is saved--is this true?

Yes, this is true. It's saved/restored by emacs' window-state-get/put functions.

However you can try to reset positions after they were restored:

(defun persp-reset-buffer-positions-after-init (file phash &rest _args)
  (when (and (eq phash *persp-hash*)
             (string= file (concat (or (file-name-directory fname)
                                       (expand-file-name persp-save-dir))
                                   (file-name-nondirectory fname))))

    (unless save-place-mode
      (dolist (b (buffer-list))
        (with-current-buffer b (beginning-of-buffer))))
    (remove-hook 'persp-after-load-state-functions
                 #'persp-reset-buffer-positions-after-init)))

(add-hook 'persp-after-load-state-functions
          #'persp-reset-buffer-positions-after-init)

Bad-ptr avatar May 26 '18 18:05 Bad-ptr

Doesn't seem to work--does it work for you? I removed save-place and the saved perspectives files and it still restores the cursor to what it was previously instead of resetting it.

rieje avatar Jun 15 '18 22:06 rieje