annotate lisp/dframe.el @ 72824:ca6fbba4d933

Add comment.
author Lars Hansen <larsh@soem.dk>
date Tue, 12 Sep 2006 07:13:17 +0000
parents 13b406066d9e
children e3694f1cb928
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; dframe --- dedicate frame support modes
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
3 ;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68561
diff changeset
4 ;; 2005, 2006 Free Software Foundation, Inc.
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Keywords: file, tags, tools
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 (defvar dframe-version "1.3"
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 "The current version of the dedicated frame library.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; any later version.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; GNU General Public License for more details.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
65780
6e229fd94815 * speedbar.el: Remove RCS tag.
Chong Yidong <cyd@stupidchicken.com>
parents: 65779
diff changeset
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6e229fd94815 * speedbar.el: Remove RCS tag.
Chong Yidong <cyd@stupidchicken.com>
parents: 65779
diff changeset
27 ;; Boston, MA 02110-1301, USA.
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;;; Commentary:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; This code was developed and maintained as a part of speedbar since 1996.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; It became its own support utility in Aug 2000.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; Dedicated frame mode is an Emacs independent library for supporting
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;; a program/buffer combination that resides in a dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; Support of this nature requires several complex interactions with the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;; user which this library will provide, including:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; * Creation of a frame. Positioned relatively.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;; Includes a frame cache for User position caching.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;; * Switching between frames.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;; * Timed activities using idle-timers
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; * Frame/buffer killing hooks
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;; * Mouse-3 position relative menu
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; * Mouse motion, help-echo hacks
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; * Mouse clicking, double clicking, & Xemacs image clicking hack
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;; * Mode line hacking
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ;; * Utilities for use in a program covering:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;; o keymap massage for some actions
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; o working with an associated buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;; o shift-click
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;; o detaching a frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; o focus-shifting & optional frame jumping
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 ;; o currently active frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 ;; o message/y-or-n-p
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;; o mouse set point
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ;; To Use:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ;; 1) (require 'dframe)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 ;; 2) Variable Setup:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ;; -frame-parameters -- Frame parameters for Emacs.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 ;; -frame-plist -- Frame parameters for XEmacs.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;; -- Not on parameter lists: They can optionally include width
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;; and height. If width or height is not included, then it will
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; be provided to match the originating frame. In general,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 ;; turning off the menu bar, mode line, and minibuffer can
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 ;; provide a smaller window, or more display area.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 ;; -track-mouse-flag -- mouse tracking on/off specific to your tool.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 ;; -update-flag -- app toggle for timer use. Init from
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;; `dframe-have-timer-flag'. This is nil for terminals, since
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 ;; updating a frame in a terminal is not useful to the user.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;; -key-map -- Your keymap. Call `dframe-update-keymap' on it.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ;; -buffer, -frame, -cached-frame -- Variables used to track your
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 ;; applications buffer, frame, or frame cache (when hidden). See
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 ;; `dframe-frame-mode' for details.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 ;; -before-delete-hook, -before-popup-hook, -after-create-hook --
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 ;; Hooks to have called. The `-after-create-hook' probably wants
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 ;; to call a function which calls `dframe-reposition-frame' in an
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 ;; appropriate manner.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 ;; 3) Function Setup:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ;; your-frame-mode -- function to toggle your app frame on and off.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 ;; its tasks are:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 ;; a) create a buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 ;; b) Call `dframe-frame-mode'. (See its doc)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 ;; c) If successful (your -frame variable has a value), call
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ;; timer setup if applicable.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ;; your-frame-reposition- -- Function to call from after-create-hook to
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 ;; reposition your frame with `dframe-repsoition-frame'.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ;; your-mode -- Set up the major mode of the buffer for your app.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ;; Set these variables: dframe-track-mouse-function,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 ;; dframe-help-echo-function,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;; dframe-mouse-click-function,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 ;; dframe-mouse-position-function.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 ;; See speedbar's implementation of these functions.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 ;; `speedbar-current-frame', `speedbar-get-focus', `speedbar-message',
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 ;; `speedbar-y-or-n-p', `speedbar-set-timer', `speedbar-click',
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 ;; `speedbar-position-cursor-on-line'
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ;; 4) Handling mouse clicks, and help text:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;; dframe-track-mouse, dframe-help-echo-function --
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;; These variables need to be set to functions that display info
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;; based on the mouse's position.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; Text propert 'help-echo, set to `dframe-help-echo', which will
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 ;; call `dframe-help-echo-function'.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 ;; Have a `-click' function, it can call `dframe-quick-mouse' for
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 ;; positioning. If the variable `dframe-power-click' is non-nil,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 ;; then `shift' was held down during the click.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 ;;; Bugs
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 ;; * The timer managers doesn't handle multiple different timeouts.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 ;; * You can't specify continuous timouts (as opposed to just lidle timers.)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112
65866
df5f6fcce1be (x-pointer-hand2, x-pointer-top-left-arrow): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 65825
diff changeset
113 (defvar x-pointer-hand2)
df5f6fcce1be (x-pointer-hand2, x-pointer-top-left-arrow): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 65825
diff changeset
114 (defvar x-pointer-top-left-arrow)
df5f6fcce1be (x-pointer-hand2, x-pointer-top-left-arrow): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 65825
diff changeset
115
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ;;; Code:
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (defvar dframe-xemacsp (string-match "XEmacs" emacs-version)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 "Non-nil if we are running in the XEmacs environment.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (defvar dframe-xemacs20p (and dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (>= emacs-major-version 20)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 ;; From custom web page for compatibility between versions of custom
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 ;; with help from ptype@dera.gov.uk (Proto Type)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (eval-and-compile
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (condition-case ()
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (require 'custom)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (error nil))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;; Some XEmacsen w/ custom don't have :set keyword.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 ;; This protects them against custom.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (fboundp 'custom-initialize-set))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 nil ;; We've got what we needed
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 ;; We have the old custom-library, hack around it!
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (if (boundp 'defgroup)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 (defmacro defgroup (&rest args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 nil))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (if (boundp 'defface)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (defmacro defface (var values doc &rest args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (` (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (defvar (, var) (quote (, var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 ;; To make colors for your faces you need to set your .Xdefaults
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 ;; or set them up ahead of time in your .emacs file.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (make-face (, var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 ))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 (if (boundp 'defcustom)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (defmacro defcustom (var value doc &rest args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (` (defvar (, var) (, value) (, doc)))))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 ;;; Compatibility functions
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (if (fboundp 'frame-parameter)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (defalias 'dframe-frame-parameter 'frame-parameter)
65866
df5f6fcce1be (x-pointer-hand2, x-pointer-top-left-arrow): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 65825
diff changeset
158
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (defun dframe-frame-parameter (frame parameter)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 "Return FRAME's PARAMETER value."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (cdr (assoc parameter (frame-parameters frame)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 ;;; Variables
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (defgroup dframe nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 "Faces used in dframe."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 :prefix "dframe-"
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 :group 'dframe)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (defvar dframe-have-timer-flag
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (and (or (fboundp 'run-with-idle-timer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (fboundp 'start-itimer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (boundp 'post-command-idle-hook))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (if (fboundp 'display-graphic-p)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (display-graphic-p)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 window-system))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 "Non-nil means that timers are available for this Emacs.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (defcustom dframe-update-speed
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (if dframe-xemacs20p
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 2 ; 1 is too obrusive in XEmacs
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 5) ; when no idleness, need long delay
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 "*Idle time in seconds needed before dframe will update itself.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 Updates occur to allow dframe to display directory information
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 relevant to the buffer you are currently editing."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 :group 'dframe
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 :type 'integer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (defcustom dframe-activity-change-focus-flag nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 "*Non-nil means the selected frame will change based on activity.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 Thus, if a file is selected for edit, the buffer will appear in the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 selected frame and the focus will change to that frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 :group 'dframe
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 :type 'boolean)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (defcustom dframe-after-select-attached-frame-hook nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 "*Hook run after dframe has selected the attached frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 :group 'dframe
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 :type 'hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (defvar dframe-track-mouse-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 "*A function to call when the mouse is moved in the given frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 Typically used to display info about the line under the mouse.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (make-variable-buffer-local 'dframe-track-mouse-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (defvar dframe-help-echo-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 "*A function to call when help-echo is used in newer versions of Emacs.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 Typically used to display info about the line under the mouse.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (make-variable-buffer-local 'dframe-help-echo-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (defvar dframe-mouse-click-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 "*A function to call when the mouse is clicked.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 Valid clicks are mouse 2, our double mouse 1.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (make-variable-buffer-local 'dframe-mouse-click-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (defvar dframe-mouse-position-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 "*A function to called to position the cursor for a mouse click.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (make-variable-buffer-local 'dframe-mouse-position-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (defvar dframe-power-click nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 "Never set this by hand. Value is t when S-mouse activity occurs.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (defvar dframe-timer nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 "The dframe timer used for updating the buffer.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (make-variable-buffer-local 'dframe-timer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 (defvar dframe-attached-frame nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 "The frame which started a frame mode.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 This is the frame from which all interesting activities will go
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 for the mode using dframe.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (make-variable-buffer-local 'dframe-attached-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (defvar dframe-controlled nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 "Is this buffer controlled by a dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 Local to those buffers, as a function called that created it.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 (make-variable-buffer-local 'dframe-controlled)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (defun dframe-update-keymap (map)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 "Update the keymap MAP for dframe default bindings."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 ;; Frame control
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (define-key map "q" 'dframe-close-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (define-key map "Q" 'delete-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 ;; Override switch to buffer to never hack our frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (substitute-key-definition 'switch-to-buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 'dframe-switch-buffer-attached-frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 map global-map)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 ;; mouse bindings so we can manipulate the items on each line
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (define-key map 'button2 'dframe-click)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (define-key map '(shift button2) 'dframe-power-click)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ;; Info doc fix from Bob Weiner
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (if (featurep 'infodoc)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (define-key map 'button3 'dframe-xemacs-popup-kludge))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 ;; mouse bindings so we can manipulate the items on each line
65825
b89d9c4d5386 * info.el (Info-next, Info-prev, Info-up): Select info buffer, in
Chong Yidong <cyd@stupidchicken.com>
parents: 65780
diff changeset
264 ;; (define-key map [down-mouse-1] 'dframe-double-click)
b89d9c4d5386 * info.el (Info-next, Info-prev, Info-up): Select info buffer, in
Chong Yidong <cyd@stupidchicken.com>
parents: 65780
diff changeset
265 (define-key map [follow-link] 'mouse-face)
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (define-key map [mouse-2] 'dframe-click)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 ;; This is the power click for new frames, or refreshing a cache
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (define-key map [S-mouse-2] 'dframe-power-click)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 ;; This adds a small unecessary visual effect
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 ;;(define-key map [down-mouse-2] 'dframe-quick-mouse)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (define-key map [down-mouse-3] 'dframe-emacs-popup-kludge)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 ;; This lets the user scroll as if we had a scrollbar... well maybe not
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (define-key map [mode-line mouse-2] 'dframe-mouse-hscroll)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ;; another handy place users might click to get our menu.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (define-key map [mode-line down-mouse-1]
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 'dframe-emacs-popup-kludge)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 ;; We can't switch buffers with the buffer mouse menu. Lets hack it.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (define-key map [C-down-mouse-1] 'dframe-hack-buffer-menu)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 ;; Lastly, we want to track the mouse. Play here
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (define-key map [mouse-movement] 'dframe-track-mouse)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (defun dframe-live-p (frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 "Return non-nil if FRAME is currently available."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (and frame (frame-live-p frame) (frame-visible-p frame)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (defun dframe-frame-mode (arg frame-var cache-var buffer-var frame-name
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 local-mode-fn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 &optional
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 parameters
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 delete-hook popup-hook create-hook
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 "Manage a frame for an application, enabling it when ARG is positive.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 FRAME-VAR is a variable used to cache the frame being used.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 This frame is either resurrected, hidden, killed, etc based on
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 the value.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 CACHE-VAR is a variable used to cache a cached frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 BUFFER-VAR is a variable used to cache the buffer being used in dframe.
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
303 This buffer will have `dframe-frame-mode' run on it.
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 FRAME-NAME is the name of the frame to create.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 LOCAL-MODE-FN is the function used to call this one.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 PARAMETERS are frame parameters to apply to this dframe.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 DELETE-HOOK are hooks to run when deleting a frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 POPUP-HOOK are hooks to run before showing a frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 CREATE-HOOK are hooks to run after creating a frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 ;; toggle frame on and off.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (if (not arg) (if (dframe-live-p (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (setq arg -1) (setq arg 1)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 ;; Make sure the current buffer is set.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (set-buffer (symbol-value buffer-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 ;; turn the frame off on neg number
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (if (and (numberp arg) (< arg 0))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (run-hooks 'delete-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (if (and (symbol-value frame-var)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (frame-live-p (symbol-value frame-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (set cache-var (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (make-frame-invisible (symbol-value frame-var))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (set frame-var nil))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 ;; Set this as our currently attached frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (setq dframe-attached-frame (selected-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (run-hooks 'popup-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 ;; Updated the buffer passed in to contain all the hacks needed
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ;; to make it work well in a dedicated window.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (set-buffer (symbol-value buffer-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 ;; Declare this buffer a dedicated frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (setq dframe-controlled local-mode-fn)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 ;; Hack the XEmacs mouse-motion handler
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (with-no-warnings
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 ;; Hack the XEmacs mouse-motion handler
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 (set (make-local-variable 'mouse-motion-handler)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 'dframe-track-mouse-xemacs)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 ;; Hack the double click handler
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (make-local-variable 'mouse-track-click-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (add-hook 'mouse-track-click-hook
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 (lambda (event count)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (if (/= (event-button event) 1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 nil ; Do normal operations.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (cond ((eq count 1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (dframe-quick-mouse event))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 ((or (eq count 2)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (eq count 3))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (dframe-click event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (dframe-quick-mouse event)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 ;; Don't do normal operations.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 t))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 ;; Enable mouse tracking in emacs
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (if dframe-track-mouse-function
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 (set (make-local-variable 'track-mouse) t)) ;this could be messy.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 ;; disable auto-show-mode for Emacs
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (setq auto-show-mode nil))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 ;;;; DISABLED: This causes problems for users with multiple frames.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 ;;;; ;; Set this up special just for the passed in buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 ;;;; ;; Terminal minibuffer stuff does not require this.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 ;;;; (if (and (or (assoc 'minibuffer parameters)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 ;;;; ;; XEmacs plist is not an association list
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 ;;;; (member 'minibuffer parameters))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 ;;;; window-system (not (eq window-system 'pc))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 ;;;; (null default-minibuffer-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 ;;;; (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 ;;;; (make-local-variable 'default-minibuffer-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 ;;;; (setq default-minibuffer-frame dframe-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;;;; )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ;; Override `temp-buffer-show-hook' so that help and such
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 ;; put their stuff into a frame other than our own.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 ;; Correct use of `temp-buffer-show-function': Bob Weiner
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (if (and (boundp 'temp-buffer-show-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (boundp 'temp-buffer-show-function))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (progn (make-local-variable 'temp-buffer-show-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (setq temp-buffer-show-hook temp-buffer-show-function)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (make-local-variable 'temp-buffer-show-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (setq temp-buffer-show-function 'dframe-temp-buffer-show-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 ;; If this buffer is killed, we must make sure that we destroy
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 ;; the frame the dedicated window is in.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (add-hook 'kill-buffer-hook `(lambda ()
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (let ((skilling (boundp 'skilling)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (if skilling
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (if dframe-controlled
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (funcall dframe-controlled -1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (setq ,buffer-var nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 )))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 t t)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 ;; Get the frame to work in
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (if (frame-live-p (symbol-value cache-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (set frame-var (symbol-value cache-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (make-frame-visible (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (select-frame (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (set-window-dedicated-p (selected-window) nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (if (not (eq (current-buffer) (symbol-value buffer-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (switch-to-buffer (symbol-value buffer-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (set-window-dedicated-p (selected-window) t)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (raise-frame (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (if (frame-live-p (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (raise-frame (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (set frame-var
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 ;; Only guess height if it is not specified.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 (if (member 'height parameters)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (make-frame parameters)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 (make-frame (nconc (list 'height
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (dframe-needed-height))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 parameters)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (let* ((mh (dframe-frame-parameter dframe-attached-frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 'menu-bar-lines))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (paramsa
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 ;; Only add a guessed height if one is not specified
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; in the input parameters.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (if (assoc 'height parameters)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 parameters
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (append
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 parameters
69236
13b406066d9e (dframe-frame-mode): Don't burp when menu-bar-lines is nil.
Nick Roberts <nickrob@snap.net.nz>
parents: 68651
diff changeset
425 (list (cons 'height (+ (or mh 0) (frame-height)))))))
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (params
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 ;; Only add a guessed width if one is not specified
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 ;; in the input parameters.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (if (assoc 'width parameters)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 paramsa
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (append
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 paramsa
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (list (cons 'width (frame-width))))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (if (or (< emacs-major-version 20)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 (not (eq window-system 'x)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (make-frame params)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 (let ((x-pointer-shape x-pointer-top-left-arrow)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (x-sensitive-text-pointer-shape
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 x-pointer-hand2))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 (make-frame params)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 frame)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 ;; Put the buffer into the frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (select-frame (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (switch-to-buffer (symbol-value buffer-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (set-window-dedicated-p (selected-window) t))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 ;; Run hooks (like reposition)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (run-hooks 'create-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 ;; Frame name
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (if (and (or (null window-system) (eq window-system 'pc))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (fboundp 'set-frame-name))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (save-window-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 (select-frame (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (set-frame-name frame-name)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 ;; On a terminal, raise the frame or the user will
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 ;; be confused.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (if (not window-system)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (select-frame (symbol-value frame-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 ))) )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (defun dframe-reposition-frame (new-frame parent-frame location)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 "Move NEW-FRAME to be relative to PARENT-FRAME.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 LOCATION can be one of 'random, 'left, 'right, 'left-right, or 'top-bottom."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 (dframe-reposition-frame-xemacs new-frame parent-frame location)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 (dframe-reposition-frame-emacs new-frame parent-frame location)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (defun dframe-reposition-frame-emacs (new-frame parent-frame location)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 "Move NEW-FRAME to be relative to PARENT-FRAME.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 LOCATION can be one of 'random, 'left-right, 'top-bottom, or
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 a cons cell indicationg a position of the form (LEFT . TOP)."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (let* ((pfx (dframe-frame-parameter parent-frame 'left))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 (pfy (dframe-frame-parameter parent-frame 'top))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (pfw (frame-pixel-width parent-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (pfh (frame-pixel-height parent-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 (nfw (frame-pixel-width new-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 (nfh (frame-pixel-height new-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 newleft newtop
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 ;; Position dframe.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 (if (or (not window-system) (eq window-system 'pc))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 ;; Do no positioning if not on a windowing system,
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 ;; Rebuild pfx,pfy to be absolute positions.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (setq pfx (if (not (consp pfx))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 pfx
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 ;; If pfx is a list, that means we grow
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 ;; from a specific edge of the display.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 ;; Convert that to the distance from the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 ;; left side of the display.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (if (eq (car pfx) '-)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 ;; A - means distance from the right edge
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 ;; of the display, or DW - pfx - framewidth
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (- (x-display-pixel-width) (car (cdr pfx)) pfw)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (car (cdr pfx))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 pfy (if (not (consp pfy))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 pfy
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 ;; If pfy is a list, that means we grow
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 ;; from a specific edge of the display.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 ;; Convert that to the distance from the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 ;; left side of the display.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 (if (eq (car pfy) '-)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 ;; A - means distance from the right edge
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 ;; of the display, or DW - pfx - framewidth
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 (- (x-display-pixel-height) (car (cdr pfy)) pfh)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (car (cdr pfy))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (cond ((eq location 'right)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (setq newleft (+ pfx pfw 5)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 newtop pfy))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 ((eq location 'left)
67226
fd62535b63a8 (dframe-reposition-frame-emacs): Fix position computation for 'left
Romain Francoise <romain@orebokech.com>
parents: 65866
diff changeset
513 (setq newleft (- pfx 10 nfw)
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 newtop pfy))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 ((eq location 'left-right)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 (setq newleft
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 ;; Decide which side to put it on. 200 is just a
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 ;; buffer for the left edge of the screen. The
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 ;; extra 10 is just dressings for window
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 ;; decorations.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (let* ((left-guess (- pfx 10 nfw))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (right-guess (+ pfx pfw 5))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 (left-margin left-guess)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 (right-margin (- (x-display-pixel-width)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 right-guess 5 nfw)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 (cond ((>= left-margin 0) left-guess)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 ((>= right-margin 0) right-guess)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 ;; otherwise choose side we overlap less
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 ((> left-margin right-margin) 0)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 (t (- (x-display-pixel-width) nfw 5))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 newtop pfy
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 ))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 ((eq location 'top-bottom)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 (setq newleft pfx
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 newtop
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 ;; Try and guess if we should be on the top or bottom.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 (let* ((top-guess (- pfy 15 nfh))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 (bottom-guess (+ pfy 5 pfh))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (top-margin top-guess)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 (bottom-margin (- (x-display-pixel-height)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 bottom-guess 5 nfh)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 (cond ((>= top-margin 0) top-guess)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 ((>= bottom-margin 0) bottom-guess)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 ;; Choose a side to overlap the least.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 ((> top-margin bottom-margin) 0)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 (t (- (x-display-pixel-height) nfh 5)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 ((consp location)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 (setq newleft (or (car location) 0)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 newtop (or (cdr location) 0)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 (t nil))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 (modify-frame-parameters new-frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 (list (cons 'left newleft)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 (cons 'top newtop))))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 (defun dframe-reposition-frame-xemacs (new-frame parent-frame location)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 "Move NEW-FRAME to be relative to PARENT-FRAME.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 LOCATION can be one of 'random, 'left-right, or 'top-bottom."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 ;; Not yet implemented
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 ;; XEmacs function only.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 (defun dframe-needed-height (&optional frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 "The needed height for the tool bar FRAME (in characters)."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 (or frame (setq frame (selected-frame)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 ;; The 1 is the missing modeline/minibuffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 (+ 1 (/ (frame-pixel-height frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 ;; This obscure code avoids a byte compiler warning in Emacs.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 (let ((f 'face-height))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 (funcall f 'default frame)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 (defun dframe-detach (frame-var cache-var buffer-var)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 "Detatch the frame in symbol FRAME-VAR.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 CACHE-VAR and BUFFER-VAR are symbols as in `dframe-frame-mode'"
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 (set-buffer (symbol-value buffer-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 (rename-buffer (buffer-name) t)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 (let ((oldframe (symbol-value frame-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 (set buffer-var nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 (set frame-var nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 (set cache-var nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 (make-variable-buffer-local frame-var)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 (set frame-var oldframe)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 )))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 ;;; Special frame event proxies
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 (if (boundp 'special-event-map)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 (progn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 (define-key special-event-map [make-frame-visible]
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 'dframe-handle-make-frame-visible)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 (define-key special-event-map [iconify-frame]
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 'dframe-handle-iconify-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (define-key special-event-map [delete-frame]
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 'dframe-handle-delete-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 (defvar dframe-make-frame-visible-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 "Function used when a dframe controlled frame is de-iconified.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 The function must take an EVENT.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 (defvar dframe-iconify-frame-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 "Function used when a dframe controlled frame is iconified.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 The function must take an EVENT.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 (defvar dframe-delete-frame-function nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 "Function used when a frame attached to a dframe frame is deleted.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 The function must take an EVENT.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 (defun dframe-handle-make-frame-visible (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 "Handle a `make-frame-visible' event.
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
610 Should enable auto-updating if the last state was also enabled.
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611 Argument E is the event making the frame visible."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 (let ((f last-event-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 (if (and (dframe-attached-frame f)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 dframe-make-frame-visible-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 (funcall dframe-make-frame-visible-function e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 )))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 (defun dframe-handle-iconify-frame (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 "Handle a `iconify-frame' event.
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
621 Should disable auto-updating if the last state was also enabled.
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 Argument E is the event iconifying the frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 (let ((f last-event-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 (if (and (dframe-attached-frame f)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 dframe-iconify-frame-function e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627 (funcall dframe-iconify-frame-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 )))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 (defun dframe-handle-delete-frame (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 "Handle `delete-frame' event.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 Argument E is the event deleting the frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 (let ((fl (frame-list))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (sf (selected-frame)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 ;; Loop over all frames. If dframe-delete-frame-function is
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 ;; non-nil, call it.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 (while fl
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 (select-frame (car fl))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 (if dframe-delete-frame-function
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (funcall dframe-delete-frame-function e))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 (setq fl (cdr fl)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 (if (frame-live-p sf)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (select-frame sf))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 (handle-delete-frame e)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 ;;; Utilities
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 (defun dframe-get-focus (frame-var activator &optional hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 "Change frame focus to or from a dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 If the selected frame is not in the symbol FRAME-VAR, then FRAME-VAR
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 frame is selected. If the FRAME-VAR is active, then select the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 attached frame. If FRAME-VAR is nil, ACTIVATOR is called to
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 created it. HOOK is an optional argument of hooks to run when
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
656 selecting FRAME-VAR."
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (interactive)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 (if (eq (selected-frame) (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 (if (frame-live-p dframe-attached-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 (dframe-select-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 ;; make sure we have a frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 (if (not (frame-live-p (symbol-value frame-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
663 (funcall activator 1))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 ;; go there
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (select-frame (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 (other-frame 0)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668 ;; If updates are off, then refresh the frame (they want it now...)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
669 (run-hooks 'hook))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 (defun dframe-close-frame ()
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 "Close the current frame if it is dedicated."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 (interactive)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 (if dframe-controlled
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 (let ((b (current-buffer)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (funcall dframe-controlled -1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 (kill-buffer b))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 (defun dframe-current-frame (frame-var desired-major-mode)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 "Return the existing dedicated frame to use.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682 FRAME-VAR is the variable storing the currently active dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 If the current frame's buffer uses DESIRED-MAJOR-MODE, then use that frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 (if (not (eq (selected-frame) (symbol-value frame-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (if (and (eq major-mode 'desired-major-mode)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (get-buffer-window (current-buffer))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 (window-frame (get-buffer-window (current-buffer))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 (window-frame (get-buffer-window (current-buffer)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 (symbol-value frame-var))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 (symbol-value frame-var)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 (defun dframe-attached-frame (&optional frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 "Return the attached frame belonging to the dframe controlled frame FRAME.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 If optional arg FRAME is nil just return `dframe-attached-frame'."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (if frame (select-frame frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 dframe-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 (defun dframe-select-attached-frame (&optional frame)
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
700 "Switch to the frame the dframe controlled frame FRAME was started from.
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
701 If optional arg FRAME is nil assume the attached frame is already selected
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
702 and just run the hooks `dframe-after-select-attached-frame-hook'. Return
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
703 the attached frame."
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 (let ((frame (dframe-attached-frame frame)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 (if frame (select-frame frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 (prog1 frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 (run-hooks 'dframe-after-select-attached-frame-hook))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 (defmacro dframe-with-attached-buffer (&rest forms)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 "Execute FORMS in the attached frame's special buffer.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 Optionally select that frame if necessary."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 `(save-selected-window
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 ;;(speedbar-set-timer speedbar-update-speed)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (dframe-select-attached-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 ,@forms
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 (dframe-maybee-jump-to-attached-frame)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 (defun dframe-maybee-jump-to-attached-frame ()
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 "Jump to the attached frame ONLY if this was not a mouse event."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 (when (or (not (dframe-mouse-event-p last-input-event))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 dframe-activity-change-focus-flag)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 (dframe-select-attached-frame)
65866
df5f6fcce1be (x-pointer-hand2, x-pointer-top-left-arrow): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 65825
diff changeset
723 ;; KB: For what is this - raising the frame??
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 (other-frame 0)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 (defvar dframe-suppress-message-flag nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 "Non-nil means that `dframe-message' should just return a string.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 (defun dframe-message (fmt &rest args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 "Like message, but for use in a dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 Argument FMT is the format string, and ARGS are the arguments for message."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 (save-selected-window
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 (if dframe-suppress-message-flag
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 (apply 'format fmt args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (if dframe-attached-frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 ;; KB: Here we do not need calling `dframe-select-attached-frame'
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738 (select-frame dframe-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 (apply 'message fmt args))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741 (defun dframe-y-or-n-p (prompt)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 "Like `y-or-n-p', but for use in a dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 Argument PROMPT is the prompt to use."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744 (save-selected-window
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 (if (and ;;default-minibuffer-frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 dframe-attached-frame
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 ;;(not (eq default-minibuffer-frame dframe-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
749 ;; KB: Here we do not need calling `dframe-select-attached-frame'
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750 (select-frame dframe-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751 (y-or-n-p prompt)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 ;;; timer management
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 ;; Unlike speedbar with a dedicated set of routines, dframe has one master
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 ;; timer, and all dframe users will use it. At least until I figure out a way
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 ;; around that problem.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 ;; Advantage 1: Two apps with timer/frames can munge the master list
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 ;; to make sure they occur in order.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 ;; Advantage 2: If a user hits a key between timer functions, we can
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762 ;; interrupt them safely.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 (defvar dframe-client-functions nil
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764 "List of client functions using the dframe timer.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766 (defun dframe-set-timer (timeout fn &optional null-on-error)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 "Apply a timer with TIMEOUT, to call FN, or remove a timer if TIMEOUT is nil.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768 TIMEOUT is the number of seconds until the dframe controled program
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 timer is called again. When TIMEOUT is nil, turn off all timeouts.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 This function must be called from the buffer belonging to the program
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 who requested the timer.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772 If NULL-ON-ERROR is a symbol, set it to nil if we cannot create a timer."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 ;; First, fix up our list of client functions
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 (if timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 (add-to-list 'dframe-client-functions fn)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 (setq dframe-client-functions (delete fn dframe-client-functions)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 ;; Now decided what to do about the timout.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 (if (or
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 ;; We have a timer, restart the timer with the new time.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780 timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781 ;; We have a timer, an off is requested, and no client
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
782 ;; functions are left, shut er down.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
783 (and dframe-timer (not timeout) dframe-client-functions))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 ;; Only call the low level function if we are changing the state.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 (dframe-set-timer-internal timeout null-on-error)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 (defun dframe-set-timer-internal (timeout &optional null-on-error)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788 "Apply a timer with TIMEOUT to call the dframe timer manager.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 If NULL-ON-ERROR is a symbol, set it to nil if we cannot create a timer."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 (cond
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
791 ;; XEmacs
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 (dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 (with-no-warnings
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 (if dframe-timer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 (progn (delete-itimer dframe-timer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
796 (setq dframe-timer nil)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 (if timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 (if (and dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 (or (>= emacs-major-version 21)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 (and (= emacs-major-version 20)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 (> emacs-minor-version 0))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 (and (= emacs-major-version 19)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 (>= emacs-minor-version 15))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 (setq dframe-timer (start-itimer "dframe"
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 'dframe-timer-fn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
807 timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
808 t))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809 (setq dframe-timer (start-itimer "dframe"
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 'dframe-timer-fn
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811 timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
812 nil))))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
813 ;; Post 19.31 Emacs
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
814 ((fboundp 'run-with-idle-timer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (if dframe-timer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
816 (progn (cancel-timer dframe-timer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
817 (setq dframe-timer nil)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
818 (if timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
819 (setq dframe-timer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
820 (run-with-idle-timer timeout t 'dframe-timer-fn))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
821 ;; Emacs 19.30 (Thanks twice: ptype@dra.hmg.gb)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
822 ((fboundp 'post-command-idle-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
823 (if timeout
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824 (add-hook 'post-command-idle-hook 'dframe-timer-fn)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
825 (remove-hook 'post-command-idle-hook 'dframe-timer-fn)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
826 ;; Older or other Emacsen with no timers. Set up so that its
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
827 ;; obvious this emacs can't handle the updates
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
828 ((symbolp null-on-error)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
829 (set null-on-error nil)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
830 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
831
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 (defun dframe-timer-fn ()
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
833 "Called due to the dframe timer.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
834 Evaluates all cached timer functions in sequence."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
835 (let ((l dframe-client-functions))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
836 (while (and l (sit-for 0))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
837 (condition-case er
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
838 (funcall (car l))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
839 (error (message "DFRAME TIMER ERROR: %S" er)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
840 (setq l (cdr l)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
841
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
842 ;;; Menu hacking for mouse-3
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
843 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
844 (defconst dframe-pass-event-to-popup-mode-menu
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
845 (let (max-args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
846 (and (fboundp 'popup-mode-menu)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 (fboundp 'function-max-args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
848 (setq max-args (function-max-args 'popup-mode-menu))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
849 (not (zerop max-args))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
850 "The EVENT arg to 'popup-mode-menu' was introduced in XEmacs 21.4.0.")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
851
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
852 ;; In XEmacs, we make popup menus work on the item over mouse (as
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853 ;; opposed to where the point happens to be.) We attain this by
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
854 ;; temporarily moving the point to that place.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
855 ;; Hrvoje Niksic <hniksic@srce.hr>
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
856 (with-no-warnings
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 (defun dframe-xemacs-popup-kludge (event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
858 "Pop up a menu related to the clicked on item.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
859 Must be bound to EVENT."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
861 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
862 (if dframe-pass-event-to-popup-mode-menu
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
863 (popup-mode-menu event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
864 (goto-char (event-closest-point event))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
865 (beginning-of-line)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
866 (forward-char (min 5 (- (save-excursion (end-of-line) (point))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
867 (save-excursion (beginning-of-line) (point)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
868 (popup-mode-menu))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 ;; Wait for menu to bail out. `popup-mode-menu' (and other popup
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
870 ;; menu functions) return immediately.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
871 (let (new)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
872 (while (not (misc-user-event-p (setq new (next-event))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
873 (dispatch-event new))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
874 (dispatch-event new))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
875 );with-no-warnings
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
876
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
877 (defun dframe-emacs-popup-kludge (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 "Pop up a menu related to the clicked on item.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
879 Must be bound to event E."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
880 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
881 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
882 (mouse-set-point e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 ;; This gets the cursor where the user can see it.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
884 (if (not (bolp)) (forward-char -1))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 (sit-for 0)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
886 (if (< emacs-major-version 20)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 (mouse-major-mode-menu e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888 (mouse-major-mode-menu e nil))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
889
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
890 ;;; Interactive user functions for the mouse
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
892 (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
893 (defalias 'dframe-mouse-event-p 'button-press-event-p)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 (defun dframe-mouse-event-p (event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 "Return t if the event is a mouse related event."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 (if (and (listp event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 (member (event-basic-type event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 '(mouse-1 mouse-2 mouse-3)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 t
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
900 nil)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
902 (defun dframe-track-mouse (event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903 "For motion EVENT, display info about the current line."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
905 (when (and dframe-track-mouse-function
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
906 (or dframe-xemacsp ;; XEmacs always safe?
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 (windowp (posn-window (event-end event))) ; Sometimes
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 ; there is no window to jump into.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 ))
65866
df5f6fcce1be (x-pointer-hand2, x-pointer-top-left-arrow): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 65825
diff changeset
910
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 (funcall dframe-track-mouse-function event)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
912
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 (defun dframe-track-mouse-xemacs (event)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
914 "For motion EVENT, display info about the current line."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915 (if (functionp (default-value 'mouse-motion-handler))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
916 (funcall (default-value 'mouse-motion-handler) event))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
917 (if dframe-track-mouse-function
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 (funcall dframe-track-mouse-function event)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
919
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
920 (defun dframe-help-echo (window &optional buffer position)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
921 "Display help based context.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
922 The context is in WINDOW, viewing BUFFER, at POSITION.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
923 BUFFER and POSITION are optional because XEmacs doesn't use them."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
924 (when (and (not dframe-track-mouse-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
925 (bufferp buffer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
926 dframe-help-echo-function)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927 (let ((dframe-suppress-message-flag t))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 (with-current-buffer buffer
65825
b89d9c4d5386 * info.el (Info-next, Info-prev, Info-up): Select info buffer, in
Chong Yidong <cyd@stupidchicken.com>
parents: 65780
diff changeset
929 (save-excursion
b89d9c4d5386 * info.el (Info-next, Info-prev, Info-up): Select info buffer, in
Chong Yidong <cyd@stupidchicken.com>
parents: 65780
diff changeset
930 (if position (goto-char position))
b89d9c4d5386 * info.el (Info-next, Info-prev, Info-up): Select info buffer, in
Chong Yidong <cyd@stupidchicken.com>
parents: 65780
diff changeset
931 (funcall dframe-help-echo-function))))))
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
932
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
933 (defun dframe-mouse-set-point (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
934 "Set POINT based on event E.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
935 Handles clicking on images in XEmacs."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
936 (if (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
937 (save-window-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
938 (mouse-set-point e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939 (and (fboundp 'event-over-glyph-p) (event-over-glyph-p e))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
940 ;; We are in XEmacs, and clicked on a picture
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941 (with-no-warnings
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
942 (let ((ext (event-glyph-extent e)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
943 ;; This position is back inside the extent where the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
944 ;; junk we pushed into the property list lives.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
945 (if (extent-end-position ext)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946 (goto-char (1- (extent-end-position ext)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 (mouse-set-point e)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
948 );with-no-warnings
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 ;; We are not in XEmacs, OR we didn't click on a picture.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
950 (mouse-set-point e)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
951
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 (defun dframe-quick-mouse (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 "Since mouse events are strange, this will keep the mouse nicely positioned.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 This should be bound to mouse event E."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 (dframe-mouse-set-point e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957 (if dframe-mouse-position-function
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 (funcall dframe-mouse-position-function)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
960 (defun dframe-power-click (e)
68561
6c2778476533 (dframe-handle-make-frame-visible, dframe-handle-iconify-frame,
Juanma Barranquero <lekktu@gmail.com>
parents: 67226
diff changeset
961 "Activate any dframe mouse click as a power click.
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
962 A power click will dispose of cached data (if available) or bring a buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 up into a different window.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 This should be bound to mouse event E."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
965 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
966 (let ((dframe-power-click t))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 (select-frame last-event-frame)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 (dframe-click e)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
970 (defun dframe-click (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
971 "Call our clients click function on a user click.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
972 E is the event causing the click."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
973 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974 (dframe-mouse-set-point e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 (when dframe-mouse-click-function
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
976 ;; On the off chance of buffer switch, or something incorrectly
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
977 ;; configured.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
978 (funcall dframe-mouse-click-function e)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
979
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
980 (defun dframe-double-click (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
981 "Activate the registered click function on a double click.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
982 This must be bound to a mouse event.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
983 This should be bound to mouse event E."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
984 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
985 ;; Emacs only. XEmacs handles this via `mouse-track-click-hook'.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
986 (cond ((eq (car e) 'down-mouse-1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
987 (dframe-mouse-set-point e))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
988 ((eq (car e) 'mouse-1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
989 (dframe-quick-mouse e))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
990 ((or (eq (car e) 'double-down-mouse-1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
991 (eq (car e) 'triple-down-mouse-1))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
992 (dframe-click e))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
993
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
994 ;;; Hacks of normal things.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
995 ;;
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
996 ;; Some normal things that happen in one of these dedicated frames
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
997 ;; must be handled specially, so that our dedicated frame isn't
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
998 ;; messed up.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
999 (defun dframe-temp-buffer-show-function (buffer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1000 "Placed in the variable `temp-buffer-show-function' in dedicated frames.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1001 If a user requests help using \\[help-command] <Key> the temp BUFFER will be
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1002 redirected into a window on the attached frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1003 (if dframe-attached-frame (dframe-select-attached-frame))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1004 (pop-to-buffer buffer nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1005 (other-window -1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1006 ;; Fix for using this hook on some platforms: Bob Weiner
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1007 (cond ((not dframe-xemacsp)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1008 (run-hooks 'temp-buffer-show-hook))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1009 ((fboundp 'run-hook-with-args)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1010 (run-hook-with-args 'temp-buffer-show-hook buffer))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1011 ((and (boundp 'temp-buffer-show-hook)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1012 (listp temp-buffer-show-hook))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1013 (mapcar (function (lambda (hook) (funcall hook buffer)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1014 temp-buffer-show-hook))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1015
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1016 (defun dframe-hack-buffer-menu (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1017 "Control mouse 1 is buffer menu.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1018 This hack overrides it so that the right thing happens in the main
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1019 Emacs frame, not in the dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1020 Argument E is the event causing this activity."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1021 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1022 (let ((fn (lookup-key global-map (if dframe-xemacsp
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1023 '(control button1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1024 [C-down-mouse-1])))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1025 (oldbuff (current-buffer))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1026 (newbuff nil))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1027 (unwind-protect
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1028 (save-excursion
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1029 (set-window-dedicated-p (selected-window) nil)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1030 (call-interactively fn)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1031 (setq newbuff (current-buffer)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1032 (switch-to-buffer oldbuff)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1033 (set-window-dedicated-p (selected-window) t))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1034 (if (not (eq newbuff oldbuff))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1035 (dframe-with-attached-buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1036 (switch-to-buffer newbuff)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1037
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1038 (defun dframe-switch-buffer-attached-frame (&optional buffer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1039 "Switch to BUFFER in the attached frame, and raise that frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1040 This overrides the default behavior of `switch-to-buffer' which is
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1041 broken because of the dedicated frame."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1042 (interactive)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1043 ;; Assume we are in the dedicated frame.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1044 (other-frame 1)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1045 ;; Now switch buffers
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1046 (if buffer
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1047 (switch-to-buffer buffer)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1048 (call-interactively 'switch-to-buffer nil nil)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1049
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1050 ;; XEmacs: this can be implemented using modeline keymaps, but there
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1051 ;; is no use, as we have horizontal scrollbar (as the docstring
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1052 ;; hints.)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1053 (defun dframe-mouse-hscroll (e)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1054 "Read a mouse event E from the mode line, and horizontally scroll.
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1055 If the mouse is being clicked on the far left, or far right of the
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1056 mode-line. This is only useful for non-XEmacs."
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1057 (interactive "e")
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1058 (let* ((x-point (car (nth 2 (car (cdr e)))))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1059 (pixels-per-10-col (/ (* 10 (frame-pixel-width))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1060 (frame-width)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1061 (click-col (1+ (/ (* 10 x-point) pixels-per-10-col)))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1062 )
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1063 (cond ((< click-col 3)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1064 (scroll-left 2))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1065 ((> click-col (- (window-width) 5))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1066 (scroll-right 2))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1067 (t (dframe-message
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1068 "Click on the edge of the modeline to scroll left/right")))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1069 ))
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1070
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1071 (provide 'dframe)
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1072
65779
103ed0b7e567 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 65753
diff changeset
1073 ;; arch-tag: df9b91b6-e85e-4a76-a02e-b3cb5b686bd4
65753
3d159a94747e * dframe.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1074 ;;; dframe.el ends here