Skip to content

Commit

Permalink
Fix toggle-maximize-buffer
Browse files Browse the repository at this point in the history
- Use high level function window-configuration-to-register. Using
set-register causes the error wrong-type-argument integer-or-marker-p
when we later want to jump to the register.

- Check if the register actually has a window configuration before
jumping to it. Otherwise error happens because we try jump to non-existent
window configuration.

- Add key bindings.
  • Loading branch information
Tu Do authored and syl20bnr committed May 28, 2015
1 parent 33e439e commit 4136536
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spacemacs/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ the current state and point position."
(defun toggle-maximize-buffer ()
"Maximize buffer"
(interactive)
(if (= 1 (length (window-list)))
(if (and (= 1 (length (window-list)))
(assoc'_ register-alist))
(jump-to-register '_)
(progn
(set-register '_ (list (current-window-configuration)))
(window-configuration-to-register '_)
(delete-other-windows))))

(defun toggle-maximize-centered-buffer ()
Expand Down
6 changes: 6 additions & 0 deletions spacemacs/keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
(setq echo-keystrokes 0.02)
;; auto-indent on RET
(define-key global-map (kbd "RET") 'newline-and-indent)

;; improve delete-other-windows
(define-key global-map (kbd "C-x 1") 'toggle-maximize-buffer)
(define-key evil-window-map (kbd "o") 'toggle-maximize-buffer)
(define-key evil-window-map (kbd "C-o") 'toggle-maximize-buffer)

;; alternate binding to search next occurrence with isearch without
;; exiting isearch
(define-key isearch-mode-map (kbd "S-<return>") 'isearch-repeat-forward)
Expand Down

0 comments on commit 4136536

Please sign in to comment.