1

I have been using the following function to maximize and unmaximize a window for two years now.

(defun toggle-maximize-buffer () "Toggle maximize buffer"
  (interactive)
  (if (= 1 (length (window-list)))
    (set-window-configuration my-saved-window-configuration)
    (progn
      (setq my-saved-window-configuration (current-window-configuration))
      (delete-other-windows))))

I have it bound to:

(define-key my-keys-minor-mode-map (kbd "C-M-u") 'toggle-maximize-buffer)

It always worked great, but today, after upgrading to the latest version of Emacs in OS X:

brew install emacs --HEAD --use-git-head --cocoa --with-gnutls --with-rsvg --with-imagemagick

this function stopped working properly when invoking it from a buffer running M-x ansi-term. More specifically, it works, but it moves cursor in my buffer whenever I do C-M-u RET. It happens regardless weather I am in character or line-mode in the ansi-term buffer.

The problem does not happen in any other type of buffer. Why am I having this problem, and what I can do about it?

In case it matters, here is the specific version I am using

GNU Emacs 25.0.50.1 (x86_64-apple-darwin14.1.0, NS appkit-1344.72 Version 10.10.2 (Build 14C1514))

Could this be a bug? Or is it perhaps a problem with my configuration?

  • current-window-configuration does not save the point in the current buffer. For what ever reason it stopped working, maybe that's your solution (i.e. additionally save and restore it). – politza Mar 30 '15 at 23:14
  • Thanks @politza That makes perfect sense! Any thoughts on how to modify the function to also store it? – Amelio Vazquez-Reina Mar 30 '15 at 23:25
2

Saving the last value of (point) and restoring it with goto-char should do the trick:

(defun toggle-maximize-buffer ()
  "Toggle maximize buffer"
  (interactive)
  (if (= 1 (length (window-list)))
      (progn
        (set-window-configuration my-saved-window-configuration)
        (goto-char my-saved-point))
    (setq my-saved-window-configuration (current-window-configuration)
          my-saved-point (point))
    (delete-other-windows)))

However this behaviour sounds like a bug to me. I'd check what the latest version of Emacs is that doesn't exhibit it and include that additionally to the other information in a M-x report-emacs-bug mail.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.