> + (with-selected-window w > + (when (functionp window-set-context-function) > > and > > + (with-selected-window w > + (when-let ((context (window-parameter w 'context))) > > would set up a precedence case for the future use of > 'window-set-context-function'. Are you sure that you always want to > select the window in question here or would it suffice to pass the > window as argument to the context function? Ok, let's add the WINDOW argument. This means that most hooks will need to call 'with-selected-window' explicitly. But maybe there will be hooks that don't need to select a window. So here how a bookmark-like default context could look. I'm still not sure whether it's a good idea to enable this by default. #+begin_src emacs-lisp ;; Like ‘bookmark-make-record-default’ (setq-default window-set-context-function (lambda (w) (with-selected-window w `((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 (w context) (with-selected-window w (when-let ((f (alist-get 'front-context-string context))) (search-forward f (point-max) t) (goto-char (match-beginning 0))) (when-let ((r (alist-get 'rear-context-string context))) (search-backward r (point-min) t) (goto-char (match-end 0)))))) #+end_src And here is the patch that at least handles the dired revert.