Bad-ptr / persp-mode.el

named perspectives(set of buffers/window configs) for emacs
400 stars 44 forks source link

The point (cursor) position is saved? #92

Open rieje opened 6 years ago

rieje commented 6 years ago

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.

Bad-ptr commented 6 years ago

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)
rieje commented 6 years ago

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.