Skip to content

Instantly share code, notes, and snippets.

@wilkes
Created December 8, 2008 04:30
Show Gist options
  • Save wilkes/33342 to your computer and use it in GitHub Desktop.
Save wilkes/33342 to your computer and use it in GitHub Desktop.
(defun writeroom ()
"Switches to a WriteRoom-like fullscreen style"
(interactive)
(when (featurep 'aquamacs)
; switch to Garamond 36pt
;; (set-frame-font "-apple-garamond-medium-r-normal--36-360-72-72-m-360-iso10646-1")
(set-frame-font "-apple-monaco-medium-r-normal--14-120-72-72-m-120-mac-roman")
; switch to fullscreen mode
(aquamacs-toggle-full-frame)))
(defun other-window-backwards (&optional n)
"Select Nth previous window"
(interactive "P")
(other-window (- (prefix-numeric-value n))))
(defun scroll-n-lines-ahead (&optional n)
"Scroll ahead N lines (1 by default)"
(interactive "P")
(scroll-up (prefix-numeric-value n)))
(defun scroll-n-lines-behind (&optional n)
"Scroll behind N lines (1 by default)"
(interactive "P")
(scroll-down (prefix-numeric-value n)))
(defun point-to-top ()
"Put point on top line of window."
(interactive)
(move-to-window-line 0))
(defun point-to-bottom ()
"Put point on bottom line of window."
(interactive)
(move-to-window-line -1))
(defun line-to-top ()
"Move current line to top of window"
(interactive)
(recenter 0))
(defun twm-focus-window ()
"assumes the largest window is the focus window"
(get-largest-window))
(defun twm-focus-buffer ()
(window-buffer (twm-focus-window)))
(defun twm-select-focus-window ()
(interactive)
(select-window (twm-focus-window)))
(defun twm-dev-layout ()
(interactive)
(when (featurep 'aquamacs) (aquamacs-toggle-full-frame))
(delete-other-windows)
(split-window-horizontally)
(other-window 1)
(split-window-vertically)
(twm-select-focus-window))
(defun twm-focus-current-buffer ()
(interactive)
(let* ((tmp (twm-focus-buffer)))
(progn
(set-window-buffer (twm-focus-window) (window-buffer))
(set-window-buffer (selected-window) tmp)
(twm-select-focus-window))))
(global-set-key "\M-\S-return" 'aquamacs-toggle-full-frame)
(global-set-key "\C-x\M-f" 'twm-select-focus-window)
(global-set-key "\C-x\M-x" 'twm-focus-current-buffer)
(global-set-key "\C-x\C-n" 'other-window)
(global-set-key "\C-x\C-p" 'other-window-backwards)
(global-set-key "\C-q" 'scroll-n-lines-behind)
(global-set-key "\C-z" 'scroll-n-lines-ahead)
;; rebinding from M-,
(global-set-key "\C-x," 'tag-loops-continue)
(global-set-key "\M-," 'point-to-top)
(global-set-key "\M-." 'point-to-bottom)
(global-set-key "\M-!" 'line-to-top)
(provide 'my-twm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment