diff options
| -rw-r--r-- | lisp/mouse-sel.el | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lisp/mouse-sel.el b/lisp/mouse-sel.el index 96a8e5b617f..f079c62f978 100644 --- a/lisp/mouse-sel.el +++ b/lisp/mouse-sel.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Mike Williams <mikew@gopher.dosli.govt.nz> | 5 | ;; Author: Mike Williams <mikew@gopher.dosli.govt.nz> |
| 6 | ;; Keywords: mouse | 6 | ;; Keywords: mouse |
| 7 | ;; Version: 2.0 | 7 | ;; Version: 2.1 |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| @@ -40,7 +40,8 @@ | |||
| 40 | ;; directly, mouse-sel sets the variables interprogram-cut-function | 40 | ;; directly, mouse-sel sets the variables interprogram-cut-function |
| 41 | ;; and interprogram-paste-function to nil. | 41 | ;; and interprogram-paste-function to nil. |
| 42 | ;; | 42 | ;; |
| 43 | ;; * Clicking mouse-2 pastes contents of primary selection. | 43 | ;; * Clicking mouse-2 pastes contents of primary selection at the mouse |
| 44 | ;; position. | ||
| 44 | ;; | 45 | ;; |
| 45 | ;; * Pressing mouse-2 while selecting or extending copies selection | 46 | ;; * Pressing mouse-2 while selecting or extending copies selection |
| 46 | ;; to the kill ring. Pressing mouse-1 or mouse-3 kills it. | 47 | ;; to the kill ring. Pressing mouse-1 or mouse-3 kills it. |
| @@ -95,6 +96,11 @@ | |||
| 95 | ;; | 96 | ;; |
| 96 | ;; (c) If mouse-sel-default-bindings = nil, no bindings are made. | 97 | ;; (c) If mouse-sel-default-bindings = nil, no bindings are made. |
| 97 | ;; | 98 | ;; |
| 99 | ;; * By default, mouse-insert-selection (mouse-2) inserts the selection at | ||
| 100 | ;; the mouse position. You can tell it to insert at point instead with: | ||
| 101 | ;; | ||
| 102 | ;; (setq mouse-sel-insert-at-point t) | ||
| 103 | ;; | ||
| 98 | ;; * I like to leave point at the end of the region nearest to where the | 104 | ;; * I like to leave point at the end of the region nearest to where the |
| 99 | ;; mouse was, even though this makes region highlighting mis-leading (the | 105 | ;; mouse was, even though this makes region highlighting mis-leading (the |
| 100 | ;; cursor makes it look like one extra character is selected). You can | 106 | ;; cursor makes it look like one extra character is selected). You can |
| @@ -152,7 +158,7 @@ | |||
| 152 | 158 | ||
| 153 | ;;=== Version ============================================================= | 159 | ;;=== Version ============================================================= |
| 154 | 160 | ||
| 155 | (defconst mouse-sel-version "2.0" | 161 | (defconst mouse-sel-version "2.1" |
| 156 | "The version number of mouse-sel (as string).") | 162 | "The version number of mouse-sel (as string).") |
| 157 | 163 | ||
| 158 | ;;=== User Variables ====================================================== | 164 | ;;=== User Variables ====================================================== |
| @@ -173,8 +179,12 @@ If nil, highlighting will be turned off when the mouse is lifted.") | |||
| 173 | "*If non-nil, \\[mouse-select] cycles the click-counts after 3 clicks. | 179 | "*If non-nil, \\[mouse-select] cycles the click-counts after 3 clicks. |
| 174 | Ie. 4 clicks = 1 click, 5 clicks = 2 clicks, etc.") | 180 | Ie. 4 clicks = 1 click, 5 clicks = 2 clicks, etc.") |
| 175 | 181 | ||
| 182 | (defvar mouse-sel-insert-at-point nil | ||
| 183 | "*If non-nil, \\[mouse-insert-selection] inserts at point. | ||
| 184 | Normally, \\[mouse-insert-selection] inserts at the mouse position.") | ||
| 185 | |||
| 176 | (defvar mouse-sel-default-bindings t | 186 | (defvar mouse-sel-default-bindings t |
| 177 | "Set to nil before loading mouse-sel to prevent default mouse bindings.") | 187 | "Set to nil before loading `mouse-sel' to prevent default mouse bindings.") |
| 178 | 188 | ||
| 179 | ;;=== Selection =========================================================== | 189 | ;;=== Selection =========================================================== |
| 180 | 190 | ||
| @@ -182,8 +192,7 @@ Ie. 4 clicks = 1 click, 5 clicks = 2 clicks, etc.") | |||
| 182 | (make-variable-buffer-local 'mouse-sel-selection-type) | 192 | (make-variable-buffer-local 'mouse-sel-selection-type) |
| 183 | 193 | ||
| 184 | (defvar mouse-sel-selection "" | 194 | (defvar mouse-sel-selection "" |
| 185 | "This variable is used to store the selection value when mouse-sel is | 195 | "Store the selection value when using a window systems other than X.") |
| 186 | used on windowing systems other than X Windows.") | ||
| 187 | 196 | ||
| 188 | (defvar mouse-sel-set-selection-function | 197 | (defvar mouse-sel-set-selection-function |
| 189 | (if (fboundp 'x-set-selection) | 198 | (if (fboundp 'x-set-selection) |
| @@ -207,8 +216,8 @@ Called with no argument.") | |||
| 207 | Called with no arguments.") | 216 | Called with no arguments.") |
| 208 | 217 | ||
| 209 | (defun mouse-sel-determine-selection-type (NCLICKS) | 218 | (defun mouse-sel-determine-selection-type (NCLICKS) |
| 210 | "Determine what `thing' \\[mouse-select] and \\[mouse-extend] should | 219 | "Determine what `thing' `mouse-sel' should operate on. |
| 211 | select by. The first argument is NCLICKS, is the number of consecutive | 220 | The first argument is NCLICKS, is the number of consecutive |
| 212 | mouse clicks at the same position." | 221 | mouse clicks at the same position." |
| 213 | (let* ((next-char (char-after (point))) | 222 | (let* ((next-char (char-after (point))) |
| 214 | (char-syntax (if next-char (char-syntax next-char))) | 223 | (char-syntax (if next-char (char-syntax next-char))) |
| @@ -406,9 +415,11 @@ This should be bound to a down-mouse event." | |||
| 406 | (delete-overlay mouse-drag-overlay))))) | 415 | (delete-overlay mouse-drag-overlay))))) |
| 407 | 416 | ||
| 408 | (defun mouse-insert-selection (click) | 417 | (defun mouse-insert-selection (click) |
| 409 | "Insert the contents of the selection at mouse click." | 418 | "Insert the contents of the selection at mouse click. |
| 419 | If `mouse-sel-insert-at-point' is non-nil, insert at point instead." | ||
| 410 | (interactive "e") | 420 | (interactive "e") |
| 411 | (mouse-set-point click) | 421 | (or mouse-sel-insert-at-point |
| 422 | (mouse-set-point click)) | ||
| 412 | (deactivate-mark) | 423 | (deactivate-mark) |
| 413 | (if mouse-sel-get-selection-function | 424 | (if mouse-sel-get-selection-function |
| 414 | (insert (or (funcall mouse-sel-get-selection-function) "")))) | 425 | (insert (or (funcall mouse-sel-get-selection-function) "")))) |