1

Recently I migrated from emacs 25 to 26.1. Before I reached the window behaviour, where I could always open a file at the window at point.

The most simple case to illustrate undesired behaviour: I have two split windows. I am calling find-file (or other alternatives) from the left one, while the new file opens in the right window.

Meanwhile, only ido-find-file works as desired (opens file at the window at point).

I tried find-file/counsel-projectile-find-file/helm-find-file and they all do not open the file in the current window.

I tried to change window-related variables introduced in emacs 26.1; so, relevant emacs config might be here:

(setq pop-up-windows nil
      switch-to-buffer-preserve-window-point nil
      switch-to-visible-buffer nil
      switch-to-buffer-in-dedicated-window t)

Have anybody tackled this issue?

UPDATE (2018-12-04):

In order to achieve the desired behaviour I used el-patch package with the following lines:

(el-patch-defun find-file (filename &optional wildcards)
  (interactive
   (find-file-read-args "Find file: "
                        (confirm-nonexistent-file-or-buffer)))
  (let ((value (find-file-noselect filename nil nil wildcards)))
    (if (listp value)
      (mapcar (el-patch-swap 'pop-to-buffer-same-window 'switch-to-buffer) (nreverse value))
      ((el-patch-swap pop-to-buffer-same-window switch-to-buffer) value))))
  • Thank you so much! I've been struggling with this for a long time, and the patched find-file is finally a working solution. – Petri Lehtinen Jan 3 at 5:28

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.