diff options
| author | Miles Bader | 2007-11-11 00:56:44 +0000 |
|---|---|---|
| committer | Miles Bader | 2007-11-11 00:56:44 +0000 |
| commit | f23d76bdefbd4c06e14d69e99e50d35ce91c8226 (patch) | |
| tree | ded28d1da6df2d0135514bac83074f4ca1c9099a /lisp/obsolete | |
| parent | e2d092da5980a7d05a5428074f8eb4925fa801e8 (diff) | |
| parent | a457417ee5ba797ab1c91d35ee957bb7a7f8d4b6 (diff) | |
| download | emacs-f23d76bdefbd4c06e14d69e99e50d35ce91c8226.tar.gz emacs-f23d76bdefbd4c06e14d69e99e50d35ce91c8226.zip | |
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
Diffstat (limited to 'lisp/obsolete')
| -rw-r--r-- | lisp/obsolete/lselect.el | 247 | ||||
| -rw-r--r-- | lisp/obsolete/sun-curs.el | 234 | ||||
| -rw-r--r-- | lisp/obsolete/sun-fns.el | 644 |
3 files changed, 247 insertions, 878 deletions
diff --git a/lisp/obsolete/lselect.el b/lisp/obsolete/lselect.el new file mode 100644 index 00000000000..d457f775a03 --- /dev/null +++ b/lisp/obsolete/lselect.el | |||
| @@ -0,0 +1,247 @@ | |||
| 1 | ;;; lselect.el --- Lucid interface to X Selections | ||
| 2 | |||
| 3 | ;; Copyright (C) 1990, 1993, 2001, 2002, 2003, 2004, | ||
| 4 | ;; 2005, 2006, 2007 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | ;; Maintainer: FSF | ||
| 7 | ;; Keywords: emulations | ||
| 8 | |||
| 9 | ;; This won't completely work until we support or emulate Lucid-style extents. | ||
| 10 | ;; Based on Lucid's selection code. | ||
| 11 | |||
| 12 | ;; This file is part of GNU Emacs. | ||
| 13 | |||
| 14 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 15 | ;; it under the terms of the GNU General Public License as published by | ||
| 16 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 17 | ;; any later version. | ||
| 18 | |||
| 19 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 20 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 21 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 22 | ;; GNU General Public License for more details. | ||
| 23 | |||
| 24 | ;; You should have received a copy of the GNU General Public License | ||
| 25 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 26 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 27 | ;; Boston, MA 02110-1301, USA. | ||
| 28 | |||
| 29 | ;;; Commentary: | ||
| 30 | |||
| 31 | ;;; Code: | ||
| 32 | |||
| 33 | ;; The selection code requires us to use certain symbols whose names are | ||
| 34 | ;; all upper-case; this may seem tasteless, but it makes there be a 1:1 | ||
| 35 | ;; correspondence between these symbols and X Atoms (which are upcased.) | ||
| 36 | |||
| 37 | ;; This is Lucid/XEmacs stuff | ||
| 38 | (defvar mouse-highlight-priority) | ||
| 39 | (defvar x-lost-selection-functions) | ||
| 40 | (defvar zmacs-regions) | ||
| 41 | |||
| 42 | (defalias 'x-get-cutbuffer 'x-get-cut-buffer) | ||
| 43 | (defalias 'x-store-cutbuffer 'x-set-cut-buffer) | ||
| 44 | |||
| 45 | (or (facep 'primary-selection) | ||
| 46 | (make-face 'primary-selection)) | ||
| 47 | |||
| 48 | (or (facep 'secondary-selection) | ||
| 49 | (make-face 'secondary-selection)) | ||
| 50 | |||
| 51 | (defun x-get-secondary-selection () | ||
| 52 | "Return text selected from some X window." | ||
| 53 | (x-get-selection-internal 'SECONDARY 'STRING)) | ||
| 54 | |||
| 55 | (defvar primary-selection-extent nil | ||
| 56 | "The extent of the primary selection; don't use this.") | ||
| 57 | |||
| 58 | (defvar secondary-selection-extent nil | ||
| 59 | "The extent of the secondary selection; don't use this.") | ||
| 60 | |||
| 61 | |||
| 62 | (defun x-select-make-extent-for-selection (selection previous-extent face) | ||
| 63 | ;; Given a selection, this makes an extent in the buffer which holds that | ||
| 64 | ;; selection, for highlighting purposes. If the selection isn't associated | ||
| 65 | ;; with a buffer, this does nothing. | ||
| 66 | (let ((buffer nil) | ||
| 67 | (valid (and (extentp previous-extent) | ||
| 68 | (extent-buffer previous-extent) | ||
| 69 | (buffer-name (extent-buffer previous-extent)))) | ||
| 70 | start end) | ||
| 71 | (cond ((stringp selection) | ||
| 72 | ;; if we're selecting a string, lose the previous extent used | ||
| 73 | ;; to highlight the selection. | ||
| 74 | (setq valid nil)) | ||
| 75 | ((consp selection) | ||
| 76 | (setq start (min (car selection) (cdr selection)) | ||
| 77 | end (max (car selection) (cdr selection)) | ||
| 78 | valid (and valid | ||
| 79 | (eq (marker-buffer (car selection)) | ||
| 80 | (extent-buffer previous-extent))) | ||
| 81 | buffer (marker-buffer (car selection)))) | ||
| 82 | ((extentp selection) | ||
| 83 | (setq start (extent-start-position selection) | ||
| 84 | end (extent-end-position selection) | ||
| 85 | valid (and valid | ||
| 86 | (eq (extent-buffer selection) | ||
| 87 | (extent-buffer previous-extent))) | ||
| 88 | buffer (extent-buffer selection))) | ||
| 89 | ) | ||
| 90 | (if (and (not valid) | ||
| 91 | (extentp previous-extent) | ||
| 92 | (extent-buffer previous-extent) | ||
| 93 | (buffer-name (extent-buffer previous-extent))) | ||
| 94 | (delete-extent previous-extent)) | ||
| 95 | (if (not buffer) | ||
| 96 | ;; string case | ||
| 97 | nil | ||
| 98 | ;; normal case | ||
| 99 | (if valid | ||
| 100 | (set-extent-endpoints previous-extent start end) | ||
| 101 | (setq previous-extent (make-extent start end buffer)) | ||
| 102 | ;; use same priority as mouse-highlighting so that conflicts between | ||
| 103 | ;; the selection extent and a mouse-highlighted extent are resolved | ||
| 104 | ;; by the usual size-and-endpoint-comparison method. | ||
| 105 | (set-extent-priority previous-extent mouse-highlight-priority) | ||
| 106 | (set-extent-face previous-extent face))))) | ||
| 107 | |||
| 108 | |||
| 109 | (defun x-own-selection (selection &optional type) | ||
| 110 | "Make a primary X Selection of the given argument. | ||
| 111 | The argument may be a string, a cons of two markers, or an extent. | ||
| 112 | In the latter cases the selection is considered to be the text | ||
| 113 | between the markers, or the between extents endpoints." | ||
| 114 | (interactive (if (not current-prefix-arg) | ||
| 115 | (list (read-string "Store text for pasting: ")) | ||
| 116 | (list (cons ;; these need not be ordered. | ||
| 117 | (copy-marker (point-marker)) | ||
| 118 | (copy-marker (mark-marker)))))) | ||
| 119 | (or type (setq type 'PRIMARY)) | ||
| 120 | (x-set-selection selection type) | ||
| 121 | (cond ((eq type 'PRIMARY) | ||
| 122 | (setq primary-selection-extent | ||
| 123 | (x-select-make-extent-for-selection | ||
| 124 | selection primary-selection-extent 'primary-selection))) | ||
| 125 | ((eq type 'SECONDARY) | ||
| 126 | (setq secondary-selection-extent | ||
| 127 | (x-select-make-extent-for-selection | ||
| 128 | selection secondary-selection-extent 'secondary-selection)))) | ||
| 129 | selection) | ||
| 130 | |||
| 131 | |||
| 132 | (defun x-own-secondary-selection (selection &optional type) | ||
| 133 | "Make a secondary X Selection of the given argument. The argument may be a | ||
| 134 | string or a cons of two markers (in which case the selection is considered to | ||
| 135 | be the text between those markers.)" | ||
| 136 | (interactive (if (not current-prefix-arg) | ||
| 137 | (list (read-string "Store text for pasting: ")) | ||
| 138 | (list (cons ;; these need not be ordered. | ||
| 139 | (copy-marker (point-marker)) | ||
| 140 | (copy-marker (mark-marker)))))) | ||
| 141 | (x-own-selection selection 'SECONDARY)) | ||
| 142 | |||
| 143 | |||
| 144 | (defun x-own-clipboard (string) | ||
| 145 | "Paste the given string to the X Clipboard." | ||
| 146 | (x-own-selection string 'CLIPBOARD)) | ||
| 147 | |||
| 148 | |||
| 149 | (defun x-disown-selection (&optional secondary-p) | ||
| 150 | "Assuming we own the selection, disown it. With an argument, discard the | ||
| 151 | secondary selection instead of the primary selection." | ||
| 152 | (x-disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY))) | ||
| 153 | |||
| 154 | (defun x-dehilight-selection (selection) | ||
| 155 | "for use as a value of `x-lost-selection-functions'." | ||
| 156 | (cond ((eq selection 'PRIMARY) | ||
| 157 | (if primary-selection-extent | ||
| 158 | (let ((inhibit-quit t)) | ||
| 159 | (delete-extent primary-selection-extent) | ||
| 160 | (setq primary-selection-extent nil))) | ||
| 161 | (if zmacs-regions (zmacs-deactivate-region))) | ||
| 162 | ((eq selection 'SECONDARY) | ||
| 163 | (if secondary-selection-extent | ||
| 164 | (let ((inhibit-quit t)) | ||
| 165 | (delete-extent secondary-selection-extent) | ||
| 166 | (setq secondary-selection-extent nil))))) | ||
| 167 | nil) | ||
| 168 | |||
| 169 | (setq x-lost-selection-functions 'x-dehilight-selection) | ||
| 170 | |||
| 171 | (defun x-notice-selection-requests (selection type successful) | ||
| 172 | "for possible use as the value of `x-sent-selection-functions'." | ||
| 173 | (if (not successful) | ||
| 174 | (message "Selection request failed to convert %s to %s" | ||
| 175 | selection type) | ||
| 176 | (message "Sent selection %s as %s" selection type))) | ||
| 177 | |||
| 178 | (defun x-notice-selection-failures (selection type successful) | ||
| 179 | "for possible use as the value of `x-sent-selection-functions'." | ||
| 180 | (or successful | ||
| 181 | (message "Selection request failed to convert %s to %s" | ||
| 182 | selection type))) | ||
| 183 | |||
| 184 | ;(setq x-sent-selection-functions 'x-notice-selection-requests) | ||
| 185 | ;(setq x-sent-selection-functions 'x-notice-selection-failures) | ||
| 186 | |||
| 187 | |||
| 188 | ;; Random utility functions | ||
| 189 | |||
| 190 | (defun x-kill-primary-selection () | ||
| 191 | "If there is a selection, delete the text it covers, and copy it to | ||
| 192 | both the kill ring and the Clipboard." | ||
| 193 | (interactive) | ||
| 194 | (or (x-selection-owner-p) (error "Emacs does not own the primary selection")) | ||
| 195 | (setq last-command nil) | ||
| 196 | (or primary-selection-extent | ||
| 197 | (error "the primary selection is not an extent?")) | ||
| 198 | (save-excursion | ||
| 199 | (set-buffer (extent-buffer primary-selection-extent)) | ||
| 200 | (kill-region (extent-start-position primary-selection-extent) | ||
| 201 | (extent-end-position primary-selection-extent))) | ||
| 202 | (x-disown-selection nil)) | ||
| 203 | |||
| 204 | (defun x-delete-primary-selection () | ||
| 205 | "If there is a selection, delete the text it covers *without* copying it to | ||
| 206 | the kill ring or the Clipboard." | ||
| 207 | (interactive) | ||
| 208 | (or (x-selection-owner-p) (error "Emacs does not own the primary selection")) | ||
| 209 | (setq last-command nil) | ||
| 210 | (or primary-selection-extent | ||
| 211 | (error "the primary selection is not an extent?")) | ||
| 212 | (save-excursion | ||
| 213 | (set-buffer (extent-buffer primary-selection-extent)) | ||
| 214 | (delete-region (extent-start-position primary-selection-extent) | ||
| 215 | (extent-end-position primary-selection-extent))) | ||
| 216 | (x-disown-selection nil)) | ||
| 217 | |||
| 218 | (defun x-copy-primary-selection () | ||
| 219 | "If there is a selection, copy it to both the kill ring and the Clipboard." | ||
| 220 | (interactive) | ||
| 221 | (setq last-command nil) | ||
| 222 | (or (x-selection-owner-p) (error "Emacs does not own the primary selection")) | ||
| 223 | (or primary-selection-extent | ||
| 224 | (error "the primary selection is not an extent?")) | ||
| 225 | (save-excursion | ||
| 226 | (set-buffer (extent-buffer primary-selection-extent)) | ||
| 227 | (copy-region-as-kill (extent-start-position primary-selection-extent) | ||
| 228 | (extent-end-position primary-selection-extent)))) | ||
| 229 | |||
| 230 | (defun x-yank-clipboard-selection () | ||
| 231 | "If someone owns a Clipboard selection, insert it at point." | ||
| 232 | (interactive) | ||
| 233 | (setq last-command nil) | ||
| 234 | (let ((clip (x-get-clipboard))) | ||
| 235 | (or clip (error "there is no clipboard selection")) | ||
| 236 | (push-mark) | ||
| 237 | (insert clip))) | ||
| 238 | |||
| 239 | (provide 'lselect) | ||
| 240 | |||
| 241 | |||
| 242 | ;; Local variables: | ||
| 243 | ;; byte-compile-warnings: (not unresolved) | ||
| 244 | ;; End: | ||
| 245 | |||
| 246 | ;; arch-tag: 92fa54d4-c5d1-4e9b-ad58-cf1e13930556 | ||
| 247 | ;;; lselect.el ends here | ||
diff --git a/lisp/obsolete/sun-curs.el b/lisp/obsolete/sun-curs.el deleted file mode 100644 index 612102159df..00000000000 --- a/lisp/obsolete/sun-curs.el +++ /dev/null | |||
| @@ -1,234 +0,0 @@ | |||
| 1 | ;;; sun-curs.el --- cursor definitions for Sun windows | ||
| 2 | |||
| 3 | ;; Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, | ||
| 4 | ;; 2006, 2007 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | ;; Author: Jeff Peck <peck@sun.com> | ||
| 7 | ;; Keywords: hardware | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 14 | ;; any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 23 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 24 | ;; Boston, MA 02110-1301, USA. | ||
| 25 | |||
| 26 | ;;; Commentary: | ||
| 27 | |||
| 28 | ;;; Code: | ||
| 29 | |||
| 30 | ;;; | ||
| 31 | ;;; Added some more cursors and moved the hot spots | ||
| 32 | ;;; Cursor defined by 16 pairs of 16-bit numbers | ||
| 33 | ;;; | ||
| 34 | ;;; 9-dec-86 Jeff Peck, Sun Microsystems Inc. <peck@sun.com> | ||
| 35 | |||
| 36 | (eval-when-compile (require 'cl)) | ||
| 37 | |||
| 38 | (defvar *edit-icon*) | ||
| 39 | (defvar char) | ||
| 40 | ;; These are from term/sun-mouse.el | ||
| 41 | (defvar *mouse-window*) | ||
| 42 | (defvar *mouse-x*) | ||
| 43 | (defvar *mouse-y*) | ||
| 44 | (defvar menu) | ||
| 45 | |||
| 46 | (require 'sun-fns) | ||
| 47 | |||
| 48 | (eval-and-compile | ||
| 49 | (defvar sc::cursors nil "List of known cursors")) | ||
| 50 | |||
| 51 | (defmacro defcursor (name x y string) | ||
| 52 | (if (not (memq name sc::cursors)) | ||
| 53 | (setq sc::cursors (cons name sc::cursors))) | ||
| 54 | (list 'defconst name (list 'vector x y string))) | ||
| 55 | |||
| 56 | ;;; push should be defined in common lisp, but if not use this: | ||
| 57 | ;(defmacro push (v l) | ||
| 58 | ; "The ITEM is evaluated and consed onto LIST, a list-valued atom" | ||
| 59 | ; (list 'setq l (list 'cons v l))) | ||
| 60 | |||
| 61 | ;;; | ||
| 62 | ;;; The standard default cursor | ||
| 63 | ;;; | ||
| 64 | (defcursor sc:right-arrow 15 0 | ||
| 65 | (concat '(0 1 0 3 0 7 0 15 0 31 0 63 0 127 0 15 | ||
| 66 | 0 27 0 25 0 48 0 48 0 96 0 96 0 192 0 192))) | ||
| 67 | |||
| 68 | ;;(sc:set-cursor sc:right-arrow) | ||
| 69 | |||
| 70 | (defcursor sc:fat-left-arrow 0 8 | ||
| 71 | (concat '(1 0 3 0 7 0 15 0 31 0 63 255 127 255 255 255 | ||
| 72 | 255 255 127 255 63 255 31 0 15 0 7 0 3 0 1 0))) | ||
| 73 | |||
| 74 | (defcursor sc:box 8 8 | ||
| 75 | (concat '(15 252 8 4 8 4 8 4 8 4 8 4 8 4 8 4 | ||
| 76 | 8 132 8 4 8 4 8 4 8 4 8 4 8 4 15 252))) | ||
| 77 | |||
| 78 | (defcursor sc:hourglass 8 8 | ||
| 79 | (concat "\177\376\100\002\040\014\032\070" | ||
| 80 | "\017\360\007\340\003\300\001\200" | ||
| 81 | "\001\200\002\100\005\040\010\020" | ||
| 82 | "\021\210\043\304\107\342\177\376")) | ||
| 83 | |||
| 84 | (defun sc:set-cursor (icon) | ||
| 85 | "Change the Sun mouse cursor to ICON. | ||
| 86 | If ICON is nil, switch to the system default cursor, | ||
| 87 | Otherwise, ICON should be a vector or the name of a vector of [x y 32-chars]" | ||
| 88 | (interactive "XIcon Name: ") | ||
| 89 | (if (symbolp icon) (setq icon (symbol-value icon))) | ||
| 90 | (sun-change-cursor-icon icon)) | ||
| 91 | |||
| 92 | ;; This does not make much sense... | ||
| 93 | (make-local-variable '*edit-icon*) | ||
| 94 | |||
| 95 | (defvar icon-edit nil) | ||
| 96 | (make-variable-buffer-local 'icon-edit) | ||
| 97 | (or (assq 'icon-edit minor-mode-alist) | ||
| 98 | (push '(icon-edit " IconEdit") minor-mode-alist)) | ||
| 99 | |||
| 100 | (defun sc:edit-cursor (icon) | ||
| 101 | "convert icon to rectangle, edit, and repack" | ||
| 102 | (interactive "XIcon Name: ") | ||
| 103 | (if (not icon) (setq icon (sc::menu-choose-cursor (selected-window) 1 1))) | ||
| 104 | (if (symbolp icon) (setq icon (symbol-value icon))) | ||
| 105 | (if (get-buffer "icon-edit") (kill-buffer "icon-edit")) | ||
| 106 | (switch-to-buffer "icon-edit") | ||
| 107 | (local-set-mouse '(text right) 'sc::menu-function) | ||
| 108 | (local-set-mouse '(text left) '(sc::pic-ins-at-mouse 32)) | ||
| 109 | (local-set-mouse '(text middle) '(sc::pic-ins-at-mouse 64)) | ||
| 110 | (local-set-mouse '(text left middle) 'sc::hotspot) | ||
| 111 | (sc::display-icon icon) | ||
| 112 | (picture-mode) | ||
| 113 | (setq icon-edit t) ; for mode line display | ||
| 114 | ) | ||
| 115 | |||
| 116 | (defun sc::pic-ins-at-mouse (char) | ||
| 117 | "Picture insert char at mouse location" | ||
| 118 | (mouse-move-point *mouse-window* (min 15 *mouse-x*) (min 15 *mouse-y*)) | ||
| 119 | (move-to-column (1+ (min 15 (current-column))) t) | ||
| 120 | (delete-char -1) | ||
| 121 | (insert char) | ||
| 122 | (sc::goto-hotspot)) | ||
| 123 | |||
| 124 | (defmenu sc::menu | ||
| 125 | ("Cursor Menu") | ||
| 126 | ("Pack & Use" sc::pack-buffer-to-cursor) | ||
| 127 | ("Pack to Icon" sc::pack-buffer-to-icon | ||
| 128 | (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) | ||
| 129 | ("New Icon" call-interactively 'sc::make-cursor) | ||
| 130 | ("Edit Icon" sc:edit-cursor | ||
| 131 | (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) | ||
| 132 | ("Set Cursor" sc:set-cursor | ||
| 133 | (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) | ||
| 134 | ("Reset Cursor" sc:set-cursor nil) | ||
| 135 | ("Help" sc::edit-icon-help-menu) | ||
| 136 | ("Quit" sc::quit-edit) | ||
| 137 | ) | ||
| 138 | |||
| 139 | (defun sc::menu-function (window x y) | ||
| 140 | (sun-menu-evaluate window (1+ x) y sc::menu)) | ||
| 141 | |||
| 142 | (defun sc::quit-edit () | ||
| 143 | (interactive) | ||
| 144 | (bury-buffer (current-buffer)) | ||
| 145 | (switch-to-buffer (other-buffer) 'no-record)) | ||
| 146 | |||
| 147 | (defun sc::make-cursor (symbol) | ||
| 148 | (interactive "SIcon Name: ") | ||
| 149 | (eval (list 'defcursor symbol 0 0 "")) | ||
| 150 | (sc::pack-buffer-to-icon (symbol-value symbol))) | ||
| 151 | |||
| 152 | (defmenu sc::edit-icon-help-menu | ||
| 153 | ("Simple Icon Editor") | ||
| 154 | ("Left => CLEAR") | ||
| 155 | ("Middle => SET") | ||
| 156 | ("L & M => HOTSPOT") | ||
| 157 | ("Right => MENU")) | ||
| 158 | |||
| 159 | (defun sc::edit-icon-help () | ||
| 160 | (message "Left=> CLEAR Middle=> SET Left+Middle=> HOTSPOT Right=> MENU")) | ||
| 161 | |||
| 162 | (defun sc::pack-buffer-to-cursor () | ||
| 163 | (sc::pack-buffer-to-icon *edit-icon*) | ||
| 164 | (sc:set-cursor *edit-icon*)) | ||
| 165 | |||
| 166 | (defun sc::menu-choose-cursor (window x y) | ||
| 167 | "Presents a menu of cursor names, and returns one or nil" | ||
| 168 | (let ((curs sc::cursors) | ||
| 169 | (items)) | ||
| 170 | (while curs | ||
| 171 | (push (sc::menu-item-for-cursor (car curs)) items) | ||
| 172 | (setq curs (cdr curs))) | ||
| 173 | (push (list "Choose Cursor") items) | ||
| 174 | (setq menu (menu-create items)) | ||
| 175 | (sun-menu-evaluate window x y menu))) | ||
| 176 | |||
| 177 | (defun sc::menu-item-for-cursor (cursor) | ||
| 178 | "apply function to selected cursor" | ||
| 179 | (list (symbol-name cursor) 'quote cursor)) | ||
| 180 | |||
| 181 | (defun sc::hotspot (window x y) | ||
| 182 | (aset *edit-icon* 0 x) | ||
| 183 | (aset *edit-icon* 1 y) | ||
| 184 | (sc::goto-hotspot)) | ||
| 185 | |||
| 186 | (defun sc::goto-hotspot () | ||
| 187 | (goto-line (1+ (aref *edit-icon* 1))) | ||
| 188 | (move-to-column (aref *edit-icon* 0))) | ||
| 189 | |||
| 190 | (defun sc::display-icon (icon) | ||
| 191 | (setq *edit-icon* (copy-sequence icon)) | ||
| 192 | (let ((string (aref *edit-icon* 2)) | ||
| 193 | (index 0)) | ||
| 194 | (while (< index 32) | ||
| 195 | (let ((char (aref string index)) | ||
| 196 | (bit 128)) | ||
| 197 | (while (> bit 0) | ||
| 198 | (insert (sc::char-at-bit char bit)) | ||
| 199 | (setq bit (lsh bit -1)))) | ||
| 200 | (if (eq 1 (% index 2)) (newline)) | ||
| 201 | (setq index (1+ index)))) | ||
| 202 | (sc::goto-hotspot)) | ||
| 203 | |||
| 204 | (defun sc::char-at-bit (char bit) | ||
| 205 | (if (> (logand char bit) 0) "@" " ")) | ||
| 206 | |||
| 207 | (defun sc::pack-buffer-to-icon (icon) | ||
| 208 | "Pack 16 x 16 field into icon string" | ||
| 209 | (goto-char (point-min)) | ||
| 210 | (aset icon 0 (aref *edit-icon* 0)) | ||
| 211 | (aset icon 1 (aref *edit-icon* 1)) | ||
| 212 | (aset icon 2 (mapconcat 'sc::pack-one-line "1234567890123456" "")) | ||
| 213 | (sc::goto-hotspot) | ||
| 214 | ) | ||
| 215 | |||
| 216 | (defun sc::pack-one-line (dummy) | ||
| 217 | (let (char chr1 chr2) | ||
| 218 | (setq char 0 chr1 (mapconcat 'sc::pack-one-char "12345678" "") chr1 char) | ||
| 219 | (setq char 0 chr2 (mapconcat 'sc::pack-one-char "12345678" "") chr2 char) | ||
| 220 | (forward-line 1) | ||
| 221 | (concat (char-to-string chr1) (char-to-string chr2)) | ||
| 222 | )) | ||
| 223 | |||
| 224 | (defun sc::pack-one-char (dummy) | ||
| 225 | "pack following char into char, unless eolp" | ||
| 226 | (if (or (eolp) (char-equal (following-char) 32)) | ||
| 227 | (setq char (lsh char 1)) | ||
| 228 | (setq char (1+ (lsh char 1)))) | ||
| 229 | (if (not (eolp))(forward-char))) | ||
| 230 | |||
| 231 | (provide 'sun-curs) | ||
| 232 | |||
| 233 | ;;; arch-tag: 7cc861e5-e2d9-4191-b211-2baaaab54e78 | ||
| 234 | ;;; sun-curs.el ends here | ||
diff --git a/lisp/obsolete/sun-fns.el b/lisp/obsolete/sun-fns.el deleted file mode 100644 index 1b6a5d239bd..00000000000 --- a/lisp/obsolete/sun-fns.el +++ /dev/null | |||
| @@ -1,644 +0,0 @@ | |||
| 1 | ;;; sun-fns.el --- subroutines of Mouse handling for Sun windows | ||
| 2 | |||
| 3 | ;; Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, | ||
| 4 | ;; 2006, 2007 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | ;; Author: Jeff Peck <peck@sun.com> | ||
| 7 | ;; Maintainer: none | ||
| 8 | ;; Keywords: hardware | ||
| 9 | |||
| 10 | ;; This file is part of GNU Emacs. | ||
| 11 | |||
| 12 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 13 | ;; it under the terms of the GNU General Public License as published by | ||
| 14 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 15 | ;; any later version. | ||
| 16 | |||
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | |||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 24 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 25 | ;; Boston, MA 02110-1301, USA. | ||
| 26 | |||
| 27 | ;;; Commentary: | ||
| 28 | |||
| 29 | ;; Submitted Mar. 1987, Jeff Peck | ||
| 30 | ;; Sun Microsystems Inc. <peck@sun.com> | ||
| 31 | ;; Conceived Nov. 1986, Stan Jefferson, | ||
| 32 | ;; Computer Science Lab, SRI International. | ||
| 33 | ;; GoodIdeas Feb. 1987, Steve Greenbaum | ||
| 34 | ;; & UpClicks Reasoning Systems, Inc. | ||
| 35 | ;; | ||
| 36 | ;; | ||
| 37 | ;; Functions for manipulating via the mouse and mouse-map definitions | ||
| 38 | ;; for accessing them. Also definitions of mouse menus. | ||
| 39 | ;; This file you should freely modify to reflect you personal tastes. | ||
| 40 | ;; | ||
| 41 | ;; First half of file defines functions to implement mouse commands, | ||
| 42 | ;; Don't delete any of those, just add what ever else you need. | ||
| 43 | ;; Second half of file defines mouse bindings, do whatever you want there. | ||
| 44 | |||
| 45 | ;; | ||
| 46 | ;; Mouse Functions. | ||
| 47 | ;; | ||
| 48 | ;; These functions follow the sun-mouse-handler convention of being called | ||
| 49 | ;; with three arguments: (window x-pos y-pos) | ||
| 50 | ;; This makes it easy for a mouse executed command to know where the mouse is. | ||
| 51 | ;; Use the macro "eval-in-window" to execute a function | ||
| 52 | ;; in a temporarily selected window. | ||
| 53 | ;; | ||
| 54 | ;; If you have a function that must be called with other arguments | ||
| 55 | ;; bind the mouse button to an s-exp that contains the necessary parameters. | ||
| 56 | ;; See "minibuffer" bindings for examples. | ||
| 57 | ;; | ||
| 58 | |||
| 59 | ;;; Code: | ||
| 60 | |||
| 61 | (require 'term/sun-mouse) | ||
| 62 | |||
| 63 | (defconst cursor-pause-milliseconds 300 | ||
| 64 | "*Number of milliseconds to display alternate cursor (usually the mark)") | ||
| 65 | |||
| 66 | (defun indicate-region (&optional pause) | ||
| 67 | "Bounce cursor to mark for cursor-pause-milliseconds and back again" | ||
| 68 | (or pause (setq pause cursor-pause-milliseconds)) | ||
| 69 | (let ((point (point))) | ||
| 70 | (goto-char (mark)) | ||
| 71 | (sit-for-millisecs pause) | ||
| 72 | ;(update-display) | ||
| 73 | ;(sleep-for-millisecs pause) | ||
| 74 | (goto-char point))) | ||
| 75 | |||
| 76 | |||
| 77 | ;;; | ||
| 78 | ;;; Text buffer operations | ||
| 79 | ;;; | ||
| 80 | (defun mouse-move-point (window x y) | ||
| 81 | "Move point to mouse cursor." | ||
| 82 | (select-window window) | ||
| 83 | (move-to-loc x y) | ||
| 84 | (if (memq last-command ; support the mouse-copy/delete/yank | ||
| 85 | '(mouse-copy mouse-delete mouse-yank-move)) | ||
| 86 | (setq this-command 'mouse-yank-move)) | ||
| 87 | ) | ||
| 88 | |||
| 89 | (defun mouse-set-mark (&optional window x y) | ||
| 90 | "Set mark at mouse cursor." | ||
| 91 | (eval-in-window window ;; use this to get the unwind protect | ||
| 92 | (let ((point (point))) | ||
| 93 | (move-to-loc x y) | ||
| 94 | (set-mark (point)) | ||
| 95 | (goto-char point) | ||
| 96 | (indicate-region))) | ||
| 97 | ) | ||
| 98 | |||
| 99 | (defun mouse-set-mark-and-select (window x y) | ||
| 100 | "Set mark at mouse cursor, and select that window." | ||
| 101 | (select-window window) | ||
| 102 | (mouse-set-mark window x y) | ||
| 103 | ) | ||
| 104 | |||
| 105 | (defun mouse-set-mark-and-stuff (w x y) | ||
| 106 | "Set mark at mouse cursor, and put region in stuff buffer." | ||
| 107 | (mouse-set-mark-and-select w x y) | ||
| 108 | (sun-select-region (region-beginning) (region-end))) | ||
| 109 | |||
| 110 | ;;; | ||
| 111 | ;;; Simple mouse dragging stuff: marking with button up | ||
| 112 | ;;; | ||
| 113 | |||
| 114 | (defvar *mouse-drag-window* nil) | ||
| 115 | (defvar *mouse-drag-x* -1) | ||
| 116 | (defvar *mouse-drag-y* -1) | ||
| 117 | |||
| 118 | (defun mouse-drag-move-point (window x y) | ||
| 119 | "Move point to mouse cursor, and allow dragging." | ||
| 120 | (mouse-move-point window x y) | ||
| 121 | (setq *mouse-drag-window* window | ||
| 122 | *mouse-drag-x* x | ||
| 123 | *mouse-drag-y* y)) | ||
| 124 | |||
| 125 | (defun mouse-drag-set-mark-stuff (window x y) | ||
| 126 | "The up click handler that goes with mouse-drag-move-point. | ||
| 127 | If mouse is in same WINDOW but at different X or Y than when | ||
| 128 | mouse-drag-move-point was last executed, set the mark at mouse | ||
| 129 | and put the region in the stuff buffer." | ||
| 130 | (if (and (eq *mouse-drag-window* window) | ||
| 131 | (not (and (equal *mouse-drag-x* x) | ||
| 132 | (equal *mouse-drag-y* y)))) | ||
| 133 | (mouse-set-mark-and-stuff window x y) | ||
| 134 | (setq this-command last-command)) ; this was just an upclick no-op. | ||
| 135 | ) | ||
| 136 | |||
| 137 | (defun mouse-select-or-drag-move-point (window x y) | ||
| 138 | "Select window if not selected, otherwise do mouse-drag-move-point." | ||
| 139 | (if (eq (selected-window) window) | ||
| 140 | (mouse-drag-move-point window x y) | ||
| 141 | (mouse-select-window window))) | ||
| 142 | |||
| 143 | ;;; | ||
| 144 | ;;; esoterica: | ||
| 145 | ;;; | ||
| 146 | (defun mouse-exch-pt-and-mark (window x y) | ||
| 147 | "Exchange point and mark." | ||
| 148 | (select-window window) | ||
| 149 | (exchange-point-and-mark) | ||
| 150 | ) | ||
| 151 | |||
| 152 | (defun mouse-call-kbd-macro (window x y) | ||
| 153 | "Invokes last keyboard macro at mouse cursor." | ||
| 154 | (mouse-move-point window x y) | ||
| 155 | (call-last-kbd-macro) | ||
| 156 | ) | ||
| 157 | |||
| 158 | (defun mouse-mark-thing (window x y) | ||
| 159 | "Set point and mark to text object using syntax table. | ||
| 160 | The resulting region is put in the sun-window stuff buffer. | ||
| 161 | Left or right Paren syntax marks an s-expression. | ||
| 162 | Clicking at the end of a line marks the line including a trailing newline. | ||
| 163 | If it doesn't recognize one of these it marks the character at point." | ||
| 164 | (mouse-move-point window x y) | ||
| 165 | (if (eobp) (open-line 1)) | ||
| 166 | (let* ((char (char-after (point))) | ||
| 167 | (syntax (char-syntax char))) | ||
| 168 | (cond | ||
| 169 | ((eq syntax ?w) ; word. | ||
| 170 | (forward-word 1) | ||
| 171 | (set-mark (point)) | ||
| 172 | (forward-word -1)) | ||
| 173 | ;; try to include a single following whitespace (is this a good idea?) | ||
| 174 | ;; No, not a good idea since inconsistent. | ||
| 175 | ;;(if (eq (char-syntax (char-after (mark))) ?\ ) | ||
| 176 | ;; (set-mark (1+ (mark)))) | ||
| 177 | ((eq syntax ?\( ) ; open paren. | ||
| 178 | (mark-sexp 1)) | ||
| 179 | ((eq syntax ?\) ) ; close paren. | ||
| 180 | (forward-char 1) | ||
| 181 | (mark-sexp -1) | ||
| 182 | (exchange-point-and-mark)) | ||
| 183 | ((eolp) ; mark line if at end. | ||
| 184 | (set-mark (1+ (point))) | ||
| 185 | (beginning-of-line 1)) | ||
| 186 | (t ; mark character | ||
| 187 | (set-mark (1+ (point))))) | ||
| 188 | (indicate-region)) ; display region boundary. | ||
| 189 | (sun-select-region (region-beginning) (region-end)) | ||
| 190 | ) | ||
| 191 | |||
| 192 | (defun mouse-kill-thing (window x y) | ||
| 193 | "Kill thing at mouse, and put point there." | ||
| 194 | (mouse-mark-thing window x y) | ||
| 195 | (kill-region-and-unmark (region-beginning) (region-end)) | ||
| 196 | ) | ||
| 197 | |||
| 198 | (defun mouse-kill-thing-there (window x y) | ||
| 199 | "Kill thing at mouse, leave point where it was. | ||
| 200 | See mouse-mark-thing for a description of the objects recognized." | ||
| 201 | (eval-in-window window | ||
| 202 | (save-excursion | ||
| 203 | (mouse-mark-thing window x y) | ||
| 204 | (kill-region (region-beginning) (region-end)))) | ||
| 205 | ) | ||
| 206 | |||
| 207 | (defun mouse-save-thing (window x y &optional quiet) | ||
| 208 | "Put thing at mouse in kill ring. | ||
| 209 | See mouse-mark-thing for a description of the objects recognized." | ||
| 210 | (mouse-mark-thing window x y) | ||
| 211 | (copy-region-as-kill (region-beginning) (region-end)) | ||
| 212 | (if (not quiet) (message "Thing saved")) | ||
| 213 | ) | ||
| 214 | |||
| 215 | (defun mouse-save-thing-there (window x y &optional quiet) | ||
| 216 | "Put thing at mouse in kill ring, leave point as is. | ||
| 217 | See mouse-mark-thing for a description of the objects recognized." | ||
| 218 | (eval-in-window window | ||
| 219 | (save-excursion | ||
| 220 | (mouse-save-thing window x y quiet)))) | ||
| 221 | |||
| 222 | ;;; | ||
| 223 | ;;; Mouse yanking... | ||
| 224 | ;;; | ||
| 225 | (defun mouse-copy-thing (window x y) | ||
| 226 | "Put thing at mouse in kill ring, yank to point. | ||
| 227 | See mouse-mark-thing for a description of the objects recognized." | ||
| 228 | (setq last-command 'not-kill) ;Avoids appending to previous kills. | ||
| 229 | (mouse-save-thing-there window x y t) | ||
| 230 | (yank) | ||
| 231 | (setq this-command 'yank)) | ||
| 232 | |||
| 233 | (defun mouse-move-thing (window x y) | ||
| 234 | "Kill thing at mouse, yank it to point. | ||
| 235 | See mouse-mark-thing for a description of the objects recognized." | ||
| 236 | (setq last-command 'not-kill) ;Avoids appending to previous kills. | ||
| 237 | (mouse-kill-thing-there window x y) | ||
| 238 | (yank) | ||
| 239 | (setq this-command 'yank)) | ||
| 240 | |||
| 241 | (defun mouse-yank-at-point (&optional window x y) | ||
| 242 | "Yank from kill-ring at point; then cycle thru kill ring." | ||
| 243 | (if (eq last-command 'yank) | ||
| 244 | (let ((before (< (point) (mark)))) | ||
| 245 | (delete-region (point) (mark)) | ||
| 246 | (insert (current-kill 1)) | ||
| 247 | (if before (exchange-point-and-mark))) | ||
| 248 | (yank)) | ||
| 249 | (setq this-command 'yank)) | ||
| 250 | |||
| 251 | (defun mouse-yank-at-mouse (window x y) | ||
| 252 | "Yank from kill-ring at mouse; then cycle thru kill ring." | ||
| 253 | (mouse-move-point window x y) | ||
| 254 | (mouse-yank-at-point window x y)) | ||
| 255 | |||
| 256 | (defun mouse-save/delete/yank (&optional window x y) | ||
| 257 | "Context sensitive save/delete/yank. | ||
| 258 | Consecutive clicks perform as follows: | ||
| 259 | * first click saves region to kill ring, | ||
| 260 | * second click kills region, | ||
| 261 | * third click yanks from kill ring, | ||
| 262 | * subsequent clicks cycle thru kill ring. | ||
| 263 | If mouse-move-point is performed after the first or second click, | ||
| 264 | the next click will do a yank, etc. Except for a possible mouse-move-point, | ||
| 265 | this command is insensitive to mouse location." | ||
| 266 | (cond | ||
| 267 | ((memq last-command '(mouse-delete yank mouse-yank-move)) ; third+ click | ||
| 268 | (mouse-yank-at-point)) | ||
| 269 | ((eq last-command 'mouse-copy) ; second click | ||
| 270 | (kill-region (region-beginning) (region-end)) | ||
| 271 | (setq this-command 'mouse-delete)) | ||
| 272 | (t ; first click | ||
| 273 | (copy-region-as-kill (region-beginning) (region-end)) | ||
| 274 | (message "Region saved") | ||
| 275 | (setq this-command 'mouse-copy)) | ||
| 276 | )) | ||
| 277 | |||
| 278 | |||
| 279 | (defun mouse-split-horizontally (window x y) | ||
| 280 | "Splits the window horizontally at mouse cursor." | ||
| 281 | (eval-in-window window (split-window-horizontally (1+ x)))) | ||
| 282 | |||
| 283 | (defun mouse-split-vertically (window x y) | ||
| 284 | "Split the window vertically at the mouse cursor." | ||
| 285 | (eval-in-window window (split-window-vertically (1+ y)))) | ||
| 286 | |||
| 287 | (defun mouse-select-window (&optional window x y) | ||
| 288 | "Selects the window, restoring point." | ||
| 289 | (select-window window)) | ||
| 290 | |||
| 291 | (defun mouse-delete-other-windows (&optional window x y) | ||
| 292 | "Deletes all windows except the one mouse is in." | ||
| 293 | (delete-other-windows window)) | ||
| 294 | |||
| 295 | (defun mouse-delete-window (window &optional x y) | ||
| 296 | "Deletes the window mouse is in." | ||
| 297 | (delete-window window)) | ||
| 298 | |||
| 299 | (defun mouse-undo (window x y) | ||
| 300 | "Invokes undo in the window mouse is in." | ||
| 301 | (eval-in-window window (undo))) | ||
| 302 | |||
| 303 | ;;; | ||
| 304 | ;;; Scroll operations | ||
| 305 | ;;; | ||
| 306 | |||
| 307 | ;;; The move-to-window-line is used below because otherwise | ||
| 308 | ;;; scrolling a non-selected process window with the mouse, after | ||
| 309 | ;;; the process has written text past the bottom of the window, | ||
| 310 | ;;; gives an "End of buffer" error, and then scrolls. The | ||
| 311 | ;;; move-to-window-line seems to force recomputing where things are. | ||
| 312 | (defun mouse-scroll-up (window x y) | ||
| 313 | "Scrolls the window upward." | ||
| 314 | (eval-in-window window (move-to-window-line 1) (scroll-up nil))) | ||
| 315 | |||
| 316 | (defun mouse-scroll-down (window x y) | ||
| 317 | "Scrolls the window downward." | ||
| 318 | (eval-in-window window (scroll-down nil))) | ||
| 319 | |||
| 320 | (defun mouse-scroll-proportional (window x y) | ||
| 321 | "Scrolls the window proportionally corresponding to window | ||
| 322 | relative X divided by window width." | ||
| 323 | (eval-in-window window | ||
| 324 | (if (>= x (1- (window-width))) | ||
| 325 | ;; When x is maximum (equal to or 1 less than window width), | ||
| 326 | ;; goto end of buffer. We check for this special case | ||
| 327 | ;; because the calculated goto-char often goes short of the | ||
| 328 | ;; end due to roundoff error, and we often really want to go | ||
| 329 | ;; to the end. | ||
| 330 | (goto-char (point-max)) | ||
| 331 | (progn | ||
| 332 | (goto-char (+ (point-min) ; For narrowed regions. | ||
| 333 | (* x (/ (- (point-max) (point-min)) | ||
| 334 | (1- (window-width)))))) | ||
| 335 | (beginning-of-line)) | ||
| 336 | ) | ||
| 337 | (what-cursor-position) ; Report position. | ||
| 338 | )) | ||
| 339 | |||
| 340 | (defun mouse-line-to-top (window x y) | ||
| 341 | "Scrolls the line at the mouse cursor up to the top." | ||
| 342 | (eval-in-window window (scroll-up y))) | ||
| 343 | |||
| 344 | (defun mouse-top-to-line (window x y) | ||
| 345 | "Scrolls the top line down to the mouse cursor." | ||
| 346 | (eval-in-window window (scroll-down y))) | ||
| 347 | |||
| 348 | (defun mouse-line-to-bottom (window x y) | ||
| 349 | "Scrolls the line at the mouse cursor to the bottom." | ||
| 350 | (eval-in-window window (scroll-up (+ y (- 2 (window-height)))))) | ||
| 351 | |||
| 352 | (defun mouse-bottom-to-line (window x y) | ||
| 353 | "Scrolls the bottom line up to the mouse cursor." | ||
| 354 | (eval-in-window window (scroll-down (+ y (- 2 (window-height)))))) | ||
| 355 | |||
| 356 | (defun mouse-line-to-middle (window x y) | ||
| 357 | "Scrolls the line at the mouse cursor to the middle." | ||
| 358 | (eval-in-window window (scroll-up (- y -1 (/ (window-height) 2))))) | ||
| 359 | |||
| 360 | (defun mouse-middle-to-line (window x y) | ||
| 361 | "Scrolls the line at the middle to the mouse cursor." | ||
| 362 | (eval-in-window window (scroll-up (- (/ (window-height) 2) y 1)))) | ||
| 363 | |||
| 364 | |||
| 365 | ;;; | ||
| 366 | ;;; main emacs menu. | ||
| 367 | ;;; | ||
| 368 | (defmenu expand-menu | ||
| 369 | ("Vertically" mouse-expand-vertically *menu-window*) | ||
| 370 | ("Horizontally" mouse-expand-horizontally *menu-window*)) | ||
| 371 | |||
| 372 | (defmenu delete-window-menu | ||
| 373 | ("This One" delete-window *menu-window*) | ||
| 374 | ("All Others" delete-other-windows *menu-window*)) | ||
| 375 | |||
| 376 | (defmenu mouse-help-menu | ||
| 377 | ("Text Region" | ||
| 378 | mouse-help-region *menu-window* *menu-x* *menu-y* 'text) | ||
| 379 | ("Scrollbar" | ||
| 380 | mouse-help-region *menu-window* *menu-x* *menu-y* 'scrollbar) | ||
| 381 | ("Modeline" | ||
| 382 | mouse-help-region *menu-window* *menu-x* *menu-y* 'modeline) | ||
| 383 | ("Minibuffer" | ||
| 384 | mouse-help-region *menu-window* *menu-x* *menu-y* 'minibuffer) | ||
| 385 | ) | ||
| 386 | |||
| 387 | (defmenu emacs-quit-menu | ||
| 388 | ("Quit" save-buffers-kill-emacs)) | ||
| 389 | |||
| 390 | (defmenu emacs-menu | ||
| 391 | ("Emacs Menu") | ||
| 392 | ("Stuff Selection" sun-yank-selection) | ||
| 393 | ("Expand" . expand-menu) | ||
| 394 | ("Delete Window" . delete-window-menu) | ||
| 395 | ("Previous Buffer" mouse-select-previous-buffer *menu-window*) | ||
| 396 | ("Save Buffers" save-some-buffers) | ||
| 397 | ("List Directory" list-directory nil) | ||
| 398 | ("Dired" dired nil) | ||
| 399 | ("Mouse Help" . mouse-help-menu) | ||
| 400 | ("Quit" . emacs-quit-menu)) | ||
| 401 | |||
| 402 | (defun emacs-menu-eval (window x y) | ||
| 403 | "Pop-up menu of editor commands." | ||
| 404 | (sun-menu-evaluate window (1+ x) (1- y) 'emacs-menu)) | ||
| 405 | |||
| 406 | (defun mouse-expand-horizontally (window) | ||
| 407 | (eval-in-window window | ||
| 408 | (enlarge-window 4 t) | ||
| 409 | (update-display) ; Try to redisplay, since can get confused. | ||
| 410 | )) | ||
| 411 | |||
| 412 | (defun mouse-expand-vertically (window) | ||
| 413 | (eval-in-window window (enlarge-window 4))) | ||
| 414 | |||
| 415 | (defun mouse-select-previous-buffer (window) | ||
| 416 | "Switch buffer in mouse window to most recently selected buffer." | ||
| 417 | (eval-in-window window (switch-to-buffer (other-buffer)))) | ||
| 418 | |||
| 419 | ;;; | ||
| 420 | ;;; minibuffer menu | ||
| 421 | ;;; | ||
| 422 | (defmenu minibuffer-menu | ||
| 423 | ("Minibuffer" message "Just some miscellaneous minibuffer commands") | ||
| 424 | ("Stuff" sun-yank-selection) | ||
| 425 | ("Do-It" exit-minibuffer) | ||
| 426 | ("Abort" abort-recursive-edit) | ||
| 427 | ("Suspend" suspend-emacs)) | ||
| 428 | |||
| 429 | (defun minibuffer-menu-eval (window x y) | ||
| 430 | "Pop-up menu of commands." | ||
| 431 | (sun-menu-evaluate window x (1- y) 'minibuffer-menu)) | ||
| 432 | |||
| 433 | (defun mini-move-point (window x y) | ||
| 434 | ;; -6 is good for most common cases | ||
| 435 | (mouse-move-point window (- x 6) 0)) | ||
| 436 | |||
| 437 | (defun mini-set-mark-and-stuff (window x y) | ||
| 438 | ;; -6 is good for most common cases | ||
| 439 | (mouse-set-mark-and-stuff window (- x 6) 0)) | ||
| 440 | |||
| 441 | |||
| 442 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 443 | ;;; Buffer-mode Mouse commands | ||
| 444 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 445 | |||
| 446 | (defun Buffer-at-mouse (w x y) | ||
| 447 | "Calls Buffer-menu-buffer from mouse click." | ||
| 448 | (save-window-excursion | ||
| 449 | (mouse-move-point w x y) | ||
| 450 | (beginning-of-line) | ||
| 451 | (Buffer-menu-buffer t))) | ||
| 452 | |||
| 453 | (defun mouse-buffer-bury (w x y) | ||
| 454 | "Bury the indicated buffer." | ||
| 455 | (bury-buffer (Buffer-at-mouse w x y)) | ||
| 456 | ) | ||
| 457 | |||
| 458 | (defun mouse-buffer-select (w x y) | ||
| 459 | "Put the indicated buffer in selected window." | ||
| 460 | (switch-to-buffer (Buffer-at-mouse w x y)) | ||
| 461 | (list-buffers) | ||
| 462 | ) | ||
| 463 | |||
| 464 | (defun mouse-buffer-delete (w x y) | ||
| 465 | "mark indicated buffer for delete" | ||
| 466 | (save-window-excursion | ||
| 467 | (mouse-move-point w x y) | ||
| 468 | (Buffer-menu-delete) | ||
| 469 | )) | ||
| 470 | |||
| 471 | (defun mouse-buffer-execute (w x y) | ||
| 472 | "execute buffer-menu selections" | ||
| 473 | (save-window-excursion | ||
| 474 | (mouse-move-point w x y) | ||
| 475 | (Buffer-menu-execute) | ||
| 476 | )) | ||
| 477 | |||
| 478 | (defun enable-mouse-in-buffer-list () | ||
| 479 | "Call this to enable mouse selections in *Buffer List* | ||
| 480 | LEFT puts the indicated buffer in the selected window. | ||
| 481 | MIDDLE buries the indicated buffer. | ||
| 482 | RIGHT marks the indicated buffer for deletion. | ||
| 483 | MIDDLE-RIGHT deletes the marked buffers. | ||
| 484 | To unmark a buffer marked for deletion, select it with LEFT." | ||
| 485 | (save-window-excursion | ||
| 486 | (list-buffers) ; Initialize *Buffer List* | ||
| 487 | (set-buffer "*Buffer List*") | ||
| 488 | (local-set-mouse '(text middle) 'mouse-buffer-bury) | ||
| 489 | (local-set-mouse '(text left) 'mouse-buffer-select) | ||
| 490 | (local-set-mouse '(text right) 'mouse-buffer-delete) | ||
| 491 | (local-set-mouse '(text middle right) 'mouse-buffer-execute) | ||
| 492 | ) | ||
| 493 | ) | ||
| 494 | |||
| 495 | |||
| 496 | ;;;******************************************************************* | ||
| 497 | ;;; | ||
| 498 | ;;; Global Mouse Bindings. | ||
| 499 | ;;; | ||
| 500 | ;;; There is some sense to this mouse binding madness: | ||
| 501 | ;;; LEFT and RIGHT scrolls are inverses. | ||
| 502 | ;;; SHIFT makes an opposite meaning in the scroll bar. | ||
| 503 | ;;; SHIFT is an alternative to DOUBLE (but double chords do not exist). | ||
| 504 | ;;; META makes the scrollbar functions work in the text region. | ||
| 505 | ;;; MIDDLE operates the mark | ||
| 506 | ;;; LEFT operates at point | ||
| 507 | |||
| 508 | ;;; META commands are generally non-destructive, | ||
| 509 | ;;; SHIFT is a little more dangerous. | ||
| 510 | ;;; CONTROL is for the really complicated ones. | ||
| 511 | |||
| 512 | ;;; CONTROL-META-SHIFT-RIGHT gives help on that region. | ||
| 513 | |||
| 514 | ;;; | ||
| 515 | ;;; Text Region mousemap | ||
| 516 | ;;; | ||
| 517 | ;; The basics: Point, Mark, Menu, Sun-Select: | ||
| 518 | (global-set-mouse '(text left) 'mouse-drag-move-point) | ||
| 519 | (global-set-mouse '(text up left) 'mouse-drag-set-mark-stuff) | ||
| 520 | (global-set-mouse '(text shift left) 'mouse-exch-pt-and-mark) | ||
| 521 | (global-set-mouse '(text double left) 'mouse-exch-pt-and-mark) | ||
| 522 | |||
| 523 | (global-set-mouse '(text middle) 'mouse-set-mark-and-stuff) | ||
| 524 | |||
| 525 | (global-set-mouse '(text right) 'emacs-menu-eval) | ||
| 526 | (global-set-mouse '(text shift right) '(sun-yank-selection)) | ||
| 527 | (global-set-mouse '(text double right) '(sun-yank-selection)) | ||
| 528 | |||
| 529 | ;; The Slymoblics multi-command for Save, Kill, Copy, Move: | ||
| 530 | (global-set-mouse '(text shift middle) 'mouse-save/delete/yank) | ||
| 531 | (global-set-mouse '(text double middle) 'mouse-save/delete/yank) | ||
| 532 | |||
| 533 | ;; Save, Kill, Copy, Move Things: | ||
| 534 | ;; control-left composes with control middle/right to produce copy/move | ||
| 535 | (global-set-mouse '(text control middle ) 'mouse-save-thing-there) | ||
| 536 | (global-set-mouse '(text control right ) 'mouse-kill-thing-there) | ||
| 537 | (global-set-mouse '(text control left) 'mouse-yank-at-point) | ||
| 538 | (global-set-mouse '(text control middle left) 'mouse-copy-thing) | ||
| 539 | (global-set-mouse '(text control right left) 'mouse-move-thing) | ||
| 540 | (global-set-mouse '(text control right middle) 'mouse-mark-thing) | ||
| 541 | |||
| 542 | ;; The Universal mouse help command (press all buttons): | ||
| 543 | (global-set-mouse '(text shift control meta right) 'mouse-help-region) | ||
| 544 | (global-set-mouse '(text double control meta right) 'mouse-help-region) | ||
| 545 | |||
| 546 | ;;; Meta in Text Region is like meta version in scrollbar: | ||
| 547 | (global-set-mouse '(text meta left) 'mouse-line-to-top) | ||
| 548 | (global-set-mouse '(text meta shift left) 'mouse-line-to-bottom) | ||
| 549 | (global-set-mouse '(text meta double left) 'mouse-line-to-bottom) | ||
| 550 | (global-set-mouse '(text meta middle) 'mouse-line-to-middle) | ||
| 551 | (global-set-mouse '(text meta shift middle) 'mouse-middle-to-line) | ||
| 552 | (global-set-mouse '(text meta double middle) 'mouse-middle-to-line) | ||
| 553 | (global-set-mouse '(text meta control middle) 'mouse-split-vertically) | ||
| 554 | (global-set-mouse '(text meta right) 'mouse-top-to-line) | ||
| 555 | (global-set-mouse '(text meta shift right) 'mouse-bottom-to-line) | ||
| 556 | (global-set-mouse '(text meta double right) 'mouse-bottom-to-line) | ||
| 557 | |||
| 558 | ;; Miscellaneous: | ||
| 559 | (global-set-mouse '(text meta control left) 'mouse-call-kbd-macro) | ||
| 560 | (global-set-mouse '(text meta control right) 'mouse-undo) | ||
| 561 | |||
| 562 | ;;; | ||
| 563 | ;;; Scrollbar mousemap. | ||
| 564 | ;;; Are available in the Scrollbar Region, or with Meta Text (or Meta Scrollbar) | ||
| 565 | ;;; | ||
| 566 | (global-set-mouse '(scrollbar left) 'mouse-line-to-top) | ||
| 567 | (global-set-mouse '(scrollbar shift left) 'mouse-line-to-bottom) | ||
| 568 | (global-set-mouse '(scrollbar double left) 'mouse-line-to-bottom) | ||
| 569 | |||
| 570 | (global-set-mouse '(scrollbar middle) 'mouse-line-to-middle) | ||
| 571 | (global-set-mouse '(scrollbar shift middle) 'mouse-middle-to-line) | ||
| 572 | (global-set-mouse '(scrollbar double middle) 'mouse-middle-to-line) | ||
| 573 | (global-set-mouse '(scrollbar control middle) 'mouse-split-vertically) | ||
| 574 | |||
| 575 | (global-set-mouse '(scrollbar right) 'mouse-top-to-line) | ||
| 576 | (global-set-mouse '(scrollbar shift right) 'mouse-bottom-to-line) | ||
| 577 | (global-set-mouse '(scrollbar double right) 'mouse-bottom-to-line) | ||
| 578 | |||
| 579 | (global-set-mouse '(scrollbar meta left) 'mouse-line-to-top) | ||
| 580 | (global-set-mouse '(scrollbar meta shift left) 'mouse-line-to-bottom) | ||
| 581 | (global-set-mouse '(scrollbar meta double left) 'mouse-line-to-bottom) | ||
| 582 | (global-set-mouse '(scrollbar meta middle) 'mouse-line-to-middle) | ||
| 583 | (global-set-mouse '(scrollbar meta shift middle) 'mouse-middle-to-line) | ||
| 584 | (global-set-mouse '(scrollbar meta double middle) 'mouse-middle-to-line) | ||
| 585 | (global-set-mouse '(scrollbar meta control middle) 'mouse-split-vertically) | ||
| 586 | (global-set-mouse '(scrollbar meta right) 'mouse-top-to-line) | ||
| 587 | (global-set-mouse '(scrollbar meta shift right) 'mouse-bottom-to-line) | ||
| 588 | (global-set-mouse '(scrollbar meta double right) 'mouse-bottom-to-line) | ||
| 589 | |||
| 590 | ;; And the help menu: | ||
| 591 | (global-set-mouse '(scrollbar shift control meta right) 'mouse-help-region) | ||
| 592 | (global-set-mouse '(scrollbar double control meta right) 'mouse-help-region) | ||
| 593 | |||
| 594 | ;;; | ||
| 595 | ;;; Modeline mousemap. | ||
| 596 | ;;; | ||
| 597 | ;;; Note: meta of any single button selects window. | ||
| 598 | |||
| 599 | (global-set-mouse '(modeline left) 'mouse-scroll-up) | ||
| 600 | (global-set-mouse '(modeline meta left) 'mouse-select-window) | ||
| 601 | |||
| 602 | (global-set-mouse '(modeline middle) 'mouse-scroll-proportional) | ||
| 603 | (global-set-mouse '(modeline meta middle) 'mouse-select-window) | ||
| 604 | (global-set-mouse '(modeline control middle) 'mouse-split-horizontally) | ||
| 605 | |||
| 606 | (global-set-mouse '(modeline right) 'mouse-scroll-down) | ||
| 607 | (global-set-mouse '(modeline meta right) 'mouse-select-window) | ||
| 608 | |||
| 609 | ;;; control-left selects this window, control-right deletes it. | ||
| 610 | (global-set-mouse '(modeline control left) 'mouse-delete-other-windows) | ||
| 611 | (global-set-mouse '(modeline control right) 'mouse-delete-window) | ||
| 612 | |||
| 613 | ;; in case of confusion, just select it: | ||
| 614 | (global-set-mouse '(modeline control left right)'mouse-select-window) | ||
| 615 | |||
| 616 | ;; even without confusion (and without the keyboard) select it: | ||
| 617 | (global-set-mouse '(modeline left right) 'mouse-select-window) | ||
| 618 | |||
| 619 | ;; And the help menu: | ||
| 620 | (global-set-mouse '(modeline shift control meta right) 'mouse-help-region) | ||
| 621 | (global-set-mouse '(modeline double control meta right) 'mouse-help-region) | ||
| 622 | |||
| 623 | ;;; | ||
| 624 | ;;; Minibuffer Mousemap | ||
| 625 | ;;; Demonstrating some variety: | ||
| 626 | ;;; | ||
| 627 | (global-set-mouse '(minibuffer left) 'mini-move-point) | ||
| 628 | |||
| 629 | (global-set-mouse '(minibuffer middle) 'mini-set-mark-and-stuff) | ||
| 630 | |||
| 631 | (global-set-mouse '(minibuffer shift middle) '(select-previous-complex-command)) | ||
| 632 | (global-set-mouse '(minibuffer double middle) '(select-previous-complex-command)) | ||
| 633 | (global-set-mouse '(minibuffer control middle) '(next-complex-command 1)) | ||
| 634 | (global-set-mouse '(minibuffer meta middle) '(previous-complex-command 1)) | ||
| 635 | |||
| 636 | (global-set-mouse '(minibuffer right) 'minibuffer-menu-eval) | ||
| 637 | |||
| 638 | (global-set-mouse '(minibuffer shift control meta right) 'mouse-help-region) | ||
| 639 | (global-set-mouse '(minibuffer double control meta right) 'mouse-help-region) | ||
| 640 | |||
| 641 | (provide 'sun-fns) | ||
| 642 | |||
| 643 | ;;; arch-tag: 1c4c1192-f71d-4d5f-b883-ae659c28e132 | ||
| 644 | ;;; sun-fns.el ends here | ||