summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2013-02-19 14:35:26 (GMT)
committer Jaromil <jaromil@dyne.org>2013-02-19 14:35:45 (GMT)
commit7ccabcbc2c072383bb6e19e4e050214d0ac1ba8c (patch)
treeb3c5dcb6496f7141e20cd5697556aa1c7952529a
parent28fcafaa7a70303bc888148610d3185fd3983582 (diff)
frame zoom, better keybindings and fixes on osx
-rw-r--r--elisp/autoload.el3
-rw-r--r--elisp/autorg.el28
-rw-r--r--elisp/frame-cmds.el1634
-rw-r--r--elisp/frame-fns.el314
-rw-r--r--elisp/grammar.el396
-rw-r--r--elisp/keymap.el7
-rw-r--r--elisp/osx.el18
-rw-r--r--elisp/zoom-frm.el310
-rwxr-xr-xmac/AutOrg.command11
9 files changed, 2712 insertions, 9 deletions
diff --git a/elisp/autoload.el b/elisp/autoload.el
index 52a519f..efcb1de 100644
--- a/elisp/autoload.el
+++ b/elisp/autoload.el
@@ -6,6 +6,9 @@
;; local emacs extensions
(add-to-list 'load-path "~/.emacs.d")
+;; generic key settings
+(require 'keymap)
+
;; word count
(autoload 'word-count-mode "word-count"
"Minor mode to count words." t nil)
diff --git a/elisp/autorg.el b/elisp/autorg.el
index a598231..5379ac1 100644
--- a/elisp/autorg.el
+++ b/elisp/autorg.el
@@ -4,9 +4,31 @@
(provide 'autorg)
+; load generic keymaps
+(require 'keymap)
+
; remember extension
(require 'remember)
+; flyspell extension
+(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
+
+; aspell dictionary list
+; (require 'dictionaries)
+
+; grammar parser
+(require 'grammar)
+
+; frame zooming
+(require 'zoom-frm)
+(global-set-key (if (boundp 'mouse-wheel-down-event) ; Emacs 22+
+ (vector (list 'control mouse-wheel-down-event))
+ [C-mouse-wheel]) ; Emacs 20, 21
+ 'zoom-in)
+(when (boundp 'mouse-wheel-up-event) ; Emacs 22+
+ (global-set-key (vector (list 'control mouse-wheel-up-event))
+ 'zoom-out))
+
; load org-mode first
(add-to-list 'load-path (concat AutOrgRes "/org-mode/lisp"))
(add-to-list 'load-path (concat AutOrgRes "/org-mode/contrib/lisp"))
@@ -114,7 +136,7 @@ org-crypt org-remember org-agenda)))
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
-
+ '(ispell-library-directory (concat AutOrgRes "/dict"))
'(browse-url-firefox-program "open")
'(column-number-mode t)
'(keyboard-coding-system (quote mule-utf-8))
@@ -217,7 +239,7 @@ org-crypt org-remember org-agenda)))
; load color-themes extension
(require 'color-theme)
(color-theme-initialize)
-(color-theme-emacs-nw)
+(color-theme-classic)
; (color-theme-gray30)
; (color-theme-matrix)
; (color-theme-blippblopp)
@@ -225,7 +247,7 @@ org-crypt org-remember org-agenda)))
;; set our favourite: Anonymous!
(set-face-font
-'default "-*-AnonymousPro-normal-normal-normal-*-13-*-*-*-*-*-*")
+'default "-*-Inconsolata-normal-normal-normal-*-18-*-*-*-*-*-*")
; transparency (thanks dreamer!)
(set-frame-parameter (selected-frame) 'alpha '(95 50))
diff --git a/elisp/frame-cmds.el b/elisp/frame-cmds.el
new file mode 100644
index 0000000..f14f4e4
--- /dev/null
+++ b/elisp/frame-cmds.el
@@ -0,0 +1,1634 @@
+;;; frame-cmds.el --- Frame and window commands (interactive functions).
+;;
+;; Filename: frame-cmds.el
+;; Description: Frame and window commands (interactive functions).
+;; Author: Drew Adams
+;; Maintainer: Drew Adams
+;; Copyright (C) 1996-2013, Drew Adams, all rights reserved.
+;; Created: Tue Mar 5 16:30:45 1996
+;; Version: 21.0
+;; Last-Updated: Wed Feb 6 14:40:30 2013 (-0800)
+;; By: dradams
+;; Update #: 2705
+;; URL: http://www.emacswiki.org/frame-cmds.el
+;; Doc URL: http://emacswiki.org/FrameModes
+;; Doc URL: http://www.emacswiki.org/OneOnOneEmacs
+;; Doc URL: http://www.emacswiki.org/Frame_Tiling_Commands
+;; Keywords: internal, extensions, mouse, frames, windows, convenience
+;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x
+;;
+;; Features that might be required by this library:
+;;
+;; `avoid', `frame-fns', `misc-fns', `strings', `thingatpt',
+;; `thingatpt+'.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; Frame and window commands (interactive functions).
+;;
+;;
+;; Summary:
+;;
+;; Load this library from your init file (~/.emacs or _emacs).
+;; Add the suggested key bindings (below) to your init file.
+;; Use `M-up|down|left|right' to move frames around incrementally.
+;; Use `C-S-v', `M-S-v', `C-S-next', `C-S-prior' to move frames to screen edges.
+;; Use `C-M-up|down|left|right' to resize frames incrementally.
+;; Use `C-M-z' or `C-x C-z' to iconify/hide all frames.
+;; Use `C-M-z' in a lone frame to restore all frames.
+;; Use `C-mouse-1' in the minibuffer to restore all frames.
+;; Use `C-mouse-1' in Dired to mark/unmark a file.
+;; Use `C-mouse-3' on the mode line to remove window from frame.
+;; Use `tile-frames-horizontally', `-vertically' to tile frames.
+;; Use `C-x o' to select `other-window' or `other-frame'.
+;;
+;; Commands to incrementally resize frames are `enlarge-frame' and
+;; `enlarge-frame-horizontally'. Sarir Khamsi
+;; [sarir.khamsi@raytheon.com] originally wrote `enlarge-frame',
+;; which he called `sk-grow-frame'.
+;;
+;; Note on saving changes made with the commands defined here:
+;;
+;; Some of the commands defined here change frame properties.
+;; You can save any changes you have made, by using Customize.
+;; To visit a Customize buffer of all unsaved changes you have
+;; made, use command `customize-customized'.
+;;
+;; Frame parameter changes, such as background color, can be saved
+;; for future use by all frames or all frames of a certain
+;; kind. For that, you must change the frame parameters of the
+;; correponding frame-alist variable.
+;;
+;; There is no single variable for saving changes to parameters of
+;; the current frame. Instead, there are several different
+;; frame-alist variables, which you can use to define different
+;; kinds of frames. These include: `default-frame-alist',
+;; `initial-frame-alist', and `special-display-frame-alist'. The
+;; complete list of such frame alist variables is available using
+;; function `frame-alist-var-names', defined here.
+;;
+;; Example: Suppose you change the background color of a frame and
+;; want to make that the default background color for new frames in
+;; the future. You will need to update the value of variable
+;; `default-frame-alist' to use the `background-color' parameter
+;; setting of the changed frame.
+;;
+;; You can easily copy one or all parameter values from any given
+;; frame to any frame alist (such as `default-frame-alist'), by
+;; using the commands `set-frame-alist-parameter-from-frame' and
+;; `set-all-frame-alist-parameters-from-frame'. Those commands are
+;; defined here.
+;;
+;; NOTE: If you also use library `fit-frame.el', and you are on MS
+;; Windows, then load that library before `frame-cmds.el'. The
+;; commands `maximize-frame' and `restore-frame' defined here are
+;; more general and non-Windows-specific than the commands of the
+;; same name defined in `fit-frame.el'.
+;;
+;;
+;; User options defined here:
+;;
+;; `available-screen-pixel-bounds', `enlarge-font-tries',
+;; `frame-config-register', `frame-parameters-to-exclude',
+;; `move-frame-wrap-within-display-flag'
+;; `rename-frame-when-iconify-flag', `show-hide-show-function',
+;; `window-mgr-title-bar-pixel-height'.
+;;
+;; Commands defined here:
+;;
+;; `delete-1-window-frames-on', `delete/iconify-window',
+;; `delete/iconify-windows-on', `delete-other-frames',
+;; `delete-windows-for', `enlarge-font', `enlarge-frame',
+;; `enlarge-frame-horizontally', `hide-everything', `hide-frame',
+;; `iconify-everything', `iconify/map-frame',
+;; `jump-to-frame-config-register', `maximize-frame',
+;; `maximize-frame-horizontally', `maximize-frame-vertically',
+;; `mouse-iconify/map-frame', `mouse-remove-window',
+;; `mouse-show-hide-mark-unmark', `move-frame-down',
+;; `move-frame-left', `move-frame-right',
+;; `move-frame-to-screen-bottom', `move-frame-to-screen-left',
+;; `move-frame-to-screen-right', `move-frame-to-screen-top',
+;; `move-frame-up', `other-window-or-frame', `remove-window',
+;; `remove-windows-on', `rename-frame',
+;; `rename-non-minibuffer-frame', `restore-frame',
+;; `restore-frame-horizontally', `restore-frame-vertically',
+;; `save-frame-config',
+;; `set-all-frame-alist-parameters-from-frame',
+;; `set-frame-alist-parameter-from-frame', `show-*Help*-buffer',
+;; `show-a-frame-on', `show-buffer-menu', `show-frame',
+;; `show-hide', `shrink-frame', `shrink-frame-horizontally',
+;; `tell-customize-var-has-changed', `tile-frames',
+;; `tile-frames-horizontally', `tile-frames-vertically',
+;; `toggle-max-frame', `toggle-max-frame-horizontally',
+;; `toggle-max-frame-vertically'.
+;;
+;; Non-interactive functions defined here:
+;;
+;; `assq-delete-all' (Emacs 20), `available-screen-pixel-bounds',
+;; `available-screen-pixel-height', `available-screen-pixel-width',
+;; `butlast' (Emacs 20), `effective-screen-pixel-bounds',
+;; `enlarged-font-name', `frame-alist-var-names',
+;; `frame-cmds-set-difference', `frame-iconified-p',
+;; `frame-parameter-names', `nbutlast' (Emacs 20),
+;; `new-frame-position', `read-args-for-tile-frames',
+;; `read-buffer-for-delete-windows', `smart-tool-bar-pixel-height'.
+;;
+;;
+;;
+;; ***** NOTE: The following EMACS PRIMITIVES have been REDEFINED HERE:
+;;
+;; `delete-window' - If only one window in frame, `delete-frame'.
+;; `delete-windows-on' -
+;; 1) Reads buffer differently. Only buffers showing windows are candidates.
+;; 2) Calls `delete-window', so this also deletes frames where
+;; window showing the BUFFER is the only window.
+;; (That's true also for vanilla Emacs 23+, but not before.)
+;;
+;;
+;; Suggested key bindings:
+;;
+;; (global-set-key [(meta up)] 'move-frame-up)
+;; (global-set-key [(meta down)] 'move-frame-down)
+;; (global-set-key [(meta left)] 'move-frame-left)
+;; (global-set-key [(meta right)] 'move-frame-right)
+;; (global-set-key [(meta shift ?v)] 'move-frame-to-screen-top) ; like `M-v'
+;; (global-set-key [(control shift ?v)] 'move-frame-to-screen-bottom) ; like `C-v'
+;; (global-set-key [(control shift prior)] 'move-frame-to-screen-left) ; like `C-prior'
+;; (global-set-key [(control shift next)] 'move-frame-to-screen-right) ; like `C-next'
+;; (global-set-key [(control meta down)] 'enlarge-frame)
+;; (global-set-key [(control meta right)] 'enlarge-frame-horizontally)
+;; (global-set-key [(control meta up)] 'shrink-frame)
+;; (global-set-key [(control meta left)] 'shrink-frame-horizontally)
+;; (global-set-key [(control ?x) (control ?z)] 'iconify-everything)
+;; (global-set-key [vertical-line S-down-mouse-1] 'iconify-everything)
+;; (global-set-key [(control ?z)] 'iconify/map-frame)
+;; (global-set-key [mode-line mouse-3] 'mouse-iconify/map-frame)
+;; (global-set-key [mode-line C-mouse-3] 'mouse-remove-window)
+;; (global-set-key [(control meta ?z)] 'show-hide)
+;; (global-set-key [vertical-line C-down-mouse-1] 'show-hide)
+;; (global-set-key [C-down-mouse-1] 'mouse-show-hide-mark-unmark)
+;; (substitute-key-definition 'delete-window 'remove-window global-map)
+;; (define-key ctl-x-map "o" 'other-window-or-frame)
+;; (define-key ctl-x-4-map "1" 'delete-other-frames)
+;; (define-key ctl-x-5-map "h" 'show-*Help*-buffer)
+;; (substitute-key-definition 'delete-window 'delete-windows-for global-map)
+;; (define-key global-map "\C-xt." 'save-frame-config)
+;; (define-key ctl-x-map "o" 'other-window-or-frame)
+;;
+;; (defalias 'doremi-prefix (make-sparse-keymap))
+;; (defvar doremi-map (symbol-function 'doremi-prefix) "Keymap for Do Re Mi commands.")
+;; (define-key global-map "\C-xt" 'doremi-prefix)
+;; (define-key doremi-map "." 'save-frame-config)
+;;
+;; Customize the menu. Uncomment this to try it out.
+;;
+;; (defvar menu-bar-frames-menu (make-sparse-keymap "Frames"))
+;; (define-key global-map [menu-bar frames]
+;; (cons "Frames" menu-bar-frames-menu)))
+;; (define-key menu-bar-frames-menu [set-all-params-from-frame]
+;; '(menu-item "Set All Frame Parameters from Frame" set-all-frame-alist-parameters-from-frame
+;; :help "Set frame parameters of a frame to their current values in frame"))
+;; (define-key menu-bar-frames-menu [set-params-from-frame]
+;; '(menu-item "Set Frame Parameter from Frame..." set-frame-alist-parameter-from-frame
+;; :help "Set parameter of a frame alist to its current value in frame"))
+;; (define-key menu-bar-frames-menu [separator-frame-1] '("--"))
+;; (define-key menu-bar-frames-menu [tile-frames-vertically]
+;; '(menu-item "Tile Frames Vertically..." tile-frames-vertically
+;; :help "Tile all visible frames vertically"))
+;; (define-key menu-bar-frames-menu [tile-frames-horizontally]
+;; '(menu-item "Tile Frames Horizontally..." tile-frames-horizontally
+;; :help "Tile all visible frames horizontally"))
+;; (define-key menu-bar-frames-menu [separator-frame-2] '("--"))
+;; (define-key menu-bar-frames-menu [toggle-max-frame-vertically]
+;; '(menu-item "Toggle Max Frame Vertically" toggle-max-frame-vertically
+;; :help "Maximize or restore the selected frame vertically"
+;; :enable (frame-parameter nil 'restore-height)))
+;; (define-key menu-bar-frames-menu [toggle-max-frame-horizontally]
+;; '(menu-item "Toggle Max Frame Horizontally" toggle-max-frame-horizontally
+;; :help "Maximize or restore the selected frame horizontally"
+;; :enable (frame-parameter nil 'restore-width)))
+;; (define-key menu-bar-frames-menu [toggle-max-frame]
+;; '(menu-item "Toggle Max Frame" toggle-max-frame
+;; :help "Maximize or restore the selected frame (in both directions)"
+;; :enable (or (frame-parameter nil 'restore-width) (frame-parameter nil 'restore-height))))
+;; (define-key menu-bar-frames-menu [maximize-frame-vertically]
+;; '(menu-item "Maximize Frame Vertically" maximize-frame-vertically
+;; :help "Maximize the selected frame vertically"))
+;; (define-key menu-bar-frames-menu [maximize-frame-horizontally]
+;; '(menu-item "Maximize Frame Horizontally" maximize-frame-horizontally
+;; :help "Maximize the selected frame horizontally"))
+;; (define-key menu-bar-frames-menu [maximize-frame]
+;; '(menu-item "Maximize Frame" maximize-frame
+;; :help "Maximize the selected frame (in both directions)"))
+;; (define-key menu-bar-frames-menu [separator-frame-3] '("--"))
+;; (define-key menu-bar-frames-menu [iconify-everything]
+;; '(menu-item "Iconify All Frames" iconify-everything
+;; :help "Iconify all frames of session at once"))
+;; (define-key menu-bar-frames-menu [show-hide]
+;; '(menu-item "Hide Frames / Show Buffers" show-hide
+;; :help "Show, if only one frame visible; else hide.")))
+;;
+;; (defvar menu-bar-doremi-menu (make-sparse-keymap "Do Re Mi"))
+;; (define-key global-map [menu-bar doremi]
+;; (cons "Do Re Mi" menu-bar-doremi-menu))
+;; (define-key menu-bar-doremi-menu [doremi-font+]
+;; '("Save Frame Configuration" . save-frame-config))
+;;
+;; See also these files for other frame commands:
+;;
+;; `autofit-frame.el' - Automatically fit each frame to its
+;; selected window. Uses `fit-frame.el'.
+;;
+;; `fit-frame.el' - 1) Fit a frame to its selected window.
+;; 2) Incrementally resize a frame.
+;;
+;; `doremi-frm.el' - Incrementally adjust frame properties
+;; using arrow keys and/or mouse wheel.
+;;
+;; `thumb-frm.el' - Shrink frames to a thumbnail size and
+;; restore them again.
+;;
+;; `zoom-frm.el' - Zoom a frame, so that its font becomes
+;; larger or smaller.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Change Log:
+;;
+;; 2013/02/06 dadams
+;; move-frame-(up|down|left|right): Set N to 1 if nil.
+;; 2013/01/17 dadams
+;; Added: move-frame-to-screen-(top|bottom|left|right).
+;; move-frame-(up|down|left|right): Redefined so prefix arg moves increments of char size.
+;; 2012/02/29 dadams
+;; Added, for Emacs 20 only: nbutlast, butlast. To avoid runtime load of cl.el.
+;; Added frame-cmds-set-difference, to avoid runtime load of cl.el.
+;; set-all-frame-alist-parameters-from-frame: Use frame-cmds-set-difference.
+;; 2011/07/25 dadams
+;; save-frame-config: Use fboundp, not featurep.
+;; 2011/01/04 dadams
+;; Removed autoload cookie from non-interactive function.
+;; 2010/10/19 dadams
+;; enlarge-font: Only do frame-update-faces if Emacs 20 (obsolete in 21).
+;; 2010/06/04 dadams
+;; Added: (toggle-max|restore)-frame(-horizontally|-vertically). Thx to Uday Reddy for suggestion.
+;; Renamed max-frame to maximize-frame.
+;; maximize-frame: Save original location & position params for later restoration.
+;; 2010/05/25 dadams
+;; Added: max-frame, maximize-frame-horizontally, maximize-frame-vertically.
+;; 2009/10/02 dadams
+;; delete-windows-on: Return nil. Make BUFFER optional: default is current buffer.
+;; 2009/08/03 dadams
+;; delete-window: Wrap with save-current-buffer. Thx to Larry Denenberg.
+;; 2009/05/17 dadams
+;; Updated to reflect thumb-frm.el name changes.
+;; 2009/01/30 dadams
+;; enlarge-font, enlarged-font-name, enlarge-font-tries:
+;; Removed temporary workaround - Emacs 23 bug #119 was finally fixed.
+;; 2009/01/01 dadams
+;; Removed compile-time require of doremi-frm.el to avoid infinite recursion.
+;; 2008/12/13 dadams
+;; enlarge-font: Redefined for Emacs 23 - just use :height face attribute.
+;; enlarge-font-tries, enlarged-font-name: Not used for Emacs 23.
+;; 2008/10/31 dadams
+;; Updated frame-parameter-names for Emacs 23.
+;; 2008/07/29 dadams
+;; Option available-screen-pixel-bounds: Use nil as default value.
+;; available-screen-pixel-bounds: Redefined as the code that defined the option's default value.
+;; Added: effective-screen-pixel-bounds - code taken from old available-screen-pixel-bounds,
+;; but also convert frame geom value to numeric.
+;; Everywhere:
+;; Use effective-screen-pixel-bounds in place of available-screen-pixel-bounds function.
+;; Use available-screen-pixel-bounds function instead of option.
+;; available-screen-pixel-(width|height): Added optional INCLUDE-MINI-P arg.
+;; new-frame-position: Call available-screen-pixel-(width|height) with arg.
+;; save-frame-config: push-current-frame-config -> doremi-push-current-frame-config.
+;; Soft-require doremi-frm.el when byte-compile.
+;; 2008/06/02 dadams
+;; Added: available-screen-pixel-bounds (option and function).
+;; tile-frames, available-screen-pixel-(width|height):
+;; Redefined to use available-screen-pixel-bounds. Thx to Nathaniel Cunningham for input.
+;; 2008/05/29 dadams
+;; Fixes for Mac by Nathaniel Cunningham and David Reitter:
+;; window-mgr-title-bar-pixel-height, tile-frames, smart-tool-bar-pixel-height (added).
+;; 2007/12/27 dadams
+;; tile-frames: Restored border calculation, but using only external border.
+;; Renamed window-mgr-*-width to window-mgr-*-height and changed default value from 32 to 27.
+;; 2007/12/20 dadams
+;; Added: frame-extra-pixels(width|height). Use in tile-frames. Thx to David Reitter.
+;; frame-horizontal-extra-pixels: Changed default value from 30 to 32.
+;; 2007/10/11 dadams
+;; Added: assq-delete-all (for Emacs 20).
+;; 2007/09/02 dadams
+;; Added: available-screen-pixel-(width|height). Use in tile-frames, new-frame-position.
+;; 2007/06/12 dadams
+;; tile-frames: Corrected use of fboundp for thumbnail-frame-p.
+;; 2007/05/27 dadams
+;; enlarged-font-name:
+;; Do nothing if null assq of ascii. Not sure what this means, but gets around Emacs 23 bug.
+;; 2006/08/22 dadams
+;; Added: delete-windows-for, read-buffer-for-delete-windows.
+;; delete-windows-on: Use read-buffer-for-delete-windows.
+;; Removed old-delete-windows-on (not used).
+;; 2006/05/30 dadams
+;; delete-windows-on: Return nil if buffer arg is nil. Thanks to Slawomir Nowaczyk.
+;; 2006/01/07 dadams
+;; Added :link for sending bug report.
+;; 2006/01/06 dadams
+;; Renamed group. Added :link.
+;; 2006/01/04 dadams
+;; Added: other-window-or-frame.
+;; 2005/12/29 dadams
+;; mouse-show-hide-mark-unmark: dired-mouse-mark/unmark -> diredp-mouse-mark/unmark.
+;; 2005/12/13 dadams
+;; Added: delete-other-frames.
+;; 2005/11/18 dadams
+;; enlarge-font: Try to increment or decrment further, testing for an existing font.
+;; Added: enlarge-font-tries, enlarged-font-name.
+;; 2005/10/03 dadams
+;; Removed require of icomplete+.el (no longer redefines read-from-minibuffer).
+;; 2005/07/03 dadams
+;; Renamed: args-for-tile-frames to read-args-for-tile-frames.
+;; 2005/06/19 dadams
+;; tile-frames: Don't tile thumbnail frames.
+;; 2005/05/29 dadams
+;; Moved here from frame+.el and fit-frame.el: enlarge-frame*, shrink-frame*.
+;; Added: move-frame-up|down|left|right, move-frame-wrap-within-display-flag,
+;; new-frame-position.
+;; 2005/05/28 dadams
+;; show-a-frame-on: Use another-buffer as default for read-buffer, if available.
+;; 2005/05/15 dadams
+;; Renamed: minibuffer-frame to 1on1-minibuffer-frame.
+;; 2005/05/10 dadams
+;; remove-window: Removed definition; just defalias it to delete-window.
+;; delete-window: (one-window-p) -> (one-window-p t).
+;; set-frame-alist-parameter-from-frame: No longer use destructive fns.
+;; 2005/01/19 dadams
+;; set-all-frame-alist-parameters-from-frame:
+;; Added really-all-p and use frame-parameters-to-exclude.
+;; Added: frame-parameters-to-exclude, tell-customize-var-has-changed.
+;; 2005/01/18 dadams
+;; Added: set-all-frame-alist-parameters-from-frame, set-frame-alist-parameter-from-frame,
+;; frame-alist-var-names, frame-parameter-names.
+;; Added Note on saving changes.
+;; 2005/01/08 dadams
+;; Moved enlarge-font here from doremi-frm.el, where it was called doremi-grow-font.
+;; 2005/01/04 dadams
+;; Added rename-frame-when-iconify-flag.
+;; Use it in iconify-everything, (mouse-)iconify/map-frame.
+;; Added (defgroup frame-cmds).
+;; 2004/12/23 dadams
+;; frame-config-register, show-hide-show-function, window-mgr-title-bar-pixel-width:
+;; Changed defvar to defcustom.
+;; 2004/12/21 dadams
+;; hide-everything, iconify-everything: bind thumbify-instead-of-iconify-flag to nil.
+;; 2004/12/10 dadams
+;; tile-frames: Change 15 to (frame-char-height fr) for scroll-bar-width.
+;; tile-frames-*: Corrected doc strings for non-interactive case.
+;; 2004/12/09 dadams
+;; Changed compile-time require of strings to a soft require.
+;; 2004/10/11 dadams
+;; args-for-tile-frames: Fixed bug when non-existant frame in name history.
+;; tile-frames: show-frame at end (for case where use prefix arg)
+;; 2004/09/11 dadams
+;; Moved to doremi-frm.el: frame-config-ring*, frame-config-wo-parameters,
+;; push-frame-config.
+;; 2004/09/07 dadams
+;; Added: jump-to-frame-config-register, push-frame-config, save-frame-config.
+;; 2004/09/01 dadams
+;; Added: frame-config-register, show-hide-show-function,
+;; jump-to-frame-config-register.
+;; Rewrote to record frame config: iconify-everything, hide-everything.
+;; Rewrote to use show-hide-show-function: show-hide.
+;; 2004/03/22 dadams
+;; Added: tile-frames, tile-frames-vertically, args-for-tile-frames.
+;; Rewrote tile-frames-horizontally to use tile-frames.
+;; 2004/03/19 dadams
+;; Added tile-frames-horizontally.
+;; 2000/11/27 dadams
+;; hide-frame: fixed bug: Added get-a-frame for frame name read.
+;; 2000/09/27 dadams
+;; 1. Added: frame-iconified-p.
+;; 2. remove-window: only make-frame-invisible if not iconified (HACK).
+;; 1999/10/05 dadams
+;; rename-frame: fixed bug if only 1 frame and old-name was a frame.
+;; 1999/08/25 dadams
+;; Added: hide-everything, show-buffer-menu, show-hide.
+;; 1999/03/17 dadams
+;; delete-1-window-frames-on: ensure a buffer object (not a name).
+;; 1996/04/26 dadams
+;; delete/iconify-windows-on, show-a-frame-on: Do nothing if null buffer.
+;; 1996/03/12 dadams
+;; delete/iconify-window: Unless one-window-p, do old-delete-window outside of
+;; save-window-excursion.
+;; 1996/03/08 dadams
+;; 1. delete-windows-on: a. Fixed incorrect interactive spec (bad paren).
+;; b. Second arg FRAME also provided interactively now.
+;; 2. Added: delete/iconify-window, delete/iconify-windows-on.
+;; 1996/02/27 dadams
+;; show-frame: Call make-frame-visible.
+;; 1996/02/09 dadams
+;; Added show-*Help*-buffer.
+;; 1996/01/30 dadams
+;; 1. show-frame: Don't make-frame-visible. Done by raise-frame anyway.
+;; 2. Added show-a-frame-on.
+;; 1996/01/09 dadams
+;; Added delete-windows-on and made it interactive.
+;; 1996/01/08 dadams
+;; Added rename-non-minibuffer-frame. Use in iconify-everything,
+;; iconify/map-frame, mouse-iconify/map-frame.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+(eval-when-compile (require 'cl)) ;; case, incf (plus, for Emacs 20: dolist)
+(require 'frame-fns) ;; frame-geom-value-numeric, frames-on, get-frame-name, get-a-frame, read-frame
+(require 'strings nil t) ;; (no error if not found) read-buffer
+(require 'misc-fns nil t) ;; (no error if not found) another-buffer
+
+;; Don't require even to byte-compile, because doremi-frm.el soft-requires frame-cmds.el
+;; (eval-when-compile (require 'doremi-frm nil t)) ;; (no error if not found)
+;; ;; doremi-push-current-frame-config
+
+;; Not required here, because this library requires `frame-cmds.el': `thumb-frm.el'.
+;; However, `frame-cmds.el' soft-uses `thumfr-thumbnail-frame-p', which is defined
+;; in `thumb-frm.el'.
+
+;; Quiet byte-compiler.
+(defvar mac-tool-bar-display-mode)
+
+;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+;;; USER OPTIONS (VARIABLES) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defgroup Frame-Commands nil
+ "Miscellaneous frame and window commands."
+ :group 'frames
+ :link `(url-link :tag "Send Bug Report"
+ ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
+frame-cmds.el bug: \
+&body=Describe bug here, starting with `emacs -q'. \
+Don't forget to mention your Emacs and library versions."))
+ :link '(url-link :tag "Other Libraries by Drew"
+ "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries")
+ :link '(url-link :tag "Download"
+ "http://www.emacswiki.org/cgi-bin/wiki/frame-cmds.el")
+ :link '(url-link :tag "Description - `delete-window'"
+ "http://www.emacswiki.org/cgi-bin/wiki/FrameModes")
+ :link '(url-link :tag "Description - Frame Renaming"
+ "http://www.emacswiki.org/cgi-bin/wiki/FrameTitle")
+ :link '(url-link :tag "Description - Frame Resizing"
+ "http://www.emacswiki.org/cgi-bin/wiki/Shrink-Wrapping_Frames")
+ :link '(url-link :tag "Description - Frame Customization"
+ "http://www.emacswiki.org/cgi-bin/wiki/CustomizingAndSaving")
+ :link '(url-link :tag "Description - Frame Tiling"
+ "http://www.emacswiki.org/cgi-bin/wiki/Frame_Tiling_Commands")
+ :link '(url-link :tag "Description - General"
+ "http://www.emacswiki.org/cgi-bin/wiki/FrameModes")
+ :link '(emacs-commentary-link :tag "Commentary" "frame-cmds")
+ )
+
+(defcustom rename-frame-when-iconify-flag t
+ "*Non-nil means frames are renamed when iconified.
+The new name is the name of the current buffer."
+ :type 'boolean :group 'Frame-Commands)
+
+(defcustom frame-config-register ?\C-l ; Control-L is the name of the register.
+ "*Character naming register for saving/restoring frame configuration."
+ :type 'character :group 'Frame-Commands)
+
+(defcustom show-hide-show-function 'jump-to-frame-config-register
+ "*Function to show stuff that is hidden or iconified by `show-hide'.
+Candidates include `jump-to-frame-config-register' and `show-buffer-menu'."
+ :type '(choice (const :tag "Restore frame configuration" jump-to-frame-config-register)
+ (function :tag "Another function"))
+ :group 'Frame-Commands)
+
+(defcustom window-mgr-title-bar-pixel-height (if (eq window-system 'mac) 22 27)
+ "*Height of frame title bar provided by the window manager, in pixels.
+You might alternatively call this constant the title-bar \"width\" or
+\"thickness\". There is no way for Emacs to determine this, so you
+must set it."
+ :type 'integer :group 'Frame-Commands)
+
+(defcustom enlarge-font-tries 100
+ "*Number of times to try to change font-size, when looking for a font.
+The font-size portion of a font name is incremented or decremented at
+most this many times, before giving up and raising an error."
+ :type 'integer :group 'Frame-Commands)
+
+(defcustom frame-parameters-to-exclude '((window-id) (buffer-list) (name) (title) (icon-name))
+ "*Parameters to exclude in `set-all-frame-alist-parameters-from-frame'.
+An alist of the same form as that returned by `frame-parameters'.
+The cdr of each alist element is ignored.
+These frame parameters are not copied to the target alist."
+ :type '(repeat (cons symbol sexp)) :group 'Frame-Commands)
+
+(defcustom move-frame-wrap-within-display-flag t
+ "*Non-nil means wrap frame movements within the display.
+Commands `move-frame-up', `move-frame-down', `move-frame-left', and
+`move-frame-right' then move the frame back onto the display when it
+moves off of it.
+If nil, you can move the frame as far off the display as you like."
+ :type 'boolean :group 'Frame-Commands)
+
+(defcustom available-screen-pixel-bounds nil
+ "*Upper left and lower right of available screen space for tiling frames.
+Integer list: (x0 y0 x1 y1), where (x0, y0) is the upper left position
+and (x1, y1) is the lower right position. Coordinates are in pixels,
+measured from the screen absolute origin, (0, 0), at the upper left.
+
+If this is nil, then the available space is calculated. That should
+give good results in most cases."
+ :type '(list
+ (integer :tag "X0 (upper left) - pixels from screen left")
+ (integer :tag "Y0 (upper left) - pixels from screen top")
+ (integer :tag "X1 (lower right) - pixels from screen left" )
+ (integer :tag "Y1 (lower right) - pixels from screen top"))
+ :group 'Frame-Commands)
+
+
+
+;;; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;###autoload
+(defun save-frame-config ()
+ "Save current frame configuration.
+You can restore it with \\[jump-to-frame-config-register]."
+ (interactive)
+ (frame-configuration-to-register frame-config-register)
+ (when (fboundp 'doremi-push-current-frame-config) ; In `doremi-frm.el'.
+ (doremi-push-current-frame-config))
+ (message
+ (substitute-command-keys
+ (if (fboundp 'doremi-frame-configs) ; In `doremi-frm.el'.
+ (format "Use `\\[jump-to-frame-config-register]' (`C-x r j %c') or \
+`\\[doremi-frame-configs]' to restore frames as before (undo)." frame-config-register)
+ "Use `\\[jump-to-frame-config-register]' to restore frames as before (undo)."))))
+
+;;;###autoload
+(defun jump-to-frame-config-register ()
+ "Restore frame configuration saved in `frame-config-register'."
+ (interactive)
+ (jump-to-register frame-config-register))
+
+;;;###autoload
+(defun iconify-everything ()
+ "Iconify all frames of session at once.
+Remembers frame configuration in register `C-l' (Control-L).
+To restore this frame configuration, use `\\[jump-to-register] C-l'."
+ (interactive)
+ (frame-configuration-to-register frame-config-register)
+ (let ((thumfr-thumbify-dont-iconify-flag nil)) ; Defined in `thumb-frm.el'.
+ (dolist (frame (visible-frame-list))
+ (when rename-frame-when-iconify-flag (rename-non-minibuffer-frame frame))
+ (iconify-frame frame))))
+
+;;;###autoload
+(defun hide-everything ()
+ "Hide all frames of session at once.
+Iconify minibuffer frame; make all others invisible.
+Remembers frame configuration in register `C-l' (Control-L).
+To restore this frame configuration, use `\\[jump-to-register] C-l'."
+ (interactive)
+ (frame-configuration-to-register frame-config-register)
+ (let ((minibuf-frame-name
+ (and (boundp '1on1-minibuffer-frame)
+ (cdr (assq 'name (frame-parameters 1on1-minibuffer-frame)))))
+ (thumfr-thumbify-dont-iconify-flag nil)) ; Defined in `thumb-frm.el'.
+ (dolist (frame (frame-list))
+ (if (eq minibuf-frame-name (cdr (assq 'name (frame-parameters frame))))
+ (iconify-frame frame) ; minibuffer frame
+ (make-frame-invisible frame t))))) ; other frames
+
+;;;###autoload
+(defun show-hide ()
+ "1 frame visible: `show-hide-show-function'; else: `hide-everything'.
+This acts as a toggle between showing all frames and showing only an
+iconified minibuffer frame."
+ (interactive)
+ (if (< (length (visible-frame-list)) 2)
+ (funcall show-hide-show-function)
+ (hide-everything)))
+
+;;;###autoload
+(defun show-buffer-menu ()
+ "Call `buffer-menu' after making all frames visible.
+Useful after using `hide-everything' because of a Windows bug that
+doesn't let you display frames that have been made visible after
+being made invisible."
+ (interactive)
+ (let ((minibuf-frame-name
+ (and (boundp '1on1-minibuffer-frame)
+ (cdr (assq 'name (frame-parameters 1on1-minibuffer-frame))))))
+ (dolist (frame (frame-list))
+ (if (eq minibuf-frame-name
+ (cdr (assq 'name (frame-parameters frame))))
+ (make-frame-visible frame) ; minibuffer frame
+ (iconify-frame frame))) ; other frames
+ (buffer-menu)))
+
+;;;###autoload
+(defun mouse-show-hide-mark-unmark (event)
+ "In minibuffer: `show-hide'. In dired: mark/unmark; else: buffer menu."
+ (interactive "e")
+ (if (window-minibuffer-p (posn-window (event-start event)))
+ (show-hide)
+ (or (and (memq major-mode '(dired-mode vc-dired-mode))
+ (fboundp 'diredp-mouse-mark/unmark)
+ (diredp-mouse-mark/unmark event)) ; Return nil if not on a file or dir.
+ (mouse-buffer-menu event))))
+
+;;;###autoload
+(defun iconify/map-frame (&optional iconify-all)
+ "Iconify selected frame if now mapped. Map it if now iconified.
+With non-nil prefix arg ICONIFY-ALL, iconify all visible frames."
+ (interactive "P")
+ (if iconify-all
+ (iconify-everything)
+ (when rename-frame-when-iconify-flag (rename-non-minibuffer-frame))
+ (iconify-or-deiconify-frame)))
+
+;;;###autoload
+(defun mouse-iconify/map-frame (event)
+ "Iconify frame clicked on, if now mapped. Map it if now iconified."
+ (interactive "e")
+ (select-window (posn-window (event-start event)))
+ (when rename-frame-when-iconify-flag (rename-non-minibuffer-frame))
+ (iconify-or-deiconify-frame))
+
+
+(or (fboundp 'old-delete-window)
+ (fset 'old-delete-window (symbol-function 'delete-window)))
+
+
+;; REPLACES ORIGINAL (built-in):
+;; If WINDOW is the only one in its frame, `delete-frame'.
+;;;###autoload
+(defun delete-window (&optional window)
+ "Remove WINDOW from the display. Default is `selected-window'.
+If WINDOW is the only one in its frame, then `delete-frame' too."
+ (interactive)
+ (save-current-buffer
+ (setq window (or window (selected-window)))
+ (select-window window)
+ (if (one-window-p t) (delete-frame) (old-delete-window (selected-window)))))
+
+;;;###autoload
+(defun delete-windows-for (&optional buffer)
+ "`delete-window' or prompt for buffer and delete its windows.
+With no prefix arg, delete the selected window.
+With a prefix arg, prompt for a buffer and delete all windows, on any
+ frame, that show that buffer."
+ (interactive (list (and current-prefix-arg (read-buffer-for-delete-windows))))
+ (if buffer (delete-windows-on buffer) (delete-window)))
+
+
+;; REPLACES ORIGINAL (built-in):
+;; 1) Use `read-buffer' in interactive spec.
+;; 2) Do not raise an error if BUFFER is a string that does not name a buffer.
+;; 3) Call `delete-window', so if you use my `delete-window' then this also deletes
+;; frames where window showing the BUFFER is the only window.
+;;;###autoload
+(defun delete-windows-on (&optional buffer frame)
+ "Delete windows showing BUFFER.
+Optional arg BUFFER defaults to the current buffer.
+
+Optional second arg FRAME controls which frames are considered.
+ If nil or omitted, delete all windows showing BUFFER in any frame.
+ If t, delete only windows showing BUFFER in the selected frame.
+ If `visible', delete all windows showing BUFFER in any visible frame.
+ If a frame, delete only windows showing BUFFER in that frame.
+
+Interactively, FRAME depends on the prefix arg, as follows:
+ Without a prefix arg (prefix = nil), FRAME is nil (all frames).
+ With prefix arg >= 0, FRAME is t (this frame only).
+ With prefix arg < 0, FRAME is `visible' (all visible frames)."
+ (interactive
+ (list (read-buffer-for-delete-windows)
+ (and current-prefix-arg
+ (or (natnump (prefix-numeric-value current-prefix-arg))
+ 'visible))))
+ (unless buffer (setq buffer (current-buffer))) ; Like Emacs 23+ - unlike Emacs 21-22.
+
+ ;; `get-buffer-window' interprets FRAME oppositely for t and nil, so switch.
+ (setq frame (if (eq t frame) nil (if (eq nil frame) t frame)))
+ (let (win)
+ ;; Vanilla Emacs version raises an error if BUFFER is a string that does not name a buffer.
+ ;; We do not raise an error - we do nothing.
+ (and (get-buffer buffer)
+ (while (setq win (get-buffer-window buffer frame))
+ (delete-window win))
+ nil))) ; Return nil always, like vanilla Emacs.
+
+(defun read-buffer-for-delete-windows ()
+ "Read buffer name for delete-windows commands.
+Only displayed buffers are completion candidates."
+ (completing-read "Delete windows on buffer: "
+ (let ((all-bufs (buffer-list))
+ (cand-bufs ()))
+ (dolist (buf all-bufs)
+ (when (get-buffer-window buf t)
+ (push (list (buffer-name buf)) cand-bufs)))
+ cand-bufs)
+ nil t nil 'minibuffer-history (buffer-name (current-buffer)) t))
+
+(defsubst frame-iconified-p (frame)
+ "Return non-nil if FRAME is `frame-live-p' and `frame-visible-p'."
+ (and (frame-live-p frame) (eq (frame-visible-p frame) 'icon)))
+
+;; (defun remove-window (&optional window)
+;; "Remove WINDOW from the display. Default is `selected-window'.
+;; If WINDOW is the only one in its frame, then:
+;; If WINDOW is dedicated to its buffer, then make its frame invisible.
+;; Otherwise, delete its frame (as well as the window)."
+;; (interactive)
+;; (setq window (or window (selected-window)))
+;; (select-window window)
+;; (if (and (window-dedicated-p (selected-window))
+;; (one-window-p t))
+;; (let ((fr (selected-frame)))
+;; ;; HACK because of Emacs bug: `raise-frame' won't raise a frame
+;; ;; that was first iconified and then made invisible.
+;; ;; So, here we don't make an iconified frame invisible.
+;; (unless (frame-iconified-p fr)
+;; (make-frame-invisible fr)))
+;; (delete-window)))
+
+;; REMOVED old definition, above, because of problems with invisible
+;; *Completions* frame when use completion window with subsequent args
+;; to a command. Just use `delete-window' now, which deletes frame if
+;; `one-window-p'. Use a `defalias' because its easier than replacing
+;; all my calls to `remove-window' with `delete-window'.
+;;
+;;;###autoload
+(defalias 'remove-window 'delete-window)
+
+;;;###autoload
+(defun remove-windows-on (buffer)
+ "Remove all windows showing BUFFER. This calls `remove-window'
+on each window showing BUFFER."
+ (interactive
+ (list (read-buffer "Remove all windows showing buffer: " (current-buffer) 'existing)))
+ (setq buffer (get-buffer buffer)) ; Convert to buffer.
+ (when buffer ; Do nothing if null BUFFER.
+ (dolist (fr (frames-on buffer t))
+ (remove-window (get-buffer-window buffer t)))))
+
+;;;###autoload
+(defun mouse-remove-window (event)
+ "Remove the window you click on. (This calls `remove-window'.)
+This command must be bound to a mouse click."
+ (interactive "e")
+ (mouse-minibuffer-check event)
+ (remove-window (posn-window (event-start event))))
+
+;;;###autoload
+(defun delete/iconify-window (&optional window frame-p)
+ "Delete or iconify WINDOW (default: `selected-window').
+If WINDOW is the only one in its frame (`one-window-p'), then optional
+arg FRAME-P determines the behavior regarding the frame, as follows:
+ If FRAME-P is nil, then the frame is deleted (with the window).
+ If FRAME-P is t, then the frame is iconified.
+ If FRAME-P is a symbol naming a function, the function is applied
+ to WINDOW as its only arg.
+ If the result is nil, then the frame is deleted.
+ If the result is non-nil, then the frame is iconified.
+ If FRAME-P is anything else, then behavior is as if FRAME-P were the
+ symbol `window-dedicated-p': the frame is iconified if
+ WINDOW is dedicated, otherwise the frame is deleted.
+
+Interactively, FRAME-P depends on the prefix arg, as follows:
+ Without a prefix arg (prefix = nil), FRAME-P is `window-dedicated-p'.
+ With prefix arg < 0, FRAME-P is t. The frame is iconified.
+ With prefix arg >= 0, FRAME-P is nil. The frame is deleted."
+ (interactive
+ (list nil (if current-prefix-arg
+ (not (natnump (prefix-numeric-value current-prefix-arg)))
+ 'window-dedicated-p)))
+ (setq window (or window (selected-window)))
+ (let ((one-win-p t))
+ (save-window-excursion
+ (select-window window)
+ (if (one-window-p)
+ (if frame-p
+ (if (eq t frame-p)
+ (iconify-frame)
+ (unless (and (symbolp frame-p) (fboundp frame-p))
+ (setq frame-p 'window-dedicated-p))
+ (if (funcall frame-p window) (iconify-frame) (delete-frame)))
+ (delete-frame)) ; Default.
+ (setq one-win-p nil)))
+ ;; Do this outside `save-window-excursion'.
+ (unless one-win-p (old-delete-window window))))
+
+;;;###autoload
+(defun delete/iconify-windows-on (buffer &optional frame frame-p)
+ "For each window showing BUFFER: delete it or iconify its frame.
+\(This calls `delete/iconify-window' on each window showing BUFFER.)
+
+Optional second arg FRAME controls which frames are considered.
+ If nil or omitted, treat all windows showing BUFFER in any frame.
+ If t, treat only windows showing BUFFER in the selected frame.
+ If `visible', treat all windows showing BUFFER in any visible frame.
+ If a frame, treat only windows showing BUFFER in that frame.
+
+Optional third arg FRAME-P controls what to do with one-window frames.
+ If FRAME-P is nil, then one-window frames showing BUFFER are deleted.
+ If FRAME-P is t, then one-window frames are iconified.
+ If FRAME-P is a symbol naming a function, the function is applied
+ to each window showing buffer in a frame by itself.
+ If the result is nil, then the frame is deleted.
+ If the result is non-nil, then the frame is iconified.
+ If FRAME-P is anything else, then behavior is as if FRAME-P were the
+ symbol `window-dedicated-p': One-window frames are
+ iconified if window is dedicated, else they are deleted.
+
+Interactively, FRAME is nil, and FRAME-P depends on the prefix arg:
+ Without a prefix arg (prefix = nil), FRAME-P is `window-dedicated-p'.
+ With prefix arg < 0, FRAME-P is t. The frame is iconified.
+ With prefix arg >= 0, FRAME-P is nil. The frame is deleted."
+ (interactive
+ (list (read-buffer "Delete windows on buffer: " (current-buffer) 'existing)
+ nil
+ (if current-prefix-arg
+ (not (natnump (prefix-numeric-value current-prefix-arg)))
+ 'window-dedicated-p)))
+ (setq buffer (get-buffer buffer)) ; Convert to buffer.
+ (when buffer ; Do nothing if null BUFFER.
+ ;; `get-buffer-window' interprets FRAME oppositely for t and nil,
+ ;; so switch.
+ (setq frame (if (eq t frame) nil (if (eq nil frame) t frame)))
+ (dolist (fr (frames-on buffer frame))
+ (delete/iconify-window (get-buffer-window buffer frame) frame-p))))
+
+;;;###autoload
+(defun rename-frame (&optional old-name new-name all-named)
+ "Rename a frame named OLD-NAME to NEW-NAME.
+Prefix arg ALL-NAMED non-nil means rename all frames named FRAME to NEWNAME.
+
+OLD-NAME may be a frame, its name, or nil. Default is `selected-frame'.
+
+NEW-NAME is a string or nil. Default NEW-NAME is current `buffer-name'."
+ (interactive
+ (list (read-frame (concat "Rename " (and current-prefix-arg "all ")
+ "frame" (and current-prefix-arg "s named") ": ")
+ nil t) ; Default = selected. Must exist.
+ (read-from-minibuffer "Rename to (new name): " (cons (buffer-name) 1))
+ current-prefix-arg))
+ (setq old-name (or old-name (get-frame-name))) ; Batch default: current.
+ (setq new-name (or new-name (buffer-name))) ; Batch default: buffer name.
+ ;; Convert to frame if string.
+ (let ((fr (get-a-frame old-name)))
+ (if all-named
+ (while fr
+ (modify-frame-parameters fr (list (cons 'name new-name)))
+ (setq fr (get-a-frame old-name))) ; Get another.
+ (when (string= (get-frame-name fr) (get-frame-name))
+ (setq fr (selected-frame)))
+ (modify-frame-parameters fr (list (cons 'name new-name))))))
+
+;;;###autoload
+(defun rename-non-minibuffer-frame (&optional old-name new-name all-named)
+ "Unless OLD-NAME names the minibuffer frame, use `rename-frame'
+to rename a frame named OLD-NAME to NEW-NAME.
+
+Prefix arg ALL-NAMED non-nil => Rename all frames named FRAME to NEWNAME.
+OLD-NAME may be a frame, its name, or nil. Default is `selected-frame'.
+NEW-NAME is a string or nil. Default NEW-NAME is current `buffer-name'."
+ (interactive
+ (list (read-frame (concat "Rename " (and current-prefix-arg "all ")
+ "frame" (and current-prefix-arg "s named") ": ")
+ nil t) ; Default = selected. Must exist.
+ (read-from-minibuffer "Rename to (new name): " (cons (buffer-name) 1))
+ current-prefix-arg))
+ (setq old-name (or old-name (get-frame-name))) ; Batch default: current.
+ (setq new-name (or new-name (buffer-name))) ; Batch default: buffer name.
+ (let ((fr (get-a-frame old-name))) ; Convert to frame if string.
+ (if (and (boundp '1on1-minibuffer-frame)
+ (eq (cdr (assq 'name (frame-parameters 1on1-minibuffer-frame)))
+ (cdr (assq 'name (frame-parameters fr)))))
+ (and (interactive-p)
+ (error "Use `rename-frame' if you really want to rename minibuffer"))
+ (rename-frame))))
+
+;;;###autoload
+(defun show-frame (frame)
+ "Make FRAME visible and raise it, without selecting it.
+FRAME may be a frame or its name."
+ (interactive (list (read-frame "Frame to make visible: ")))
+ (setq frame (get-a-frame frame))
+ (make-frame-visible frame)
+ (raise-frame frame))
+
+;;;###autoload
+(defun hide-frame (frame &optional prefix)
+ "Make FRAME invisible. Like `make-frame-invisible', but reads frame name.
+Non-nil PREFIX makes it invisible even if all other frames are invisible."
+ (interactive (list (read-frame "Frame to make invisible: ")))
+ (make-frame-invisible (get-a-frame frame) prefix))
+
+;;;###autoload
+(defun show-a-frame-on (buffer)
+ "Make visible and raise a frame showing BUFFER, if there is one.
+Neither the frame nor the BUFFER are selected.
+BUFFER may be a buffer or its name (a string)."
+ (interactive
+ (list (read-buffer "Show a frame showing buffer: "
+ (if (fboundp 'another-buffer) ; Defined in `misc-fns.el'.
+ (another-buffer nil t)
+ (other-buffer (current-buffer)))
+ 'existing)))
+ (when buffer ; Do nothing if null BUFFER.
+ (let ((fr (car (frames-on buffer)))) (when fr (show-frame fr)))))
+
+;;;###autoload
+(defun show-*Help*-buffer ()
+ "Raise a frame showing buffer *Help*, without selecting it."
+ (interactive) (show-a-frame-on "*Help*"))
+
+;;;###autoload
+(defun delete-1-window-frames-on (buffer)
+ "Delete all visible 1-window frames showing BUFFER."
+ (interactive
+ (list (read-buffer "Delete all visible 1-window frames showing buffer: "
+ (current-buffer) 'existing)))
+ (setq buffer (get-buffer buffer))
+ (save-excursion
+ (when (buffer-live-p buffer) ; Do nothing if dead buffer.
+ (dolist (fr (frames-on buffer)) ; Is it better to search through
+ (save-window-excursion ; `frames-on' or `get-buffer-window-list'?
+ (select-frame fr)
+ (when (one-window-p t fr) (delete-frame)))))))
+
+;;;###autoload
+(defun delete-other-frames (&optional frame)
+ "Delete all frames except FRAME (default: selected frame).
+Interactively, use a prefix arg (`\\[universal-argument]') to be prompted for FRAME."
+ (interactive (list (if current-prefix-arg
+ (get-a-frame (read-frame "Frame to make invisible: "))
+ (selected-frame))))
+ (when frame
+ (dolist (fr (frame-list))
+ (unless (eq fr frame) (condition-case nil (delete-frame fr) (error nil))))))
+
+;;;###autoload
+(defun maximize-frame-horizontally (&optional frame)
+ "Maximize selected frame horizontally."
+ (interactive (list (selected-frame)))
+ (maximize-frame 'horizontal frame))
+
+;;;###autoload
+(defun maximize-frame-vertically (&optional frame)
+ "Maximize selected frame vertically."
+ (interactive (list (selected-frame)))
+ (maximize-frame 'vertical frame))
+
+;;;###autoload
+(defun maximize-frame (&optional direction frame)
+ "Maximize selected frame horizontally, vertically, or both.
+With no prefix arg, maximize both directions.
+With a non-negative prefix arg, maximize vertically.
+With a negative prefix arg, maximize horizontally.
+
+In Lisp code:
+ DIRECTION is the direction: `horizontal', `vertical', or `both'.
+ FRAME is the frame to maximize."
+ (interactive (list (if current-prefix-arg
+ (if (natnump (prefix-numeric-value current-prefix-arg))
+ 'vertical
+ 'horizontal)
+ 'both)))
+ (unless frame (setq frame (selected-frame)))
+ (unless direction (setq direction 'both))
+ (let (;; Size of a frame that uses all of the available screen area,
+ ;; but leaving room for a minibuffer frame at bottom of display.
+ (fr-pixel-width (available-screen-pixel-width))
+ (fr-pixel-height (available-screen-pixel-height))
+ (fr-origin (if (eq direction 'horizontal)
+ (car (effective-screen-pixel-bounds))
+ (cadr (effective-screen-pixel-bounds))))
+ (orig-left (frame-parameter frame 'left))
+ (orig-top (frame-parameter frame 'top))
+ (orig-width (frame-parameter frame 'width))
+ (orig-height (frame-parameter frame 'height)))
+ (let* ((borders (* 2 (cdr (assq 'border-width (frame-parameters frame)))))
+ (new-left (if (memq direction '(horizontal both)) fr-origin 0))
+ (new-top (if (memq direction '(horizontal both)) 0 fr-origin))
+ ;; Subtract borders, scroll bars, & title bar, then convert pixel sizes to char sizes.
+ (new-width (if (memq direction '(horizontal both))
+ (/ (- fr-pixel-width borders (frame-extra-pixels-width frame))
+ (frame-char-width frame))
+ orig-width))
+ (new-height (if (memq direction '(vertical both))
+ (- (/ (- fr-pixel-height borders
+ (frame-extra-pixels-height frame)
+ window-mgr-title-bar-pixel-height
+ (smart-tool-bar-pixel-height))
+ (frame-char-height frame))
+ ;; Subtract menu bar unless on Carbon Emacs (menu bar not in the frame).
+ (if (eq window-system 'mac)
+ 0
+ (cdr (assq 'menu-bar-lines (frame-parameters frame)))))
+ orig-height)))
+ (modify-frame-parameters
+ frame
+ `((left . ,new-left)
+ (width . ,new-width)
+ (top . ,new-top)
+ (height . ,new-height)
+ ;; If we actually changed a parameter, record the old one for restoration.
+ ,(and new-left (/= orig-left new-left) (cons 'restore-left orig-left))
+ ,(and new-top (/= orig-top new-top) (cons 'restore-top orig-top))
+ ,(and new-width (/= orig-width new-width) (cons 'restore-width orig-width))
+ ,(and new-height (/= orig-height new-height) (cons 'restore-height orig-height)))))
+ (show-frame frame)
+ (incf fr-origin (if (eq direction 'horizontal) fr-pixel-width fr-pixel-height))))
+
+;;;###autoload
+(defalias 'restore-frame-horizontally 'toggle-max-frame-horizontally)
+;;;###autoload
+(defun toggle-max-frame-horizontally (&optional frame)
+ "Toggle maximization of FRAME horizontally.
+If used once, this restores the frame. If repeated, it maximizes.
+This affects the `left' and `width' frame parameters.
+
+FRAME defaults to the selected frame."
+ (interactive (list (selected-frame)))
+ (restore-frame 'horizontal frame))
+
+;;;###autoload
+(defalias 'restore-frame-horizontally 'toggle-max-frame-horizontally)
+;;;###autoload
+(defun toggle-max-frame-vertically (&optional frame)
+ "Toggle maximization of FRAME vertically.
+If used once, this restores the frame. If repeated, it maximizes.
+This affects the `top' and `height' frame parameters.
+
+FRAME defaults to the selected frame."
+ (interactive (list (selected-frame)))
+ (restore-frame 'vertical frame))
+
+;;;###autoload
+(defalias 'restore-frame 'toggle-max-frame)
+;;;###autoload
+(defun toggle-max-frame (&optional direction frame)
+ "Toggle maximization of FRAME horizontally, vertically, or both.
+Reverses or (if restored) repeats the effect of the Emacs maximize
+commands. Does not restore from maximization effected outside Emacs.
+
+With no prefix arg, toggle both directions.
+With a non-negative prefix arg, toggle only vertically.
+With a negative prefix arg, toggle horizontally.
+
+When toggling both, each is toggled from its last maximize or restore
+state. This means that using this after `maximize-horizontal',
+`maximize-vertical', `toggle-max-horizontal', or `toggle-max-vertical'
+does not necessarily just reverse the effect of that command.
+
+In Lisp code:
+ DIRECTION is the direction: `horizontal', `vertical', or `both'.
+ FRAME is the frame to change. It defaults to the selected frame."
+ (interactive (list (if current-prefix-arg
+ (if (natnump (prefix-numeric-value current-prefix-arg))
+ 'vertical
+ 'horizontal)
+ 'both)))
+ (unless frame (setq frame (selected-frame)))
+ (unless direction (setq direction 'both))
+ (let ((restore-left (frame-parameter frame 'restore-left))
+ (restore-top (frame-parameter frame 'restore-top))
+ (restore-width (frame-parameter frame 'restore-width))
+ (restore-height (frame-parameter frame 'restore-height))
+ (orig-left (frame-parameter frame 'left))
+ (orig-top (frame-parameter frame 'top))
+ (orig-width (frame-parameter frame 'width))
+ (orig-height (frame-parameter frame 'height))
+ (horiz (memq direction '(horizontal both)))
+ (vert (memq direction '(vertical both))))
+ (modify-frame-parameters
+ frame `(,(and horiz restore-left (cons 'left restore-left))
+ ,(and horiz restore-width (cons 'width restore-width))
+ ,(and vert restore-top (cons 'top restore-top))
+ ,(and vert restore-height (cons 'height restore-height))
+ ,(and horiz restore-left (cons 'restore-left orig-left))
+ ,(and horiz restore-width (cons 'restore-width orig-width))
+ ,(and vert restore-top (cons 'restore-top orig-top))
+ ,(and vert restore-height (cons 'restore-height orig-height)))))
+ (show-frame frame))
+
+;;;###autoload
+(defun tile-frames-horizontally (&optional frames)
+ "Tile frames horizontally.
+Interatively:
+ With prefix arg, you are prompted for names of two frames to tile.
+ With no prefix arg, all visible frames are tiled, except a
+ standalone minibuffer frame, if any.
+If called from a program, all frames in list FRAMES are tiled."
+ (interactive (and current-prefix-arg (read-args-for-tile-frames)))
+ (tile-frames 'horizontal frames))
+
+;;;###autoload
+(defun tile-frames-vertically (&optional frames)
+ "Tile frames vertically.
+Interatively:
+ With prefix arg, you are prompted for names of two frames to tile.
+ With no prefix arg, all visible frames are tiled, except a
+ standalone minibuffer frame, if any.
+If called from a program, all frames in list FRAMES are tiled."
+ (interactive (and current-prefix-arg (read-args-for-tile-frames)))
+ (tile-frames 'vertical frames))
+
+(defun tile-frames (direction frames)
+ "Tile visible frames horizontally or vertically, depending on DIRECTION.
+Arg DIRECTION is `horizontal' or `vertical'.
+Arg FRAMES is the list of frames to tile. If nil, then tile all visible
+frames (except a standalone minibuffer frame, if any)."
+ (let ((visible-frames
+ (or frames
+ (filtered-frame-list ; Get visible frames, except minibuffer.
+ (function
+ (lambda (fr)
+ (and (eq t (frame-visible-p fr))
+ (or (not (fboundp 'thumfr-thumbnail-frame-p))
+ (not (thumfr-thumbnail-frame-p fr)))
+ (or (not (boundp '1on1-minibuffer-frame))
+ (not (eq (cdr (assq 'name (frame-parameters 1on1-minibuffer-frame)))
+ (cdr (assq 'name (frame-parameters fr))))))))))))
+ ;; Size of a frame that uses all of the available screen area,
+ ;; but leaving room for a minibuffer frame at bottom of display.
+ (fr-pixel-width (available-screen-pixel-width))
+ (fr-pixel-height (available-screen-pixel-height))
+ (fr-origin (if (eq direction 'horizontal)
+ (car (effective-screen-pixel-bounds))
+ (cadr (effective-screen-pixel-bounds)))))
+ (case direction ; Size of frame in pixels.
+ (horizontal (setq fr-pixel-width (/ fr-pixel-width (length visible-frames))))
+ (vertical (setq fr-pixel-height (/ fr-pixel-height (length visible-frames))))
+ (otherwise (error "Function tile-frames: DIRECTION must be `horizontal' or `vertical'")))
+ (dolist (fr visible-frames)
+ ;; $$$$$$ (let ((borders (* 2 (+ (cdr (assq 'border-width (frame-parameters fr)))
+ ;; (cdr (assq 'internal-border-width (frame-parameters fr)))))))
+ (let ((borders (* 2 (cdr (assq 'border-width (frame-parameters fr))))))
+ (set-frame-size
+ fr
+ ;; Subtract borders, scroll bars, & title bar, then convert pixel sizes to char sizes.
+ (/ (- fr-pixel-width borders (frame-extra-pixels-width fr))
+ (frame-char-width fr))
+ (- (/ (- fr-pixel-height borders (frame-extra-pixels-height fr)
+ window-mgr-title-bar-pixel-height (smart-tool-bar-pixel-height))
+ (frame-char-height fr))
+ (if (eq window-system 'mac)
+ 0 ; Menu bar for Carbon Emacs is not in the frame.
+ (cdr (assq 'menu-bar-lines (frame-parameters fr))))))) ; Subtract `menu-bar-lines'.
+ (set-frame-position fr
+ (if (eq direction 'horizontal) fr-origin 0)
+ (if (eq direction 'horizontal) 0 fr-origin))
+ (show-frame fr)
+ (incf fr-origin (if (eq direction 'horizontal) fr-pixel-width fr-pixel-height)))))
+
+(defun frame-extra-pixels-width (frame)
+ "Pixel difference between FRAME total width and its text area width."
+ (- (frame-pixel-width frame) (* (frame-char-width frame) (frame-width frame))))
+
+(defun frame-extra-pixels-height (frame)
+ "Pixel difference between FRAME total height and its text area height."
+ (- (frame-pixel-height frame) (* (frame-char-height frame) (frame-height frame))))
+
+(defun smart-tool-bar-pixel-height (&optional frame)
+ "Pixel height of Mac smart tool bar."
+ (if (and (boundp 'mac-tool-bar-display-mode) (> (frame-parameter frame 'tool-bar-lines) 0))
+ (if (eq mac-tool-bar-display-mode 'icons) 40 56)
+ 0))
+
+(defun read-args-for-tile-frames ()
+ "Read arguments for `tile-frames'."
+ (list
+ (list
+ ;; Note: `read-frame' puts selected-frame name at front of `frame-name-history'.
+ (get-a-frame (read-frame "Tile two frames - First frame: " nil t))
+ ;; Get next visible frame. For default (prompt) value:
+ ;; If there is another visible frame in `frame-name-history', use next such.
+ ;; Else if there is another visible frame in internal frame list, use next such.
+ ;; Else use selected frame. (`frame-name-history' is defined in `frame.el'.)
+ (get-a-frame
+ (read-frame
+ "Second frame: "
+ (let ((fr-names (cdr frame-name-history))
+ (visible-p nil)
+ (fr nil))
+ (while (and (not fr) fr-names) ; While no visible frame found and still fr-names to check.
+ (setq fr (car fr-names)) ; Name
+ (setq fr (get-a-frame fr)) ; Frame
+ (setq fr (and fr (eq t (frame-visible-p fr)) fr)) ; Visible frame
+ (setq fr-names (cdr fr-names)))
+
+ ;; If no visible frames in history, besides selected-frame,
+ ;; then get next visible frame (not its name) from internal frame list.
+ (unless fr
+ (setq fr (selected-frame))
+ (while (and (not visible-p)
+ (setq fr (next-frame fr))
+ (not (equal fr (selected-frame)))) ; equal => no other found.
+ (setq visible-p (eq t (frame-visible-p fr)))))
+ fr)
+ t)))))
+
+(defun available-screen-pixel-bounds ()
+ "Returns a value of the same form as `available-screen-pixel-bounds'.
+This represents the currently available screen area."
+ (or available-screen-pixel-bounds ; Use the option value, if available.
+ (if (fboundp 'mac-display-available-pixel-bounds) ; Mac-OS-specific.
+ (mac-display-available-pixel-bounds)
+ (list 0 0 (x-display-pixel-width) (x-display-pixel-height)))))
+
+; Emacs 20 doesn't have `butlast'. Define it to avoid requiring `cl.el' at runtime. From `subr.el'.
+(unless (fboundp 'butlast)
+ (defun nbutlast (list &optional n)
+ "Modifies LIST to remove the last N elements."
+ (let ((m (length list)))
+ (or n (setq n 1))
+ (and (< n m) (progn (when (> n 0) (setcdr (nthcdr (- (1- m) n) list) ()))
+ list))))
+
+ (defun butlast (list &optional n)
+ "Return a copy of LIST with the last N elements removed."
+ (if (and n (<= n 0)) list (nbutlast (copy-sequence list) n))))
+
+(defun effective-screen-pixel-bounds ()
+ "Upper left and lower right of available screen space for tiling frames.
+This is `available-screen-pixel-bounds', possibly adjusted to allow
+for the standalone minibuffer frame provided by `oneonone.el'."
+ (if (boundp '1on1-minibuffer-frame)
+ (append (butlast (available-screen-pixel-bounds))
+ (list (frame-geom-value-numeric 'top (cdr (assq 'top (frame-parameters
+ 1on1-minibuffer-frame))))))
+ (available-screen-pixel-bounds)))
+
+(defun available-screen-pixel-width (&optional include-mini-p)
+ "Width of the usable screen, in pixels.
+Non-nil optional argument `include-mini-p' means include the space
+occupied by a standalone minibuffer, if any."
+ (let ((bounds (if include-mini-p
+ (available-screen-pixel-bounds)
+ (effective-screen-pixel-bounds))))
+ (- (caddr bounds) (car bounds)))) ; X1 - X0
+
+(defun available-screen-pixel-height (&optional include-mini-p)
+ "Height of the usable screen, in pixels.
+Non-nil optional argument `include-mini-p' means include the
+space occupied by a standalone minibuffer, if any."
+ (let ((bounds (if include-mini-p
+ (available-screen-pixel-bounds)
+ (effective-screen-pixel-bounds))))
+ (- (cadddr bounds) (cadr bounds)))) ; Y1 - Y0
+
+;; Inspired by `sk-grow-frame' from Sarir Khamsi [sarir.khamsi@raytheon.com]
+;;;###autoload
+(defun enlarge-frame (&optional increment frame) ; Suggested binding: `C-M-down'.
+ "Increase the height of FRAME (default: selected-frame) by INCREMENT.
+INCREMENT is in lines (characters).
+Interactively, it is given by the prefix argument."
+ (interactive "p")
+ (set-frame-height frame (+ (frame-height frame) increment)))
+
+;;;###autoload
+(defun enlarge-frame-horizontally (&optional increment frame) ; Suggested binding: `C-M-right'.
+ "Increase the width of FRAME (default: selected-frame) by INCREMENT.
+INCREMENT is in columns (characters).
+Interactively, it is given by the prefix argument."
+ (interactive "p")
+ (set-frame-width frame (+ (frame-width frame) increment)))
+
+;;;###autoload
+(defun shrink-frame (&optional increment frame) ; Suggested binding: `C-M-up'.
+ "Decrease the height of FRAME (default: selected-frame) by INCREMENT.
+INCREMENT is in lines (characters).
+Interactively, it is given by the prefix argument."
+ (interactive "p")
+ (set-frame-height frame (- (frame-height frame) increment)))
+
+;;;###autoload
+(defun shrink-frame-horizontally (&optional increment frame) ; Suggested binding: `C-M-left'.
+ "Decrease the width of FRAME (default: selected-frame) by INCREMENT.
+INCREMENT is in columns (characters).
+Interactively, it is given by the prefix argument."
+ (interactive "p")
+ (set-frame-width frame (- (frame-width frame) increment)))
+
+;;;###autoload
+(defun move-frame-down (&optional n frame) ; Suggested binding: `M-down'.
+ "Move selected frame down.
+Move it N times `frame-char-height', where N is the prefix arg.
+In Lisp code, FRAME is the frame to move."
+ (interactive "p")
+ (unless n (setq n 1))
+ (setq n (* n (frame-char-height frame)))
+ (modify-frame-parameters frame (list (list 'top '+ (new-frame-position frame 'top n)))))
+
+;;;###autoload
+(defun move-frame-up (&optional n frame) ; Suggested binding: `M-up'.
+ "Move selected frame up.
+Same as `move-frame-down', except movement is up."
+ (interactive "p")
+ (unless n (setq n 1))
+ (move-frame-down (- n)))
+
+;;;###autoload
+(defun move-frame-right (&optional n frame) ; Suggested binding: `M-right'.
+ "Move frame to the right.
+Move it N times `frame-char-width', where N is the prefix arg.
+In Lisp code, FRAME is the frame to move."
+ (interactive "p")
+ (unless n (setq n 1))
+ (setq n (* n (frame-char-width frame)))
+ (modify-frame-parameters frame (list (list 'left '+ (new-frame-position frame 'left n)))))
+
+;;;###autoload
+(defun move-frame-left (&optional n frame) ; Suggested binding: `M-left'.
+ "Move frame to the left.
+Same as `move-frame-right', except movement is to the left."
+ (interactive "p")
+ (unless n (setq n 1))
+ (move-frame-right (- n)))
+
+;; Helper function.
+(defun new-frame-position (frame type incr)
+ "Return the new TYPE position of FRAME, incremented by INCR.
+TYPE is `left' or `top'.
+INCR is the increment to use when changing the position."
+ (let ((new-pos
+ (+ incr (cadr (frame-geom-value-cons type (cdr (assq type (frame-parameters frame)))))))
+ (display-dimension
+ (if (eq 'left type)
+ (available-screen-pixel-width t)
+ (available-screen-pixel-height t)))
+ (frame-dimension
+ (if (eq 'left type) (frame-pixel-width frame) (frame-pixel-height frame))))
+ (if (not move-frame-wrap-within-display-flag)
+ new-pos
+ (when (< new-pos (- frame-dimension)) (setq new-pos display-dimension))
+ (when (> new-pos display-dimension) (setq new-pos (- frame-dimension)))
+ new-pos)))
+
+;;;###autoload
+(defun move-frame-to-screen-top (arg &optional frame) ; Suggested binding: `M-S-v'.
+ "Move FRAME (default: selected-frame) to the top of the screen.
+With a prefix arg, offset it that many char heights from the top."
+ (interactive (list (if current-prefix-arg
+ (* (frame-char-height) (prefix-numeric-value current-prefix-arg))
+ 0)))
+ (modify-frame-parameters frame `((top . ,arg))))
+
+;;;###autoload
+(defun move-frame-to-screen-bottom (arg &optional frame) ; Suggested binding: `C-S-v'.
+ "Move FRAME (default: selected-frame) to the bottom of the screen.
+With a prefix arg, offset it that many char heights from the bottom."
+ (interactive (list (if current-prefix-arg
+ (* (frame-char-height) (prefix-numeric-value current-prefix-arg))
+ 0)))
+ (let* ((borders (* 2 (cdr (assq 'border-width (frame-parameters frame)))))
+ (avail-height (- (/ (- (available-screen-pixel-height) borders
+ (frame-extra-pixels-height frame)
+ window-mgr-title-bar-pixel-height
+ (smart-tool-bar-pixel-height))
+ (frame-char-height frame))
+ ;; Subtract menu bar unless on Carbon Emacs (menu bar not in the frame).
+ (if (eq window-system 'mac)
+ 0
+ (cdr (assq 'menu-bar-lines (frame-parameters frame)))))))
+ (modify-frame-parameters frame `((top . ,(- (+ avail-height arg)))))))
+
+;;;###autoload
+(defun move-frame-to-screen-left (arg &optional frame) ; Suggested binding: `C-S-prior'.
+ "Move FRAME (default: selected-frame) to the left side of the screen.
+With a prefix arg, offset it that many char widths from the left."
+ (interactive (list (if current-prefix-arg
+ (* (frame-char-width) (prefix-numeric-value current-prefix-arg))
+ 0)))
+ (modify-frame-parameters frame `((left . ,arg))))
+
+;;;###autoload
+(defun move-frame-to-screen-right (arg &optional frame) ; Suggested binding: `C-S-next'.
+ "Move FRAME (default: selected-frame) to the right side of the screen.
+With a prefix arg, offset it that many char widths from the right."
+ (interactive (list (if current-prefix-arg
+ (* (frame-char-width) (prefix-numeric-value current-prefix-arg))
+ 0)))
+ (modify-frame-parameters
+ frame ; Hard-code 7 here - what does it depend on?
+ `((left . ,(- (x-display-pixel-width) (+ (frame-pixel-width) 7 arg))))))
+
+
+
+
+;;; This was a workaround hack for an Emacs 23 bug (#119, aka #1562).
+;;; This works OK, but it is not as refined as the version I use, and it does not work for
+;;; older Emacs versions.
+;;;
+;;; (when (> emacs-major-version 22)
+;;; (defun enlarge-font (&optional increment frame)
+;;; "Increase size of font in FRAME by INCREMENT.
+;;; Interactively, INCREMENT is given by the prefix argument.
+;;; Optional FRAME parameter defaults to current frame."
+;;; (interactive "p")
+;;; (setq frame (or frame (selected-frame)))
+;;; (set-face-attribute
+;;; 'default frame :height (+ (* 10 increment)
+;;; (face-attribute 'default :height frame 'default)))))
+
+
+;; This still doesn't work 100% well. For instance, set frame font to
+;; "-raster-Terminal-normal-r-normal-normal-12-90-96-96-c-50-ms-oemlatin", then decrease font size.
+;; The next smaller existing font on my machine is
+;; "-raster-Terminal-normal-r-normal-normal-11-*-96-96-c-*-ms-oemlatin". Decrease size again.
+;; Next smaller font is "-raster-Terminal-bold-r-normal-normal-5-37-96-96-c-60-ms-oemlatin". Notice
+;; the switch to bold from regular. Cannot decrease any more. Increase size. Next larger font is
+;; "-raster-Terminal-bold-r-normal-normal-8-*-96-96-c-*-ms-oemlatin". Can no longer increase size.
+;;
+;;;###autoload
+(defun enlarge-font (&optional increment frame)
+ "Increase size of font in FRAME by INCREMENT.
+Interactively, INCREMENT is given by the prefix argument.
+Optional FRAME parameter defaults to current frame."
+ (interactive "p")
+ (setq frame (or frame (selected-frame)))
+ (let ((fontname (cdr (assq 'font (frame-parameters frame))))
+ (count enlarge-font-tries))
+ (setq fontname (enlarged-font-name fontname frame increment))
+ (while (and (not (x-list-fonts fontname)) (wholenump (setq count (1- count))))
+ (setq fontname (enlarged-font-name fontname frame increment)))
+ (unless (x-list-fonts fontname) (error "Cannot change font size"))
+ (modify-frame-parameters frame (list (cons 'font fontname)))
+ ;; Update faces that want a bold or italic version of the default font.
+ (when (< emacs-major-version 21) (frame-update-faces frame))))
+
+(defun enlarged-font-name (fontname frame increment)
+ "FONTNAME, after enlarging font size of FRAME by INCREMENT.
+FONTNAME is the font of FRAME."
+ (when (query-fontset fontname)
+ (let ((ascii (assq 'ascii (aref (fontset-info fontname frame) 2))))
+ (when ascii (setq fontname (nth 2 ascii)))))
+ (let ((xlfd-fields (x-decompose-font-name fontname)))
+ (unless xlfd-fields (error "Cannot decompose font name"))
+ (let ((new-size (+ (string-to-number (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
+ increment)))
+ (unless (> new-size 0) (error "New font size is too small: %s" new-size))
+ (aset xlfd-fields xlfd-regexp-pixelsize-subnum (number-to-string new-size)))
+ ;; Set point size & width to "*", so frame width will adjust to new font size
+ (aset xlfd-fields xlfd-regexp-pointsize-subnum "*")
+ (aset xlfd-fields xlfd-regexp-avgwidth-subnum "*")
+ (x-compose-font-name xlfd-fields)))
+
+;;;###autoload
+(defun set-frame-alist-parameter-from-frame (alist parameter &optional frame)
+ "Set PARAMETER of frame alist ALIST to its current value in FRAME.
+FRAME defaults to the selected frame. ALIST is a variable (symbol)
+whose value is an alist of frame parameters."
+ (interactive
+ (let ((symb (or (and (fboundp 'symbol-nearest-point)(symbol-nearest-point))
+ (and (symbolp (variable-at-point)))))
+ (enable-recursive-minibuffers t))
+ (list (intern (completing-read "Frame alist to change (variable): "
+ (frame-alist-var-names) nil t nil nil 'default-frame-alist t))
+ (intern (completing-read "Parameter to set:"
+ (frame-parameter-names) nil t nil nil 'left t))
+ (get-a-frame (read-frame "Frame to copy parameter value from: " nil t)))))
+ (unless (boundp alist)
+ (error "Not a defined Emacs variable: `%s'" alist))
+ (set alist (assq-delete-all parameter (copy-alist (eval alist))))
+ (set alist (cons (assq parameter (frame-parameters frame)) (eval alist)))
+ (tell-customize-var-has-changed alist))
+
+;;; Standard Emacs 21+ function, defined here for Emacs 20.
+(unless (fboundp 'assq-delete-all)
+ (defun assq-delete-all (key alist)
+ "Delete from ALIST all elements whose car is `eq' to KEY.
+Return the modified alist.
+Elements of ALIST that are not conses are ignored."
+ (while (and (consp (car alist)) (eq (car (car alist)) key)) (setq alist (cdr alist)))
+ (let ((tail alist) tail-cdr)
+ (while (setq tail-cdr (cdr tail))
+ (if (and (consp (car tail-cdr)) (eq (car (car tail-cdr)) key))
+ (setcdr tail (cdr tail-cdr))
+ (setq tail tail-cdr))))
+ alist))
+
+;; Define this to avoid requiring `cl.el' at runtime. Same as `icicle-set-difference'.
+(defun frame-cmds-set-difference (list1 list2 &optional key)
+ "Combine LIST1 and LIST2 using a set-difference operation.
+Optional arg KEY is a function used to extract the part of each list
+item to compare.
+
+The result list contains all items that appear in LIST1 but not LIST2.
+This is non-destructive; it makes a copy of the data if necessary, to
+avoid corrupting the original LIST1 and LIST2."
+ (if (or (null list1) (null list2)) list1
+ (let ((keyed-list2 (and key (mapcar key list2)))
+ (result ()))
+ (while list1
+ (unless (if key
+ (member (funcall key (car list1)) keyed-list2)
+ (member (car list1) list2))
+ (setq result (cons (car list1) result)))
+ (setq list1 (cdr list1)))
+ result)))
+
+;;;###autoload
+(defun set-all-frame-alist-parameters-from-frame (alist &optional frame really-all-p)
+ "Set frame parameters of ALIST to their current values in FRAME.
+Unless optional argument REALLY-ALL-P (prefix arg) is non-nil, the
+frame parameters in list `frame-parameters-to-exclude' are
+excluded: they are not copied from FRAME to ALIST.
+ALIST is a variable (symbol) whose value is an alist of frame parameters.
+FRAME defaults to the selected frame."
+ (interactive
+ (let ((symb (or (and (fboundp 'symbol-nearest-point)(symbol-nearest-point))
+ (and (symbolp (variable-at-point)))))
+ (enable-recursive-minibuffers t))
+ (list (intern (completing-read "Frame alist to change (variable): "
+ (frame-alist-var-names) nil t nil nil 'default-frame-alist t))
+ (get-a-frame (read-frame "Frame to copy parameter values from: " nil t))
+ current-prefix-arg)))
+ (unless (boundp alist)
+ (error "Not a defined Emacs variable: `%s'" alist))
+ (set alist (frame-cmds-set-difference (frame-parameters frame)
+ (and (not really-all-p) frame-parameters-to-exclude)
+ #'car))
+ (tell-customize-var-has-changed alist))
+
+(defun frame-alist-var-names ()
+ "Return an alist of all variable names that end in \"frame-alist\".
+The CAR of each list item is a string variable name.
+The CDR is nil."
+ (let ((vars nil))
+ (mapatoms (lambda (sym) (and (boundp sym)
+ (setq sym (symbol-name sym))
+ (string-match "frame-alist$" sym)
+ (push (list sym) vars))))
+ vars))
+
+(defun frame-parameter-names ()
+ "Return an alist of all available frame-parameter names.
+The CAR of each list item is a string parameter name.
+The CDR is nil."
+ (let ((params '(("display") ("title") ("name") ("left") ("top") ("icon-left") ("icon-top")
+ ("user-position") ("height") ("width") ("window-id") ("minibuffer")
+ ("buffer-predicate") ("buffer-list") ("font") ("auto-raise") ("auto-lower")
+ ("vertical-scroll-bars") ("horizontal-scroll-bars") ("scroll-bar-width")
+ ("icon-type") ("icon-name") ("foreground-color") ("background-color")
+ ("background-mode") ("mouse-color") ("cursor-color") ("border-color")
+ ("display-type") ("cursor-type") ("border-width") ("internal-border-width")
+ ("unsplittable") ("visibility") ("menu-bar-lines"))))
+ (when (> emacs-major-version 20)
+ (setq params (nconc params '("fullscreen" "outer-window-id" "tty-color-mode" "left-fringe"
+ "right-fringe" "tool-bar-lines" "screen-gamma" "line-spacing"
+ "wait-for-wm" "scroll-bar-foreground" "scroll-bar-background"))))
+ (when (> emacs-major-version 21) (setq params (nconc params '("user-size"))))
+ (when (> emacs-major-version 22)
+ (setq params (nconc params '("display-environment-variable" "term-environment-variable"))))
+ params))
+
+;;;###autoload
+(defun tell-customize-var-has-changed (variable)
+ "Tell Customize to recognize that VARIABLE has been set (changed).
+VARIABLE is a symbol that names a user option."
+ (interactive "vVariable: ")
+ (put variable 'customized-value (list (custom-quote (eval variable)))))
+
+;;;###autoload
+(defun other-window-or-frame (arg)
+ "`other-frame', if `one-window-p'; otherwise, `other-window'."
+ (interactive "p")
+ (if (one-window-p) (other-frame arg) (other-window arg)))
+
+;;;;;;;;;;;;;;;;;;;;;;;
+
+(provide 'frame-cmds)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; frame-cmds.el ends here
diff --git a/elisp/frame-fns.el b/elisp/frame-fns.el
new file mode 100644
index 0000000..2746576
--- /dev/null
+++ b/elisp/frame-fns.el
@@ -0,0 +1,314 @@
+;;; frame-fns.el --- Non-interactive frame and window functions.
+;;
+;; Filename: frame-fns.el
+;; Description: Non-interactive frame and window functions.
+;; Author: Drew Adams
+;; Maintainer: Drew Adams
+;; Copyright (C) 1996-2013, Drew Adams, all rights reserved.
+;; Created: Tue Mar 5 16:15:50 1996
+;; Version: 21.1
+;; Last-Updated: Fri Dec 28 09:49:09 2012 (-0800)
+;; By: dradams
+;; Update #: 204
+;; URL: http://www.emacswiki.org/frame-fns.el
+;; Doc URL: http://emacswiki.org/FrameModes
+;; Keywords: internal, extensions, local, frames
+;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x
+;;
+;; Features that might be required by this library:
+;;
+;; `avoid'.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; Non-interactive frame and window functions.
+;;
+;; Main new functions defined here:
+;;
+;; `1-window-frames-on', `distance', `flash-ding',
+;; `frame-geom-spec-cons', `frame-geom-value-cons',
+;; `frame-geom-spec-numeric', `frame-geom-value-numeric',
+;; `frames-on', `get-a-frame', `get-frame-name',
+;; `multi-window-frames-on', `read-frame', `window-coords'.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Change Log:
+;;
+;; 2011/01/04 dadams
+;; Removed autoload cookies from non-interactive functions.
+;; 2010/01/12 dadams
+;; 1-window-frames-on, multi-window-frames-on:
+;; save-excursion + set-buffer -> with-current-buffer.
+;; 2008/04/05 dadams
+;; get-a-frame: Define without using member-if.
+;; 2005/10/31 dadams
+;; read-frame: Swapped default and init values in call to completing-read.
+;; 2004/11/26 dadams
+;; Added frame-geom-spec-numeric and frame-geom-value-numeric.
+;; 2004/03/19 dadams
+;; read-frame: 1) if default is a frame, use its name,
+;; 2) use frame-name-history, not minibuffer-history,
+;; and use make-frame-names-alist, not frame-alist,
+;; in completing-read
+;; 1996/02/14 dadams
+;; Added: window-coords, distance.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+(eval-when-compile (when (< emacs-major-version 21) (require 'cl)))
+ ;; dolist, push
+(require 'avoid nil t) ;; mouse-avoidance-point-position
+
+;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun window-coords (&optional position)
+ "Return window coordinates of buffer POSITION (default: point).
+If POSITION is nil, (point) is used."
+ (unless (fboundp 'mouse-avoidance-point-position) (require 'avoid))
+ (cdr (mouse-avoidance-point-position)))
+
+(defun distance (pt1 pt2)
+ "Distance as the crow flies between PT1 and PT2.
+PT1 and PT2 are each a cons of the form (X . Y)."
+ (let ((xdiff (abs (- (car pt1) (car pt2))))
+ (ydiff (abs (- (cdr pt1) (cdr pt2)))))
+ (sqrt (+ (* xdiff xdiff) (* ydiff ydiff)))))
+
+(defun frame-geom-value-numeric (type value &optional frame)
+ "Return equivalent geometry value for FRAME in numeric terms.
+A geometry value equivalent to VALUE for FRAME is returned,
+where the value is numeric, not a consp.
+TYPE is the car of the original geometry spec (TYPE . VALUE).
+ It is `top' or `left', depending on which edge VALUE is related to.
+VALUE is the cdr of a frame geometry spec: (left/top . VALUE).
+If VALUE is a consp, then it is converted to a numeric value, perhaps
+ relative to the opposite frame edge from that in the original spec.
+FRAME defaults to the selected frame.
+
+Examples (measures in pixels) -
+ Assuming display height/width=1024, frame height/width=600:
+ 300 inside display edge: 300 => 300
+ (+ 300) => 300
+ 300 inside opposite display edge: (- 300) => -300
+ -300 => -300
+ 300 beyond display edge
+ (= 724 inside opposite display edge): (+ -300) => -724
+ 300 beyond display edge
+ (= 724 inside opposite display edge): (- -300) => 724
+
+In the last two examples, the returned value is relative to the
+opposite frame edge from the edge indicated in the input spec."
+ (if (consp value)
+ (if (natnump (cadr value))
+ ;; e.g. (+ 300) or (- 300) => 300 or -300
+ (funcall (car value) (cadr value))
+ ;; e.g. (+ -300) or (- -300)
+ (let ((oppval (- (if (eq 'left type)
+ (x-display-pixel-width)
+ (x-display-pixel-height))
+ (cadr value)
+ (if (eq 'left type)
+ (frame-pixel-width frame)
+ (frame-pixel-height frame)))))
+ (if (eq '+ (car value))
+ (- oppval) ; e.g. (+ -300) => -724
+ oppval))) ; e.g. (- -300) => 724
+ ;; e.g. 300 or -300
+ value))
+
+(defun frame-geom-spec-numeric (spec &optional frame)
+ "Return equivalent geometry specification for FRAME in numeric terms.
+A geometry specification equivalent to SPEC for FRAME is returned,
+where the value is numeric, not a consp.
+SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE).
+If VALUE is a consp, then it is converted to a numeric value, perhaps
+ relative to the opposite frame edge from that in the original SPEC.
+FRAME defaults to the selected frame.
+
+Examples (measures in pixels) -
+ Assuming display height=1024, frame height=600:
+ top 300 below display top: (top . 300) => (top . 300)
+ (top + 300) => (top . 300)
+ bottom 300 above display bottom: (top - 300) => (top . -300)
+ (top . -300) => (top . -300)
+ top 300 above display top
+ (= bottom 724 above display bottom): (top + -300) => (top . -724)
+ bottom 300 below display bottom
+ (= top 724 below display top): (top - -300) => (top . 724)
+
+In the last two examples, the returned value is relative to the
+opposite frame edge from the edge indicated in the input SPEC."
+ (cons (car spec) (frame-geom-value-numeric (car spec) (cdr spec))))
+
+(defun frame-geom-value-cons (type value &optional frame)
+ "Return equivalent geometry value for FRAME as a cons with car `+'.
+A geometry value equivalent to VALUE for FRAME is returned,
+where the value is a cons with car `+', not numeric.
+TYPE is the car of the original geometry spec (TYPE . VALUE).
+ It is `top' or `left', depending on which edge VALUE is related to.
+VALUE is the cdr of a frame geometry spec: (left/top . VALUE).
+If VALUE is a number, then it is converted to a cons value, perhaps
+ relative to the opposite frame edge from that in the original spec.
+FRAME defaults to the selected frame.
+
+Examples (measures in pixels) -
+ Assuming display height/width=1024, frame height/width=600:
+ 300 inside display edge: 300 => (+ 300)
+ (+ 300) => (+ 300)
+ 300 inside opposite display edge: (- 300) => (+ 124)
+ -300 => (+ 124)
+ 300 beyond display edge
+ (= 724 inside opposite display edge): (+ -300) => (+ -300)
+ 300 beyond display edge
+ (= 724 inside opposite display edge): (- -300) => (+ 724)
+
+In the 3rd, 4th, and 6th examples, the returned value is relative to
+the opposite frame edge from the edge indicated in the input spec."
+ (cond ((and (consp value) (eq '+ (car value))) ; e.g. (+ 300), (+ -300)
+ value)
+ ((natnump value) (list '+ value)) ; e.g. 300 => (+ 300)
+ (t ; e.g. -300, (- 300), (- -300)
+ (list '+ (- (if (eq 'left type) ; => (+ 124), (+ 124), (+ 724)
+ (x-display-pixel-width)
+ (x-display-pixel-height))
+ (if (integerp value) (- value) (cadr value))
+ (if (eq 'left type)
+ (frame-pixel-width frame)
+ (frame-pixel-height frame)))))))
+
+(defun frame-geom-spec-cons (spec &optional frame)
+ "Return equivalent geometry spec for FRAME as a cons with car `+'.
+A geometry specification equivalent to SPEC for FRAME is returned,
+where the value is a cons with car `+', not numeric.
+SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE).
+If VALUE is a number, then it is converted to a cons value, perhaps
+ relative to the opposite frame edge from that in the original spec.
+FRAME defaults to the selected frame.
+
+Examples (measures in pixels) -
+ Assuming display height=1024, frame height=600:
+ top 300 below display top: (top . 300) => (top + 300)
+ (top + 300) => (top + 300)
+ bottom 300 above display bottom: (top - 300) => (top + 124)
+ (top . -300) => (top + 124)
+ top 300 above display top
+ (= bottom 724 above display bottom): (top + -300) => (top + -300)
+ bottom 300 below display bottom
+ (= top 724 below display top): (top - -300) => (top + 724)
+
+In the 3rd, 4th, and 6th examples, the returned value is relative to
+the opposite frame edge from the edge indicated in the input spec."
+ (cons (car spec) (frame-geom-value-cons (car spec) (cdr spec))))
+
+(defun get-frame-name (&optional frame)
+ "Return the string that names FRAME (a frame). Default is selected frame."
+ (unless frame (setq frame (selected-frame)))
+ (if (framep frame)
+ (cdr (assq 'name (frame-parameters frame)))
+ (error "Function `get-frame-name': Argument not a frame: `%s'" frame)))
+
+(defun get-a-frame (frame)
+ "Return a frame, if any, named FRAME (a frame or a string).
+If none, return nil.
+If FRAME is a frame, it is returned."
+ (cond ((framep frame) frame)
+ ((stringp frame)
+ (catch 'get-a-frame-found
+ (dolist (fr (frame-list))
+ (when (string= frame (get-frame-name fr))
+ (throw 'get-a-frame-found fr)))
+ nil))
+ (t
+ (error
+ "Function `get-frame-name': Arg neither a string nor a frame: `%s'"
+ frame))))
+
+(defun read-frame (prompt &optional default existing)
+ "Read the name of a frame, and return it as a string.
+Prompts with 1st arg, PROMPT (a string).
+
+The default frame is named by the optional 2nd arg, DEFAULT, if a
+string or a frame, or by the `selected-frame', if nil.
+
+Non-nil optional 3rd arg, EXISTING, means to allow only names of
+existing frames."
+ (setq default (if (framep default) (get-frame-name default)
+ (or default (get-frame-name))))
+ (unless (stringp default)
+ (error
+ "Function `read-frame': DEFAULT arg is neither a frame nor a string"))
+ (completing-read prompt (make-frame-names-alist)
+ ;; To limit to live frames:
+ ;; (function (lambda (fn+f)(frame-live-p (cdr fn+f))))
+ ;; `frame-name-history' is defined in `frame.el'.
+ nil existing nil '(frame-name-history . 2) default))
+
+(defun frames-on (buffer &optional frame)
+ "List of all live frames showing BUFFER (a buffer or its name).
+The optional FRAME argument is as for function `get-buffer-window'."
+ (filtered-frame-list (function (lambda (fr) (get-buffer-window buffer fr)))))
+
+(defun 1-window-frames-on (buffer)
+ "List of all visible 1-window frames showing BUFFER."
+ (setq buffer (get-buffer buffer))
+ (when buffer ; Do nothing if BUFFER is not a buffer.
+ (let ((frs nil))
+ (with-current-buffer buffer
+ (when (buffer-live-p buffer) ; Do nothing if dead buffer.
+ (dolist (fr (frames-on buffer)) ; Is it better to search through
+ (save-window-excursion ; frames-on or windows-on?
+ (select-frame fr)
+ (when (one-window-p t fr) (push fr frs))))))
+ frs)))
+
+(defun multi-window-frames-on (buffer)
+ "List of all visible multi-window frames showing BUFFER."
+ (setq buffer (get-buffer buffer))
+ (when buffer ; Do nothing if BUFFER is not a buffer.
+ (let ((frs nil))
+ (with-current-buffer buffer
+ (when (buffer-live-p buffer) ; Do nothing if dead buffer.
+ (dolist (fr (frames-on buffer)) ; Is it better to search through
+ (save-window-excursion ; frames-on or windows-on?
+ (select-frame fr)
+ (when (not (one-window-p t fr)) (push fr frs))))))
+ frs)))
+
+(defun flash-ding (&optional do-not-terminate frame)
+ "Ring bell (`ding'), after flashing FRAME (default: current), if relevant.
+Terminates any keyboard macro executing, unless arg DO-NOT-TERMINATE non-nil."
+ (save-window-excursion
+ (when frame (select-frame frame))
+ (let ((visible-bell t)) ; Flash.
+ (ding do-not-terminate)))
+ (let ((visible-bell nil))
+ (ding do-not-terminate))) ; Bell.
+
+;;;;;;;;;;;;;;;;;;;;;;;
+
+(provide 'frame-fns)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; frame-fns.el ends here
diff --git a/elisp/grammar.el b/elisp/grammar.el
new file mode 100644
index 0000000..00736c4
--- /dev/null
+++ b/elisp/grammar.el
@@ -0,0 +1,396 @@
+;;; grammar.el --- Grammar checker for Emacs
+;;
+;; Copyright (C) 2010 Baoqiu Cui
+;;
+;; Filename: grammar.el
+;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
+;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
+;; Keywords: grammar spell
+;; Description: Perform grammar checking in Emacs buffers
+;;
+;; $Id: grammar.el,v 1.12 2010/06/14 06:00:06 bcui Exp $
+;;
+;; This file is NOT part of GNU Emacs.
+;;
+;; grammar.el is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by the
+;; Free Software Foundation, either version 3 of the License, or (at
+;; your option) any later version.
+;;
+;; This file is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; A copy of the GNU General Public License can be made from
+;; <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Grammar is a minor Emacs mode that performs semi-on-the-fly grammar
+;; checking using Link Grammar (http://www.link.cs.cmu.edu/link/). A
+;; separate Link Grammar client, grammar.cc (included in this package),
+;; is required in order to make this mode work.
+;;
+;; To enable Grammar minor mode, type M-x grammar-mode. This applies
+;; only to the current buffer. Command grammar-mode toggles Grammar
+;; mode in the current buffer.
+;;
+
+(defgroup grammar nil
+ "Grammar checking on the fly."
+ :tag "Grammar"
+ :group 'processes)
+
+(defcustom grammar-mode-line-string " Grammar"
+ "String displayed on the modeline when grammar is active.
+Set this to nil if you don't want a modeline indicator."
+ :group 'grammar
+ :type '(choice string (const :tag "None" nil)))
+
+(defcustom grammar-program-name "grammar-filter"
+ "Program invoked by Grammar mode.
+Make sure this program can be located in your environment."
+ :type 'string
+ :group 'grammar)
+
+(defcustom grammar-delay 3
+ "The number of seconds to wait before checking, after a \"delayed\" command."
+ :type 'number
+ :group 'grammar)
+
+(defcustom grammar-default-delayed-commands
+ '(self-insert-command
+ delete-backward-char
+ backward-or-forward-delete-char
+ delete-char
+ scrollbar-vertical-drag
+ backward-delete-char-untabify)
+ "The standard list of delayed commands for Grammar.
+See `grammar-delayed-commands'."
+ :type '(repeat (symbol))
+ :group 'grammar)
+
+(defcustom grammar-delayed-commands nil
+ "List of commands that are \"delayed\" for Grammar mode.
+After these commands, grammar checking is delayed for a short time,
+whose length is specified by `grammar-delay'."
+ :type '(repeat (symbol))
+ :group 'grammar)
+
+(defface grammar-error-face
+ '((((class color)) :foreground "Red" :underline "White")
+ (t :underline t))
+ "Face for highlighting grammar errors."
+ :group 'grammar)
+
+(defvar grammar-process nil
+ "The process object for Grammar.")
+
+(defvar grammar-filter nil
+ "Output filter from piped calls to Grammar.")
+
+(defvar grammar-filter-continue nil
+ "Control variable for Ispell filter function.")
+
+(defun grammar-start-process ()
+ "Start the grammar process."
+ (apply 'start-process
+ "grammar" nil grammar-program-name nil))
+
+(defun grammar-accept-output (&optional timeout-secs timeout-msecs)
+ "Wait for output from grammar process, or TIMEOUT-SECS and TIMEOUT-MSECS."
+ (accept-process-output grammar-process timeout-secs timeout-msecs))
+
+;;; "grammar-filter" is a list of output lines from the generating
+;;; function. Each full line (ending with \n) is a separate item on the
+;;; list. "output" can contain multiple lines, part of a line, or both.
+;;; "start" and "end" are used to keep bounds on lines when "output"
+;;; contains multiple lines. "ispell-filter-continue" is true when we
+;;; have received only part of a line as output from a generating
+;;; function ("output" did not end with \n).
+;;;
+;;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
+;;; This is the case when a process dies or fails. The default behavior
+;;; in this case treats the next input received as fresh input.
+
+(defun grammar-filter (process output)
+ "Output filter function for grammar."
+ (let ((start 0)
+ (continue t)
+ end)
+ (while continue
+ ;; (message ">>> output = %s###" output)
+ (setq end (string-match "\n" output start)) ; get text up to the newline.
+ ;; If we get out of sync and ispell-filter-continue is asserted when we
+ ;; are not continuing, treat the next item as a separate list. When
+ ;; ispell-filter-continue is asserted, ispell-filter *should* always be a
+ ;; list!
+
+ ;; Continue with same line (item)?
+ (if (and grammar-filter-continue
+ grammar-filter
+ (listp grammar-filter))
+ ;; Yes. Add it to the prev item
+ (setcar grammar-filter
+ (concat (car grammar-filter) (substring output start end)))
+ ;; No. This is a new line and item.
+ (setq grammar-filter
+ (cons (substring output start end) grammar-filter)))
+ (if (null end)
+ ;; We've completed reading the output, but didn't finish the line.
+ (setq grammar-filter-continue t
+ continue nil)
+ ;; skip over newline, this line complete.
+ (setq grammar-filter-continue nil
+ end (1+ end))
+ (if (= end (length output))
+ ;; No more lines in output, so we can exit the filter.
+ (setq continue nil)
+ (setq start end))))))
+
+(defun grammar-kill-grammar (&optional no-error)
+ "Kill current grammar process."
+ (interactive)
+ (if (not (and grammar-process
+ (eq (process-status grammar-process) 'run)))
+ (or no-error
+ (error "There is no grammar process running!"))
+ (delete-process grammar-process)
+ (setq grammar-process nil)
+ (message "Grammar process killed")
+ nil))
+
+(defun grammar-init-process ()
+ "Initialize the grammar process.
+This function will (re)start the grammar process if necessary."
+ (if (and grammar-process
+ (eq (process-status grammar-process) 'run))
+ (setq grammar-filter nil))
+ (grammar-kill-grammar t)
+ (message "Starting new grammar process...")
+ (sit-for 0)
+ (setq grammar-process (grammar-start-process)
+ grammar-filter nil
+ grammar-filter-continue nil)
+ (set-process-filter grammar-process 'grammar-filter)
+ (grammar-accept-output 3)
+ (if (null grammar-filter)
+ ;; Get more output if filter is empty
+ (grammar-accept-output 3))
+ (cond ((null grammar-filter)
+ (error "%s did not output version line" grammar-program-name))
+ (t
+ (message (car grammar-filter)))
+ )
+ (setq grammar-filter nil)
+ (set-process-query-on-exit-flag grammar-process nil)
+ )
+
+(defun grammar-send-string (string)
+ "Send string STRING to the Grammar process.
+STRING should not contain any newline. It will be appended with
+a newline before being sent to the Grammar process."
+ (process-send-string grammar-process (concat string "\n")))
+
+(defun grammar-process-line (string)
+ "Check the grammar of string STRING.
+STRING is pre-processed before it is sent to the grammar process:
+the newlines, and prefixes for ordered lists or itemized lists,
+etc., are replaced with spaces. As long as we keep the relative
+positions of all really words intact, it is fine.
+
+When finished, `grammar-process-line' always returns a list of
+strings. If there is no grammar errors in STRING, '(\"ok\") is
+returned. If grammar checker timeout happens, '(\"timeout\") is
+returned. Otherwise, a sequence of problematic words and their
+positions in STRING is returned.
+
+For example, if STRING is \"This person have two name.\", list
+'(\"this\" \"0\" \"person\" \"5\" \"name\" \"21\") is returned."
+ (let (word-pos-list word pos (start 0))
+ ;;
+ ;; Do some cleanups on the string.
+ ;;
+ ;; - Replace potential prefixes like "\n 5. " or "\n - " with
+ ;; spaces. This prefix may exist if the current sentence is an
+ ;; item of an ordered list.
+ ;;
+ ;; - Replace newlines with spaces.
+ ;;
+ (if (string-match "\n *\\([0-9]+\.\\|-\\) " string)
+ (setq string (replace-match
+ (make-string (length (match-string 0 string)) ? )
+ t t string)))
+ (while (setq start (string-match "\n" string start))
+ (setq string (replace-match " " t t string)))
+ (grammar-send-string string)
+ (with-local-quit
+ (while (progn
+ (accept-process-output grammar-process)
+ ;; (if (not (string= "" (car grammar-filter)))
+ ;; (message ">>>> Read again"))
+ (not (string= "" (car grammar-filter))))))
+ (setq word-pos-list (split-string (cadr grammar-filter)))
+ word-pos-list))
+
+(defun grammar-make-overlay (from to face)
+ "Highlight region from FROM to TO with face FACE."
+ (let ((overlay (make-overlay from to)))
+ (overlay-put overlay 'grammar-overlay t)
+ (overlay-put overlay 'face face)))
+
+(defun grammar-check ()
+ "Check grammar of the sentence before or at the current point."
+ (interactive)
+ (let (start end sentence word-pos-list word pos)
+ (save-excursion
+ (backward-sentence)
+ (setq start (point))
+ (forward-sentence)
+ (setq end (point)))
+ (when (> end (+ start 10))
+ (setq word-pos-list (grammar-process-line
+ (buffer-substring start end)))
+ ;; Clear all overlays that may have grammar-error-face.
+ (dolist (overlay (overlays-in start end))
+ (when (eq (overlay-get overlay 'face) 'grammar-error-face)
+ (delete-overlay overlay)))
+ ;; If something is wrong with the grammar, word-pos-list should
+ ;; contains N pairs of (word position).
+ (if (= (length word-pos-list) 1)
+ (message "Grammar %s" (car word-pos-list))
+ (message "Grammar error")
+ (while word-pos-list
+ (setq word (car word-pos-list)
+ pos (string-to-number (cadr word-pos-list))
+ word-pos-list (cddr word-pos-list))
+ (grammar-make-overlay (+ start pos)
+ (+ start pos (length word))
+ 'grammar-error-face)
+ )))))
+
+(defun grammar-delay-commands ()
+ "Install the standard set of Grammar delayed commands."
+ (mapc 'grammar-delay-command grammar-default-delayed-commands)
+ (mapcar 'grammar-delay-command grammar-delayed-commands))
+
+(defun grammar-delay-command (command)
+ "Set COMMAND to be delayed, for Grammar.
+When grammar `post-command-hook' is invoked because a delayed command
+as been used the current sentence is not immediately checked.
+It will be checked only after `grammar-delay' seconds."
+ (interactive "SDelay Grammar after Command: ")
+ (put command 'grammar-delayed t))
+
+(defvar grammar-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-\M-g" 'grammar-check)
+ map)
+ "Minor mode keymap for grammar mode--for the whole buffer.")
+
+;;;###autoload
+(define-minor-mode grammar-mode
+ "Minor mode performing on-the-fly grammar checking."
+ :lighter grammar-mode-line-string
+ :keymap grammar-mode-map
+ :group grammar
+ (if grammar-mode
+ (condition-case ()
+ (grammar-mode-on)
+ (error (message "Enabling Grammar mode gave an error")
+ (grammar-mode -1)))
+ (grammar-mode-off)))
+
+;;;###autoload
+(defun turn-on-grammar ()
+ "Unconditionally turn on Grammar mode."
+ (grammar-mode 1))
+
+;;;###autoload
+(defun turn-off-grammar ()
+ "Unconditionally turn off Grammar mode."
+ (grammar-mode -1))
+
+(defun grammar-mode-on ()
+ "Turn Grammar mode on. Do not use this; use `grammar-mode' instead."
+ (if (or (null grammar-process)
+ (not (eq (process-status grammar-process) 'run)))
+ (grammar-init-process))
+ ;; we put the `grammar-delayed' property on some commands
+ (grammar-delay-commands)
+ ;; we put the `grammar-deplacement' property on some commands
+ ;(grammar-deplacement-commands)
+ ;; we bound grammar action to post-command hook
+ (add-hook 'post-command-hook (function grammar-post-command-hook) t t)
+ ;; we bound grammar action to pre-command hook
+ ;; (add-hook 'pre-command-hook (function grammar-pre-command-hook) t t)
+
+ ;; the welcome message
+ (message "Welcome to grammar."))
+
+(defun grammar-delete-all-overlays ()
+ "Delete all the overlays used by grammar."
+ (remove-overlays (point-min) (point-max) 'grammar-overlay))
+
+;;;###autoload
+(defun grammar-mode-off ()
+ "Turn Grammar mode off."
+ ;; Remove the hooks
+ (remove-hook 'post-command-hook (function grammar-post-command-hook) t)
+ ;; (remove-hook 'pre-command-hook (function grammar-pre-command-hook) t)
+
+ ;; Remove all the Grammar highlightings
+ (grammar-delete-all-overlays)
+ ;; Mark the mode as killed
+ (setq grammar-mode nil))
+
+(defun grammar-check-pre-sentence-p ()
+ "Return non-nil if we should check the sentence before point."
+ (let ((sentence-end (sentence-end)))
+ (cond
+ ;; After a space key: at least we should see two spaces before the
+ ;; current point.
+ ((and (or (eq this-command 'self-insert-command)
+ (eq this-command 'org-self-insert-command)
+ (eq this-command 'orgtbl-self-insert-command))
+ (eq (char-before (point)) ? )
+ (eq (char-before (1- (point))) ? )
+ (save-excursion
+ (re-search-backward sentence-end (- (point) 3) t)))
+ t)
+ ;; After a newline key
+ ((and (or (eq this-command 'newline)
+ (eq this-command 'org-return)
+ (eq this-command 'orgtbl-hijacker-command-100))
+ (eq (char-before (point)) 10)
+ (not (eq (char-before (1- (point))) 10))
+ (save-excursion
+ (re-search-backward sentence-end (- (point) 3) t)))
+ t)
+ ;; After a tab key.
+ ((and (or (eq this-command 'indent-for-tab-command)
+ (eq this-command 'orgtbl-hijacker-command-102))
+ (eq (char-syntax (char-before (point))) ? )
+ (save-excursion
+ (re-search-backward sentence-end (- (point) 3) t)))
+ t)
+ ((and (symbolp this-command)
+ (not executing-kbd-macro)
+ (or (get this-command 'grammar-delayed)))
+ nil)
+ ;; By default, do not check the sentence before point.
+ (t
+ nil)
+ )))
+
+(defun grammar-post-command-hook ()
+ "The `post-command-hook' used by Grammar to check a sentence in-the-fly."
+ (interactive)
+ (when grammar-mode
+ (let ((command this-command))
+ (if (grammar-check-pre-sentence-p)
+ (grammar-check))
+ )))
+
+(provide 'grammar)
diff --git a/elisp/keymap.el b/elisp/keymap.el
new file mode 100644
index 0000000..0c2785d
--- /dev/null
+++ b/elisp/keymap.el
@@ -0,0 +1,7 @@
+;; genering key mappping
+(provide 'keymap)
+
+; justify paragraph keys
+(global-set-key (kbd "A-q") 'fill-paragraph)
+(global-set-key (kbd "C-j") 'fill-paragraph)
+
diff --git a/elisp/osx.el b/elisp/osx.el
index 392b73a..f438647 100644
--- a/elisp/osx.el
+++ b/elisp/osx.el
@@ -14,9 +14,6 @@
(global-set-key [(hyper h)] 'help)
-; justify paragraph keys
-(global-set-key (kbd "A-q") 'fill-paragraph)
-(global-set-key (kbd "C-j") 'fill-paragraph)
; scrolling
(global-set-key [(hyper up)] 'backward-paragraph)
@@ -36,12 +33,23 @@
(global-set-key [next] 'sfp-page-down)
(global-set-key [prior] 'sfp-page-up)
+; switching windows
+(global-set-key [(hyper \`)] 'other-window)
+(global-set-key [(hyper \])] 'other-window)
+(global-set-key [(hyper \[)] 'other-window)
+
+; switch buffer
+(global-set-key [(hyper backspace)] 'ido-switch-buffer)
+(global-set-key [(hyper =)] 'ido-switch-buffer)
(global-set-key [(hyper a)] 'mark-whole-buffer)
(global-set-key [(hyper v)] 'yank)
+
(global-set-key [(hyper c)] 'kill-ring-save)
(global-set-key [(hyper x)] 'kill-region)
+(global-set-key [(hyper k)] 'kill-buffer)
+
(global-set-key [(hyper s)] 'save-buffer)
(global-set-key [(hyper l)] 'goto-line)
(global-set-key [(hyper o)] 'ns-open-file-using-panel)
@@ -61,10 +69,10 @@
; compat with old-school emacs behaviour and swap of hyper - alt
(global-set-key [(hyper w)] 'kill-ring-save)
(global-set-key (kbd "C-w") 'kill-region)
-; if you are an hardcore osx user you might want to comment out the
-; following:
+
(global-set-key [(hyper y)] 'yank)
(global-set-key [(hyper /)] 'complete-symbol)
+(global-set-key [(hyper \\)] 'complete-symbol)
(defun maximize-frame ()
(interactive)
diff --git a/elisp/zoom-frm.el b/elisp/zoom-frm.el
new file mode 100644
index 0000000..c17e516
--- /dev/null
+++ b/elisp/zoom-frm.el
@@ -0,0 +1,310 @@
+;;; zoom-frm.el --- Commands to zoom frame font size.
+;;
+;; Filename: zoom-frm.el
+;; Description: Commands to zoom frame font size.
+;; Author: Drew Adams
+;; Maintainer: Drew Adams
+;; Copyright (C) 2005-2013, Drew Adams, all rights reserved.
+;; Created: Fri Jan 07 10:24:35 2005
+;; Version: 20
+;; Last-Updated: Fri Dec 28 10:41:18 2012 (-0800)
+;; By: dradams
+;; Update #: 247
+;; URL: http://www.emacswiki.org/zoom-frm.el
+;; Doc URL: http://emacswiki.org/SetFonts
+;; Keywords: frames, extensions, convenience
+;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x
+;;
+;; Features that might be required by this library:
+;;
+;; `avoid', `frame-cmds', `frame-fns', `misc-fns', `strings',
+;; `thingatpt', `thingatpt+'.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; Commands to zoom font size.
+;;
+;; A few commands are provided for zooming a frame or buffer, so that
+;; its font becomes larger or smaller. For example, bind `zoom-in'
+;; and `zoom-out' to mouse wheel events to get the zooming effect you
+;; are used to in a Web browser.
+;;
+;; With Emacs 20, 21, and 22, you can zoom a frame. Starting with
+;; Emacs 23, you can zoom either a frame (all buffers shown there) or
+;; a single buffer (in all frames where it is displayed). User
+;; option `zoom-frame/buffer' determines which kind of zooming (frame
+;; or buffer) is done. You can customize this option, but you can
+;; also toggle it just by providing a prefix arg (`C-u') to `zoom-in'
+;; or `zoom-out'.
+;;
+;; Note on saving changes made with the commands defined here:
+;;
+;; Some of the commands defined here change frame properties. You
+;; can save any changes you have made, by using Customize. To
+;; visit a Customize buffer of all unsaved changes you have made,
+;; use command `customize-customized'.
+;;
+;; Frame parameter changes, such as font size, can be saved for
+;; future use by all frames or all frames of a certain kind. For
+;; that, you must change the frame parameters of the correponding
+;; frame-alist variable.
+;;
+;; There is no single variable for saving changes to parameters of
+;; the current frame. Instead, there are several different
+;; frame-alist variables, which you can use to define different
+;; kinds of frames. These include: `default-frame-alist',
+;; `initial-frame-alist', and `special-display-frame-alist'. The
+;; complete list of such frame alist variables is available using
+;; function `frame-alist-var-names', defined in library
+;; `frame-cmds.el'.
+;;
+;; Example: Suppose you change the font size of a frame and want to
+;; make that the default font size for new frames in the future.
+;; You will need to update the value of variable
+;; `default-frame-alist' to use the `font' parameter setting of the
+;; changed frame.
+;;
+;; You can easily copy one or all parameter values from any given
+;; frame to any frame alist (such as `default-frame-alist'), by
+;; using the commands `set-frame-alist-parameter-from-frame' and
+;; `set-all-frame-alist-parameters-from-frame'. Those commands are
+;; defined in library `frame-cmds.el'.
+;;
+;;
+;; Commands defined here:
+;;
+;; `toggle-zoom-frame', `zoom-frm-in', `zoom-frm-out',
+;; `zoom-frm-unzoom', `zoom-in', `zoom-out'.
+;;
+;;
+;; User options (variables) defined here:
+;;
+;; `frame-zoom-font-difference', `zoom-frame/buffer' (Emacs 23+).
+;;
+;;
+;; Put this in your init file (`~/.emacs'): (require 'zoom-frm)
+;;
+;; Suggested key bindings:
+;;
+;; (global-set-key (if (boundp 'mouse-wheel-down-event) ; Emacs 22+
+;; (vector (list 'control mouse-wheel-down-event))
+;; [C-mouse-wheel]) ; Emacs 20, 21
+;; 'zoom-in)
+;; (when (boundp 'mouse-wheel-up-event) ; Emacs 22+
+;; (global-set-key (vector (list 'control mouse-wheel-up-event))
+;; 'zoom-out))
+;;
+;; (global-set-key [S-mouse-1] 'zoom-in)
+;; (global-set-key [C-S-mouse-1] 'zoom-out)
+;; ;; Get rid of `mouse-set-font' or `mouse-appearance-menu':
+;; (global-set-key [S-down-mouse-1] nil)
+;;
+;; The first two of these mean that in Emacs 22 or later you can hold
+;; the Control key and rotate the wheel to zoom in and out, just as
+;; you do in your Web browser. In Emacs 20 and 21, however, Control
+;; plus wheeling zooms in, but to zoom out you need to use `C--'
+;; before wheeling with Control. This is because Emacs 20 and 21 do
+;; not have separate events for the mouse wheel directions, and it is
+;; the prefix arg, not the wheel direction, that determines the
+;; effect.
+;;
+;; Note: You can bind the zooming commands to keyboard events, as
+;; well as to mouse events. You could do this, for instance:
+;;
+;; (global-set-key [(control shift ?z)] 'zoom-in) ; `C-S-z'
+;; (global-set-key [(control ?z)] 'zoom-out) ; `C-z'
+;;
+;;
+;; See also these files for other frame commands:
+;;
+;; `autofit-frame.el' - Automatically fit each frame to its
+;; selected window. Uses `fit-frame.el'.
+;;
+;; `fit-frame.el' - 1) Fit a frame to its selected window.
+;; 2) Incrementally resize a frame.
+;;
+;; `doremi-frm.el' - Incrementally adjust frame properties
+;; using arrow keys and/or mouse wheel.
+;;
+;; `frame-cmds.el' - Miscellaneous frame and window commands.
+;;
+;; `thumb-frm.el' - Shrink frames to a thumbnail size and
+;; restore them again.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Change Log:
+;;
+;; 2011/01/04 dadams
+;; Added autoload cookies for defgroup and defcustom.
+;; 2010/07/06 dadams
+;; zoom-(in|out): Put doc strings before interactive spec. Thx to Yidong Chong.
+;; 2009/06/11 dadams
+;; Added buffer zooming, for Emacs 23.
+;; Added zoom-(in|out), group zoom, zoom-frame/buffer.
+;; 2006/01/07 dadams
+;; Added :link for sending bug report.
+;; 2006/01/06 dadams
+;; frame-zoom-font-difference: Changed :group to Frame-Commands. Added :link.
+;; 2005/01/18 dadams
+;; Changed default value of frame-zoom-font-difference.
+;; Added Note on saving changes.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+(require 'frame-cmds) ;; enlarge-font
+
+;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+;;; USER OPTIONS (VARIABLES) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;###autoload
+(defgroup zoom nil
+ "Zoom a frame or buffer."
+ :group 'frames :group 'Frame-Commands ; Defined in `frame-cmds.el'.
+ :link `(url-link :tag "Send Bug Report"
+ ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
+zoom-frm.el bug: \
+&body=Describe bug here, starting with `emacs -q'. \
+Don't forget to mention your Emacs and library versions."))
+ :link '(url-link :tag "Other Libraries by Drew"
+ "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries")
+ :link '(url-link :tag "Download"
+ "http://www.emacswiki.org/cgi-bin/wiki/zoom-frm.el")
+ :link '(url-link :tag "Description"
+ "http://www.emacswiki.org/cgi-bin/wiki/SetFonts#ChangingFontSize")
+ :link '(emacs-commentary-link :tag "Commentary" "zoom-frm"))
+
+;;;###autoload
+(defcustom frame-zoom-font-difference 1
+ "*Number of points to change the frame font size when zooming
+using commands `zoom-frm-in' and `zoom-frm-out'.
+The absolute value of this must be less than the current font size,
+since the new font size cannot be less than 1 point."
+ :type 'integer :group 'zoom)
+
+(when (> emacs-major-version 22)
+ (defcustom zoom-frame/buffer 'frame
+ "*What to zoom: current frame or current buffer.
+See commands `zoom-in' and `zoom-out'."
+ :type '(choice (const :tag "Zoom frame" frame) (const :tag "Zoom buffer" buffer))
+ :group 'zoom))
+
+
+;;; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(unless (> emacs-major-version 22) (defalias 'zoom-in 'zoom-frm-in))
+;;;###autoload
+(defun zoom-frm-in (&optional frame flip)
+ "Zoom FRAME in by `frame-zoom-font-difference', making text larger.
+If `frame-zoom-font-difference' is negative, make text smaller.
+With prefix argument FLIP, reverse the direction:
+if `frame-zoom-font-difference' is positive, then make text smaller.
+This is equal but opposite to `zoom-frm-out'."
+ (interactive (list (selected-frame) current-prefix-arg))
+ (setq frame (or frame (selected-frame)))
+ (let ((zoom-factor (frame-parameter frame 'zoomed))
+ (increment (if flip (- frame-zoom-font-difference) frame-zoom-font-difference)))
+ (unless zoom-factor (setq zoom-factor 0))
+ (setq zoom-factor (+ zoom-factor increment))
+ (enlarge-font increment frame)
+ (modify-frame-parameters frame (list (cons 'zoomed zoom-factor)))))
+
+(unless (> emacs-major-version 22) (defalias 'zoom-out 'zoom-frm-out))
+;;;###autoload
+(defun zoom-frm-out (&optional frame flip)
+ "Zoom FRAME out by `frame-zoom-font-difference'.
+If `frame-zoom-font-difference' is negative, make text larger.
+With prefix argument FLIP, reverse the direction:
+if `frame-zoom-font-difference' is positive, then make text larger.
+This is equal but opposite to `zoom-frm-in'."
+ (interactive (list (selected-frame) current-prefix-arg))
+ (setq frame (or frame (selected-frame)))
+ (let ((frame-zoom-font-difference (- frame-zoom-font-difference)))
+ (zoom-frm-in frame flip)))
+
+;;;###autoload
+(defun zoom-frm-unzoom (&optional frame)
+ "Cancel zoom of FRAME."
+ (interactive)
+ (setq frame (or frame (selected-frame)))
+ (let ((zoom-factor (frame-parameter frame 'zoomed)))
+ (if (not zoom-factor)
+ (error "Frame is not zoomed")
+ (enlarge-font (- zoom-factor) frame)
+ (modify-frame-parameters frame '((zoomed))))))
+
+;;;###autoload
+(defun toggle-zoom-frame (&optional frame)
+ "Alternately zoom/unzoom FRAME by `frame-zoom-font-difference'."
+ (interactive)
+ (setq frame (or frame (selected-frame)))
+ (if (frame-parameter frame 'zoomed)
+ (zoom-frm-unzoom frame)
+ (zoom-frm-in frame)))
+
+(when (> emacs-major-version 22)
+ (defun zoom-in (arg)
+ "Zoom current frame or buffer in.
+With a prefix arg, toggle between zooming frame and zooming buffer.
+Frame zooming uses command `zoom-frm-in'.
+Buffer zooming uses command `text-scale-increase'."
+ (interactive "P")
+ (when arg
+ (setq zoom-frame/buffer (if (eq zoom-frame/buffer 'frame) 'buffer 'frame)))
+ (if (eq zoom-frame/buffer 'frame)
+ (zoom-frm-in)
+ (with-current-buffer
+ (if (string-match "mouse" (format "%S" (event-basic-type
+ last-command-event)))
+ (window-buffer (posn-window (event-start last-command-event)))
+ (current-buffer))
+ (text-scale-increase 1))))
+
+ (defun zoom-out (arg)
+ "Zoom current frame or buffer out.
+With a prefix arg, toggle between zooming frame and zooming buffer.
+Frame zooming uses command `zoom-frm-out'.
+Buffer zooming uses command `text-scale-decrease'."
+ (interactive "P")
+ (when arg
+ (setq zoom-frame/buffer (if (eq zoom-frame/buffer 'frame) 'buffer 'frame)))
+ (if (eq zoom-frame/buffer 'frame)
+ (zoom-frm-out)
+ (with-current-buffer
+ (if (string-match "mouse" (format "%S" (event-basic-type
+ last-command-event)))
+ (window-buffer (posn-window (event-start last-command-event)))
+ (current-buffer))
+ (text-scale-decrease 1)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(provide 'zoom-frm)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; zoom-frm.el ends here
diff --git a/mac/AutOrg.command b/mac/AutOrg.command
index 778d878..917253f 100755
--- a/mac/AutOrg.command
+++ b/mac/AutOrg.command
@@ -24,6 +24,15 @@ cat <<EOF > $appbase/$autorg/.emacs
(require 'osx)
EOF
-export PATH=$PATH:/usr/texbin
+export PATH=$PATH:$appbase/$autorg:/usr/texbin
+# export LANG=en_US
+# export LC_CTYPE=UTF-8
+cat <<EOF > $appbase/$autorg/.aspell.conf
+dict-dir $appbase/$autorg/dict
+data-dir $appbase/$autorg/dict
+#add-extra-dicts en
+#add-extra-dicts grc
+home-dir $HOME
+EOF
HOME=$appbase/$autorg $appbin/Emacs $@