I think we should add to the documentation that buffer local values for `switch-to-buffer-obey-display-actions' and `switch-to-buffer-preserve-window-point' won't work as user would expect.
The problem with their buffer local values is that they are used for buffer logic *before* buffer is set as current, see `switch-to-buffer'. We should either use `(buffer-local-value NAME buffer)' to get their values in `switch-to-buffer', or add to the documentation that they should not have buffer local values.
Here is code snippet to trigger unexpected behaviour:
;; Switch to scratch and eval
(progn
(setq switch-to-buffer-preserve-window-point t)
(with-current-buffer (get-buffer-create "pwp")
(setq-local switch-to-buffer-preserve-window-point nil)
(insert "asnoteh asoensnaot heusnatoeh usanotehu aeosntuhaoe")
(point))
(switch-to-buffer "pwp")
(switch-to-other-buffer 1)
(with-current-buffer "pwp"
(goto-char 10)
(point))
(switch-to-buffer "pwp")
;; Expecting point to be at 10 position, but it remains at the end
;; of the line
)
What do you think?
Thanks