>> ;; set-window-configuration does not restore the value of >> ;; point in the current buffer, so restore it separately. >> (when (and (markerp wc-point) >> (marker-buffer wc-point) >> ;; FIXME: After dired-revert, marker relocates to 1. >> ;; window-configuration restores point to global point >> ;; in this dired buffer, not to its window point, >> ;; but this is slightly better than 1. >> ;; Maybe better to save dired-filename in each window? >> (not (eq 1 (marker-position wc-point)))) >> (goto-char wc-point)) >> >> Please note that this bug report is related to FIXME above. >> >> So a possible solution is also to save more context information >> like dired-filename, and then restore it using dired-goto-file. > > We obviously then should strive for a solution that stores any kind of > information via a hook in an alist of entries, one for each window in a > buffer local way, and one global entry for the frame itself. Here is the patch that stores any kind of information via a hook, one for each window in a buffer local way. Currently only dired positions for the revert case are supported. But also I tried to save context of any buffer in a bookmark way, and this works nicely, and correctly restores old positions even from window states from the desktop: #+begin_src emacs-lisp ;; Like ‘bookmark-make-record-default’: (setq-default window-set-context-function (lambda () `((front-context-string . ,(buffer-substring-no-properties (point) (min (+ (point) 16) (point-max)))) (rear-context-string . ,(buffer-substring-no-properties (point) (max (- (point) 16) (point-min))))))) ;; Like ‘bookmark-default-handler’: (setq-default window-use-context-function (lambda (context) (when (search-forward (alist-get 'front-context-string context) (point-max) t) (goto-char (match-beginning 0))) (when (search-backward (alist-get 'rear-context-string context) (point-min) t) (goto-char (match-end 0))))) #+end_src