annotate lisp/x-mouse.el @ 5773:94a6b8fbd56e

Use a face, show more context around open parenthesis, #'blink-matching-open lisp/ChangeLog addition: 2013-12-17 Aidan Kehoe <kehoea@parhasard.net> * simple.el (blink-matching-open): When showing the opening parenthesis in the minibiffer, use the isearch face for it, in case there are multiple parentheses in the text shown. When writing moderately involved macros, it's often not enough just to show the backquote context before the parenthesis (e.g. @,.`). Skip over that when searching for useful context in the same way we skip over space and tab. * simple.el (message): * simple.el (lmessage): If there are no ARGS, don't call #'format. This allows extent information to be passed through to the minibuffer. It's probably better still to update #'format to preserve extent info.
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 17 Dec 2013 20:49:52 +0200
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; x-mouse.el --- Mouse support for X window system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1992-4, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: mouse, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
14 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
19 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;;; Synched up with: Not synched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;; This file is dumped with XEmacs (when X support is compiled in).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 446
diff changeset
32 (globally-declare-fboundp
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 446
diff changeset
33 '(x-store-cutbuffer x-get-resource))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 446
diff changeset
34
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;;(define-key global-map 'button2 'x-set-point-and-insert-selection)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;; This is reserved for use by Hyperbole.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;;(define-key global-map '(shift button2) 'x-mouse-kill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 (define-key global-map '(control button2) 'x-set-point-and-move-selection)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 (define-obsolete-function-alias 'x-insert-selection 'insert-selection)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (defun x-mouse-kill (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 "Kill the text between the point and mouse and copy it to the clipboard and
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
44 to the cut buffer."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (interactive "@e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (let ((old-point (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 (mouse-set-point event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (let ((s (buffer-substring old-point (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (own-clipboard s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (x-store-cutbuffer s))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 (kill-region old-point (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (make-obsolete 'x-set-point-and-insert-selection 'mouse-yank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (defun x-set-point-and-insert-selection (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 "Set point where clicked and insert the primary selection or the cut buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (let ((mouse-yank-at-point nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (mouse-yank event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (defun x-set-point-and-move-selection (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 "Set point where clicked and move the selected text to that location."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 ;; Don't try to move the selection if x-kill-primary-selection if going
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;; to fail; just let the appropriate error message get issued. (We need
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ;; to insert the selection and set point first, or the selection may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ;; get inserted at the wrong place.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (and (selection-owner-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 primary-selection-extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (insert-selection t event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 (kill-primary-selection))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (defun mouse-track-and-copy-to-cutbuffer (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 "Make a selection like `mouse-track', but also copy it to the cutbuffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (mouse-track event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (cond
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 ((null primary-selection-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 ((consp primary-selection-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (set-buffer (extent-object (car primary-selection-extent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (x-store-cutbuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (mapconcat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #'identity
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (extract-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (extent-start-position (car primary-selection-extent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (extent-end-position (car (reverse primary-selection-extent))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 "\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (set-buffer (extent-object primary-selection-extent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (x-store-cutbuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (buffer-substring (extent-start-position primary-selection-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (extent-end-position primary-selection-extent)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (defvar x-pointers-initialized nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (defun x-init-pointer-shape (device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 "Initialize the mouse-pointers of DEVICE from the X resource database."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (if x-pointers-initialized ; only do it when the first device is created
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (set-glyph-image text-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
104 (or (x-get-resource "textPointer" "Cursor" 'string device nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
105 [cursor-font :data "xterm"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (set-glyph-image selection-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
107 (or (x-get-resource "selectionPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
108 nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
109 [cursor-font :data "top_left_arrow"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (set-glyph-image nontext-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
111 (or (x-get-resource "spacePointer" "Cursor" 'string device nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
112 [cursor-font :data "xterm"])) ; was "crosshair"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (set-glyph-image modeline-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
114 (or (x-get-resource "modeLinePointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
115 nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 ;; "fleur"))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
117 [cursor-font :data "sb_v_double_arrow"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (set-glyph-image gc-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
119 (or (x-get-resource "gcPointer" "Cursor" 'string device nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
120 [cursor-font :data "watch"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (when (featurep 'scrollbar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (set-glyph-image
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 scrollbar-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
124 (or (x-get-resource "scrollbarPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
125 nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
126 ;; bizarrely if we don't specify the specific locale (x) this
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
127 ;; gets instantiated on the stream device. Bad puppy.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
128 [cursor-font :data "top_left_arrow"]) 'global '(default x)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (set-glyph-image busy-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
130 (or (x-get-resource "busyPointer" "Cursor" 'string device nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
131 [cursor-font :data "watch"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (set-glyph-image toolbar-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
133 (or (x-get-resource "toolBarPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
134 nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
135 [cursor-font :data "left_ptr"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (set-glyph-image divider-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
137 (or (x-get-resource "dividerPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
138 nil 'warn)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
139 [cursor-font :data "sb_h_double_arrow"]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (let ((fg
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
141 (x-get-resource "pointerColor" "Foreground" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
142 nil 'warn)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (and fg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 (set-face-foreground 'pointer fg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (let ((bg
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
146 (x-get-resource "pointerBackground" "Background" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
147 nil 'warn)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (and bg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (set-face-background 'pointer bg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (setq x-pointers-initialized t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 ;;; x-mouse.el ends here