[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

wmanip.el -- trivial global minor mode for window manipulation



The following message is a courtesy copy of an article
that has been posted to gnu.emacs.sources as well.


;;; wmanip.el --- manipulate windows from the keyboard
;; Copyright (C) Ian Zimmerman, December 2002
;; Terms: GNU General Public License, Version 2

(defvar wmanip-mode nil
  "The global flag for the wmanip minor mode.")

(defun wmanip-mode (&optional arg)
  "Set or toggle the wmanip minor mode.
\\<wmanip-mode-map>  This mode provides a keyboard interface to the window
manipulation commands {enlarge,shrink}-window{,-horizontally} which is
actually usable.  The keybindings for these commands that are built
into Emacs (C-x^, C-x{, C-x}) are terrible because to repeating them
means stretching your hands back and forth over the keyboard.

\\[other-window] - Select the ARG'th different window on this frame.
\\[enlarge-window] - Make current window ARG lines bigger.
\\[shrink-window] - Make current window ARG lines smaller.
\\[enlarge-window-horizontally] - Make current window ARG columns \
wider.
\\[shrink-window-horizontally] - Make current window ARG columns narrower."

  (interactive "P")
  (let ((goal
         (if (null arg) (not wmanip-mode)
           (> (prefix-numeric-value arg) 0))))
    (if (or (and goal wmanip-mode) (and (not goal) (not wmanip-mode))) nil
      (setq wmanip-mode (not (null goal)))
      (force-mode-line-update 'all))))

(defsubst turn-on-wmanip-mode ()
  "Turn on the wmanip minor mode."
  (interactive)
  (wmanip-mode 1))

(defsubst turn-off-wmanip-mode ()
  "Turn off the wmanip minor mode."
  (interactive)
  (wmanip-mode 0))

(or (assq 'wmanip-mode minor-mode-alist)
    (setq minor-mode-alist
          (cons '(wmanip-mode " Wmanip") minor-mode-alist)))

(defvar wmanip-mode-map nil
  "Keymap used in wmanip mode.")
(if wmanip-mode-map
    ()
  (setq wmanip-mode-map (make-sparse-keymap))
  (suppress-keymap wmanip-mode-map)
  (define-key wmanip-mode-map "o" 'other-window)
  (define-key wmanip-mode-map "\M-\e" 'turn-off-wmanip-mode)
  (define-key wmanip-mode-map "/" 'enlarge-window)
  (define-key wmanip-mode-map "\\" 'shrink-window)
  (define-key wmanip-mode-map "[" 'shrink-window-horizontally)
  (define-key wmanip-mode-map "]" 'enlarge-window-horizontally))

(or (assq 'wmanip-mode minor-mode-map-alist)
    (setq minor-mode-map-alist
          (cons (cons 'wmanip-mode wmanip-mode-map) minor-mode-map-alist)))

(provide 'wmanip)

;;; wmanip.el ends here

-- 
Ian Zimmerman, Oakland, California, U.S.A. 
if (sizeof(signed) > sizeof(unsigned) + 4) { delete this; }
GPG: 433BA087  9C0F 194F 203A 63F7 B1B8  6E5A 8CA3 27DB 433B A087



Reply to: