annotate lisp/packages/mode-motion+.el @ 207:e45d5e7c476e r20-4b2

Import from CVS: tag r20-4b2
author cvs
date Mon, 13 Aug 2007 10:03:52 +0200
parents 360340f9fd5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; -*- Syntax: Emacs-Lisp; Mode: emacs-lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Per mode and per buffer mouse tracking with highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Copyright (C) 1992, 1993 by Guido Bosch <Guido.Bosch@loria.fr>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is written in GNU Emacs Lisp, It is a part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; The software contained in this file is free software; you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; redistribute it and/or modify it under the terms of the GNU General
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; Public License as published by the Free Software Foundation; either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; version 2, or (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Please send bugs and comments to Russell.Ritchie@gssec.bt.co.uk or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; tlp00@spg.amdahl.com.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; <DISCLAIMER>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This program is still under development. Neither the author nor any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; of the maintainers accepts responsibility to anyone for the consequences of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; using it or for whether it serves any particular purpose or works
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; at all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ; Change History
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
35 ; Revision 3.16 Fri Jun 28 13:01:12 1996 ritchier@msc.ie
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
36 ; Stop multiple highlighting lossage with 19.14 release.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
37
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ; Revision 3.15 Thu Feb 15 14:26:34 GMT 1996 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ; lisp-interaction-popup-menu => lisp-interaction-mode-popup-menu,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ; emacs-lisp-popup-menu => emacs-lisp-mode-popup-menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ; Revision 3.14 Tue Nov 14 11:14:38 GMT 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ; Made nil the default value for mode-motion-focus-on-window. Too many people
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ; hate it when the cursor warps into Dired and GNUS buffers because some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ; window managers auto-raise the window with keyboard focus with predictably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ; nauseous results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ; Revision 3.13 Thu Sep 14 10:30:04 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ; Fix the `spontaneous scrolling' problem (at last). It's funny how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ; easy things are once you actually understand the issues involved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ; As ever, what we sought was the right question...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ; Revision 3.12 Wed Jul 12 11:30:43 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ; Track `don't highlight non-file lines in dired buffers' functionality (in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ; pretty tasteless manner if I say so myself :-)).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ; Revision 3.11 Fri Jul 7 16:26:56 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ; Minor extent detaching bug fix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ; Revision 3.10 Thu Jun 15 11:36:56 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ; Quiet, faster, non-interactive initialistion, mild list-motion-handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ; chrome and minor formatting clean-ups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ; Revision 3.9 Thu Jun 15 11:36:56 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ; Fixed the `mouse-motion whilst reading filename in minibuffer auto-ftp' bug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ; Revision 3.8 Thus Mar 23 1995 tlp00@spg.amdahl.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ; added in menu controls from paquette@atomas.crim.ca
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ; re-added minibuffer support (from 3.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ; Revision 3.7 Tue Feb 21 11:06:38 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ; Extended mode-motion+-religion and made the defaulting frame-buffer aware.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ; Reworked and added new mode-motion-handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ; Doc string clean up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ; Fixed unintentional frame/screen reversion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ; Revision 3.6 Mon Feb 20 11:46:32 1995 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ; Made mouse tracking use mode-motion-hook for better integration with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ; the default mouse-motion system (help-echo and friends now work).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ; Revision 3.5 1995/02/16 13:40:00 tlp00@spg.amdahl.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ; fixed sporatic scroll bug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ; added M-button2 binding for mode-motion-copy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ; Revision 3.4 1995/02/14 14:30:15 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ; Small code cleanups: let* -> let, duplicate defvars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ; Chromed list-motion-handlers a little.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ; Added variable mode-motion+-religion for easy choice twixt underline & bold.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;tlp00 changes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ; tlp00@spg.amdahl.com 2/11/93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ; modified mode-motion-track-pointer to move cursor cross windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ; renamed mode-motion-delete to mode-motion-kill to follow kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ; convention
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ; mode-motion-highlight-with-handler to put cursor at beginning of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ; follow operations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ; mode-motion-copy/delete and mode-motion-kill to position cursor at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ; delete point start. Also set this-command to avoid appends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ; set mode-motion-extent priority to 1, so it will override font-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ; changed default handlers for buffer-mode, c-mode, dired-mode, added occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ; and compilation mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ; fixed bug in minibuffer-selection-boundaries where C-g was leaving the wrong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ; syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ; added support for pending-delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ; adds the copy/delete motion-extent to the clipboard even if kill-hooks is nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ; Revision 3.3 1995/02/13 tlp00@spg.amdahl.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ; merged Russell.Ritchie@gssec.bt.co.uk versions with molli/bosch versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ; renamed versioning 3.0+ for molli/bosch versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Russell Ritchie changes;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ; !Log: mode-motion+.el,v !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ; Revision 2.14.R 1994/09/09 10:19:18 rieke@darmstadt.gmd.de
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ; Merged in my changes to support motion-gray. This needs a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ; named "gray1.xbm" in your data-directory (etc) like the following.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ; -------------------------------snip--------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ; #define bg2_width 16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ; #define bg2_height 16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ; static char bg2_bits[] = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ; 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ; 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ; 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ; -------------------------------snip--------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ; This one looks good on SUN 19'' screens with 10x20 font,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ; black foreground and khaki background.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ; To use the gray-handlers instead of the underline-handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ; include the following into your .emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ; (set-mode-motion-handler 'emacs-lisp-mode 'gray-thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ; (set-mode-motion-handler 'lisp-interaction-mode 'gray-thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ; (set-mode-motion-handler 'c++-mode 'gray-c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ; (set-mode-motion-handler 'c-mode 'gray-c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ; (set-mode-motion-handler 'tcl-mode 'gray-tcl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ; (set-mode-motion-handler 'dired-mode 'gray-line@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ; (set-mode-motion-handler 'gnus-group-mode 'gray-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ; (set-mode-motion-handler 'gnus-summary-mode 'gray-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ; (set-mode-motion-handler 'texinfo-mode 'gray-Texinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ; (setq default-motion-handler (find-motion-handler 'gray-thing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ; Revision 2.13.R 1994/08/08 19:47:34 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ; Made default handler be underline-thing, as most bold fonts seem to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ; be greater in height than their corresponding normal versions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ; causing irritating screen flicker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Molli/bosch changes;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ; Revision 3.2 1994/09/28 15:14:29 molli
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ; add "(set-mode-motion-handler 'latex-mode 'raise-LaTeX)". Barry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ; Waraw's C/C++ mode is now changed to cc-mode ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ; Revision 3.1 1994/09/28 15:10:36 molli
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ; Initial revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ; Revision 2.15 1993/11/18 08:13:28 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ; Constant `mode-motion+-version' added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ; Minor bug fix in `tcl-forward-sexp1'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ; Revision 2.14 1993/10/29 20:04:59 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ; Minibuffer name matching improved. Made `tcl-boundaries' smarter by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ; use of new function `tcl-forward-sexp1'. `tcl-commands' list updated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ; -- should be complete now. A message is printed if the syntax scanner
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
163 ; matched or failed for known tcl/tk commands. Separated `tcl-commands'
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ; from `tk-commands' -- `tk-commands' not yet complete. New motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ; handler `raise-LaTeX' added, for tex-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ; Revision 2.13 1993/10/08 09:43:00 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ; New user option `mode-motion-setup-cut-and-paste-bindings'. Function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ; `mode-motion-copy/delete' now takes into account the primary and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ; motion selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ; Revision 2.12 1993/10/08 09:08:46 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ; Avoid highlighting empty lines, even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ; `mode-motion-highlight-lines-when-behind' is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ; Revision 2.12 1994/07/07 18:33:38 Russell.Ritchie@gssec.bt.co.uk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ; Made list-motion-handlers and mode-motion-set-handler work in lemacs-19.10.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ; Revision 2.11 1993/09/20 08:29:15 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ; Code reorganized: variables declared before used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ; Compatibility hack patched again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ; Revision 2.10 1993/09/17 18:50:33 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ; Bug in the compatibility hack fixed. Call to `make-cursor' replaced by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ; `x-pointer-cache'. Compatibility hack for Lemacs 19.8 removed. Tcl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ; motion handler improved (needs still some work).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ; Revision 2.9 1993/09/15 17:52:53 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ; Compatibility patch for Lucid Emacs 19.8. tcl motion handler added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ; Revision 2.8 1993/08/27 15:17:07 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ; Select window conflict between motion handlers and process filters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ; resolved by using `enqueue-eval-event' for selecting a different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ; window (functions `mode-motion-track-pointer' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ; `mode-motion-highlight-with-handler' modified). This fixes the nasty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ; bug that made GNUS hanging during NNTP activity while the mouse was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ; moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ; Revision 2.7 1993/08/27 12:50:10 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ; TeX and LaTeX motion handler generalized. Motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ; `highlight-Texinfo' added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ; Revision 2.6 1993/06/24 11:58:52 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ; Mode motion+ support for pcl-cvs added. #undef syntax for C added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ; Revision 2.5 1993/06/09 12:04:31 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ; Delivery motion handlers for `c++-c-mode', `gnus-group-mode', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ; `gnus-summary-mode' added. Mode motion commands bound to copy/cut/past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ; keys for Sun keyboards (f16, f18, f20). Comment added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ; Revision 2.4 1993/02/15 12:59:47 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ; Modifications sent by Tibor Polgar integrated:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ; Optional parameter added to `mode-motion-copy/delete'. User option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ; `mode-motion-focus-on-window' added. It controls window selection for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ; the motion handlers. Minor changes of the delivery motion handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ; Revision 2.3 1993/02/04 18:10:09 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ; User option `mode-motion-minibuffer-completion' added. It controls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ; the minibuffer completion highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ; Revision 2.2 1993/01/27 13:08:12 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ; Improved clearing of `sticky' mode-motion-extents when leaving screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ; or buffer. Function `mode-motion-clear-extent' added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ; Highlight line mouse cursor is behind.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ; `mode-motion-highlight-with-handler' now takes an event as argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ; Cut and paste functions renamed and rewritten. Now they are called:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ; `mode-motion-move', `mode-motion-delete', `mode-motion-copy',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ; `mode-motion-copy-as-kill'. Bug fixes in the C scanner stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ; Motion handler `underline-c' added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ; Revision 2.1 1993/01/19 18:29:58 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ; Scanner and motion handler for C syntax added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ; Function `set-default-motion-handler' added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ; Minor improvements on the `list-motion-handlers' interface done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ; Minor bug fixes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ; Revision 2.0 1993/01/14 19:17:29 bosch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ; Lot of things rewritten and reorganized. This version fits in only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ; one file (beside the required package thing.el).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ; New basic features are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ; - buffer, mode and default motion handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ; - easy composition of own motion handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ; - listing of motion handlers in tabular form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ; - menu interface for changing motion handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ; - only two elisp files: mode-motion+.el, thing.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (require 'thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (require 'mode-motion)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
251 (defconst mode-motion+-version "3.16")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;; This file defines a set of mouse motion handlers that do some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;; highlighting of the text when the mouse moves over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; An exhaustive list of the motion handlers defined in this file may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;; obtained with M-x list-motion-handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;; User Options and their Custommisation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; Mode-motion+ provides four user options, defined beyond. See their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;; documentation string to know what they are good for. If you want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;; to modify their default values, just setq them in your ~/.emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defvar mode-motion+-religion nil ; Initialised in mode-motion-init.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "*Default highlight religion: one of bold, gray, highlight, invert or underline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Unless you setq this otherwise, it defaults to underline when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (x-display-color-p) is non-nil and invert otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 Setting it to 'highlight should cause mode-motion+ extents to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 indistinguishable from any other type of highlighted extent which may or may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 not be advisable, depending on your point of view.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defvar mode-motion-highlight-lines-when-behind t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 "*If non-nil highlight the whole line if the mouse is past the end.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (defvar mode-motion-focus-on-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "*Controls whether moving the mouse into another window selects this window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 The following values are possible:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 nil - Window selection isn't influenced at all by mode motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 t - Window selection always follows the mouse cursor. Copying motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 active regions doesn't work any longer between different buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 any other - window selection follows the mouse cursor if the motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 of the buffer under the mouse has the follow-point property set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 Useful for selecting line mode buffers just by moving the mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 inside in order to execute commands there (VM summary,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 GNUS Group and Subject, DIRED, Buffer menu etc.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defvar mode-motion-setup-cut-and-paste-bindings t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "*If non-nil, bind commands to the Copy, Paste and Cut keys.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; Options sub-menu for mode-motion+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defvar mode-motion+-options-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 '("Motion Highlighting"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "For Current Buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ["None"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (set-buffer-motion-handler (current-buffer) 'no-thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (mode-motion-clear-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 :selected (eq (mode-motion+-buffer-handler-religion (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 'no)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ["Bold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (modify-buffer-motion-handler (current-buffer) 'bold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 :selected (eq (mode-motion+-buffer-handler-religion (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ["Underline"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (modify-buffer-motion-handler (current-buffer) 'underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 :selected (eq (mode-motion+-buffer-handler-religion (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ["Gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (modify-buffer-motion-handler (current-buffer) 'gray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 :selected (eq (mode-motion+-buffer-handler-religion (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 'gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ["Highlight"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (modify-buffer-motion-handler (current-buffer) 'highlight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 :selected (eq (mode-motion+-buffer-handler-religion (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ["Invert"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (modify-buffer-motion-handler (current-buffer) 'invert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 :selected (eq (mode-motion+-buffer-handler-religion (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 'invert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "For Current Mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ["None"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (set-mode-motion-handler major-mode 'no-thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (mode-motion-clear-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 :selected (eq (mode-motion+-mode-handler-religion major-mode) 'no)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ["Bold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (modify-mode-motion-handler major-mode 'bold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 :selected (eq (mode-motion+-mode-handler-religion major-mode) 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ["Underline"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (modify-mode-motion-handler major-mode 'underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 :selected (eq (mode-motion+-mode-handler-religion major-mode) 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ["Gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (modify-mode-motion-handler major-mode 'gray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 :selected (eq (mode-motion+-mode-handler-religion major-mode) 'gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ["Highlight"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (modify-mode-motion-handler major-mode 'highlight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 :selected (eq (mode-motion+-mode-handler-religion major-mode) 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ["Invert"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (modify-mode-motion-handler major-mode 'invert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 :selected (eq (mode-motion+-mode-handler-religion major-mode) 'invert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "For All"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ["None"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (setq mode-motion+-religion 'no)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (mode-motion-init-handlers-according-to-religion 'force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (mode-motion-clear-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 :selected (eq mode-motion+-religion 'no)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ["Bold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (setq mode-motion+-religion 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (mode-motion-init-handlers-according-to-religion 'force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 :selected (eq mode-motion+-religion 'bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ["Underline"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (setq mode-motion+-religion 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (mode-motion-init-handlers-according-to-religion 'force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 :selected (eq mode-motion+-religion 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ["Gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (setq mode-motion+-religion 'gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (mode-motion-init-handlers-according-to-religion 'force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 :selected (eq mode-motion+-religion 'gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ["Highlight"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (setq mode-motion+-religion 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (mode-motion-init-handlers-according-to-religion 'force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 :selected (eq mode-motion+-religion 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ["Invert"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq mode-motion+-religion 'invert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (mode-motion-init-handlers-according-to-religion 'force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 :style radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 :selected (eq mode-motion+-religion 'invert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 :active (mode-motion+-active-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ["Minibuffer highlighting" (setq mode-motion-use-minibuffer-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (not mode-motion-use-minibuffer-motion-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 :style toggle :selected mode-motion-use-minibuffer-motion-handler]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ["Customize..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (list-motion-handlers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ["Revert Customization"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (call-interactively 'mode-motion+-motion-hook-revert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (and (boundp 'mode-motion+-previous-hook) mode-motion+-previous-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 "Menu for changing mode-motion+ religion and other things.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (defun mode-motion+-active-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (cond ((symbolp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (eq mode-motion-hook 'mode-motion+-highlight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ((listp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (memq 'mode-motion+-highlight mode-motion-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defun mode-motion+-buffer-handler-religion (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (let* ((current-handler-name (symbol-name (motion-handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (get-current-motion-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (religion-name (substring current-handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (string-match "-" current-handler-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (intern-soft religion-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun mode-motion+-mode-handler-religion (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (let* ((mode-handler (or (get major-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 default-motion-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (current-handler (symbol-name (motion-handler-name mode-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (religion (substring current-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (string-match "-" current-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (intern-soft religion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defun modify-buffer-motion-handler (buffer religion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (let* ((current-handler (symbol-name (motion-handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (get-current-motion-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (suffix (substring current-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (string-match "-" current-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (set-buffer-motion-handler buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (intern-soft (concat (symbol-name religion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 suffix)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defun modify-mode-motion-handler (mode religion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (let* ((mode-handler (or (get major-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 default-motion-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (current-handler (symbol-name (motion-handler-name mode-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (suffix (substring current-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (string-match "-" current-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (set-mode-motion-handler mode (intern-soft (concat (symbol-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 religion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 suffix)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;;;; This does not work. I would like to be able to modify in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;;;; the non-selectable items, but I don't know how.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;;;; --paquette, Wed Mar 8 23:32:32 1995 (Marc Paquette)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;;; Sensitize the mode motion+ options submenu, a la
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;;; sensitize-file-and-edit-menus-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun mode-motion+-sensitize-options-menu-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 "Hook function that will adjust title items in the mode-motion+ submenu in Options"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (let* ((mm+-menu (cdr (car (find-menu-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 current-menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 '("Options" "Motion Highlighting")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (buffer-item (find-menu-item mm+-menu '("For Current Buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (mode-item (find-menu-item mm+-menu '("For Current Mode"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setcar buffer-item (format "For Buffer `%s'" (buffer-name nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (setcar mode-item (format "For Mode `%s'" major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;;(add-hook 'activate-menubar-hook 'mode-motion+-sensitize-options-menu-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;; Motion Handler Format:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; A motion handler is vector with the following format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;; [<name> - a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; <region computing function> - a function or name of function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; that returns (<startpos> . <endpos>)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; <face or face name> - as it says ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;; <highlight-p> - non-nil means that the motion extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; will be highlighted using the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;; `highlight-extent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; <follow-point-p> - non-nil means that point will follow the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;; mouse motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;; accessor functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defsubst motion-handler-name (handler) (aref handler 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (defsubst motion-handler-boundary-function (handler) (aref handler 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (defsubst motion-handler-face (handler) (aref handler 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defsubst motion-handler-highlight (handler) (aref handler 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defsubst motion-handler-follow-point (handler) (aref handler 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; modifier functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (defsubst set-motion-handler-boundary-function (handler x) (aset handler 1 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defsubst set-motion-handler-face (handler x) (aset handler 2 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (defsubst set-motion-handler-highlight (handler x) (aset handler 3 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defsubst set-motion-handler-follow-point (handler x) (aset handler 4 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ;; Internal global variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defvar motion-handler-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Alist with entries of the form \(<name> . <handler>\).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 ;; Minibuffer motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defvar mode-motion-use-minibuffer-motion-handler t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 "*Enable mousable highlighting when the minibuffer is active. When false only extents with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 highlight property are selectable (*Completion*)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (defvar mode-motion-extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (make-variable-buffer-local 'mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (defvar buffer-motion-handler nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (make-variable-buffer-local 'buffer-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (defvar mode-motion-last-extent nil "The last used mode motion extent.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (defvar default-motion-handler nil) ; Initialised in mode-motion-init.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;; Creation of motion handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (defun find-motion-handler (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (or (symbolp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (setq name (intern-soft name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (cdr (assq name motion-handler-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; internal motion handler creator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defsubst make-motion-handler-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (name boundary-function face highlight follow-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (vector name boundary-function (get-face face) highlight follow-cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defun make-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (name boundary-function &optional face highlight follow-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "Create a motion handler named NAME (a symbol or string) using REGION-FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 REGION-FUNCTION is the function that computes the region to be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 Optional arguments are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 FACE: A face or face name to be used to highlight the region computed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 by REGION-FUNCTION. 'default is the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 HIGHLIGHT: Flag that indicates whether the highlight attribute of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 mode-motion-extent should be set or not. If FACE is the default face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 HIGHLIGHT defaults to t, otherwise to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 FOLLOW-CURSOR: Flag that indicates whether the cursor should follow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 the mouse motion. Default is nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; required arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (or name (error "motion handler name required."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (or (symbolp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (stringp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (error "motion handler name must be a string or symbol: %s" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (or boundary-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (error "motion handler region function required."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (or (fboundp boundary-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (error "not a function: %s." boundary-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (or face (setq face 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; store the mode motion handler on the 'mode-motion-handler property of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; its name symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (let ((old-handler (cdr (assq name motion-handler-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 new-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (if old-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (set-motion-handler-boundary-function old-handler boundary-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (set-motion-handler-face old-handler (get-face face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (set-motion-handler-highlight old-handler highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (set-motion-handler-follow-point old-handler follow-cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq motion-handler-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (cons (cons name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq new-handler (make-motion-handler-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 boundary-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (get-face face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 highlight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 follow-cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 motion-handler-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (or old-handler new-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (defvar list-motion-handlers-buffer-to-customize nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 "Name of buffer from where list-motion-handlers was called.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (make-variable-buffer-local 'list-motion-handlers-buffer-to-customize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (defvar list-motion-handlers-buffer-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 "Name of mode of buffer from where list-motion-handlers was called.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (make-variable-buffer-local 'list-motion-handlers-buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ;; Listing available motion handlers in tabular form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defvar basic-motion-handlers (list 'mode-motion-highlight-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 'mode-motion-highlight-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 'mode-motion-highlight-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 'mode-motion-highlight-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "The basic motion handlers provided by the underlying XEmacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (defun list-motion-handlers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 "Display a list of available motion handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 The listing is in tabular form and contains the following columns:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 NAME: the motion handlers name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 BOUNDARY FUNCTION: the name of the funtion used to compute the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 highlighted by the motion handler,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 FACE: the face used to highlight the text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Additionally, the following flags are used at the beginning of each line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 `*' Marks the motion handler current to the buffer this functions was called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 from.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 `H' Force highlighting of the selected text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 `F' Make point follow the mouse cursor as it moves."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (let ((current-handler (get-current-motion-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (buffer-mode major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (bmmh (if (symbolp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (car (memq mode-motion-hook basic-motion-handlers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (and (listp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (equal 1 (length mode-motion-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (car (memq (car mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 basic-motion-handlers))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (with-output-to-temp-buffer "*Mouse Motion Handlers*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (let ((truncate-lines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (set-buffer "*Mouse Motion Handlers*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (setq list-motion-handlers-buffer-to-customize buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (setq list-motion-handlers-buffer-mode buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (let ((pos1 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (pos2 25)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (pos3 50)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (mapcar 'cdr motion-handler-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 '(lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (string<
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (symbol-name (motion-handler-boundary-function x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (symbol-name (motion-handler-boundary-function y)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if bmmh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (let ((i 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (fw (frame-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (while (< i fw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (princ "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (princ "\nNote: this buffer is not using mode-motion+.\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (princ "It's using the `")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (princ bmmh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (princ "' motion handler which claims it's:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (insert (documentation bmmh))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (princ "\nSetting this motion handler will be irrevocable from this interface\n(but only for duration of this XEmacs session).\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (setq i 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (while (< i fw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (princ "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (terpri)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (princ " NAME BOUNDARY FUNCTION FACE\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (princ " ---- ----------------- ----\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 #'(lambda (handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (let ((line-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (princ (if (and (not bmmh) (eq handler current-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 "*" " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (princ (if (eq handler default-motion-handler) "D" " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (princ (if (motion-handler-highlight handler) "H" " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (princ (if (motion-handler-follow-point handler) "F" " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (indent-to-column pos1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (princ (motion-handler-name handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (indent-to-column pos2 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (princ (motion-handler-boundary-function handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (indent-to-column pos3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (let ((face-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (princ (face-name (motion-handler-face handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (let ((line-extent (make-extent line-start face-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (face-extent (make-extent face-start (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (set-extent-face face-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (motion-handler-face handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (set-extent-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 face-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 'mode-motion-handler (motion-handler-name handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (set-extent-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 line-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 'mode-motion-handler (motion-handler-name handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (set-extent-property line-extent 'highlight t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (terpri)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 handlers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (princ (format "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 Flags: `D' the default motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 `H' handler with highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 `F' handler with `following' property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 `*' the motion handler of buffer \"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 list-motion-handlers-buffer-to-customize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (local-set-key 'button3 'mode-motion-set-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (setq buffer-read-only t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (defun mode-motion-set-handler (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (let* ((handler (or (extent-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (extent-at (event-point event) (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (error "Click on highlighted line to select a handler")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (menu (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (format "Make `%s' the Motion Handler of :" handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (vector (format "Buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 list-motion-handlers-buffer-to-customize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (` (set-buffer-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 '(, list-motion-handlers-buffer-to-customize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 '(, handler))) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (vector "Another Buffer..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (` (motion-handler-list-set-buffer-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 '(, handler))) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (vector (format "Mode %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 list-motion-handlers-buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (` (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (set-mode-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 '(, list-motion-handlers-buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 '(, handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (lambda (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (and (eq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 '(, list-motion-handlers-buffer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (mode-motion+-hook-install buf t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (buffer-list))))) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (vector "Another Mode..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (` (motion-handler-list-set-mode-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 '(, handler))) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (vector "Default Motion Handler"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (` (set-default-motion-handler '(, handler))) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (popup-menu menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (defun motion-handler-list-set-buffer-handler (handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (let ((buffer (read-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (format "Make `%s' the motion handler of buffer: " handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (buffer-name list-motion-handlers-buffer-to-customize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (set-buffer-motion-handler buffer handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (and (not (cond ((listp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (memq 'mode-motion+-highlight mode-motion-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ((symbolp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (eq 'mode-motion+-highlight mode-motion-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (y-or-n-p (format "Augment the default mode motion hook for `%s'? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (buffer-name nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (mode-motion+-hook-install buffer t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (defvar mode-motion+-previous-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 "Value of previous `mode-motion-hook' in current buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (make-variable-buffer-local 'mode-motion+-previous-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (defun motion-handler-list-set-mode-handler (handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (let ((mode (intern (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (format "Make `%s' the motion handler of mode: " handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 'fboundp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (symbol-name list-motion-handlers-buffer-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (set-mode-motion-handler mode handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (lambda (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (and (eq mode major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (mode-motion+-hook-install buf t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (buffer-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (defun mode-motion+-hook-install (&optional buffer remove-highlight-line-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 "Add `mode-motion+-highlight' to the BUFFER `mode-motion-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 If the optional second arg REMOVE-HIGHLIGHT-LINE-P is t, remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 `mode-motion-highlight-line' from `mode-motion-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 See `mode-motion+-hook-uninstall' for reverting this operation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (interactive "bInstall mode-motion+ hook for buffer :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 XRemove highlight-line from hook ? :")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ;; Check for the mode-motion-hook value to make sure it's under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; the control of mode-motion+.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; The reasonning here is that if the user went trough the hassles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; of list-motion-handlers (or if he's calling this directly from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;; his .emacs) , he is prepared to give up on the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;; mode-motion-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;; However, we keep the previous hook value in a buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ;; variable: it will be then possible to revert to the old motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ;; handling behavior with `mode-motion+-hook-uninstall'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ;; --paquette, Mon Feb 27 08:54:30 1995 (Marc Paquette)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (setq buffer (or buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;; force the uninstall of mode-motion-highlight since if its second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;; you'll never see ours.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (setq remove-highlight-line-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (if (boundp 'mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (setq mode-motion+-previous-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (cond ((sequencep mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (copy-sequence mode-motion-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (t mode-motion-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; Make sure that the mode-motion+-highlight is not saved in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; the variable, otherwise, we could not revert back to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; "factory settings" after having played with different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; --paquette, Mon Feb 27 08:54:21 1995 (Marc Paquette)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (remove-hook 'mode-motion+-previous-hook 'mode-motion+-highlight)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (add-hook 'mode-motion-hook 'mode-motion+-highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (and remove-highlight-line-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; Remove the standard mode-motion-highlight hook because we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; provide an alternative to this. I don't use setq here because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; something else could be hooked to mode-motion-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;; --paquette, Mon Feb 27 08:53:51 1995 (Marc Paquette)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (remove-hook 'mode-motion-hook 'mode-motion-highlight-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (delete-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (setq mode-motion-extent nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ;; Try to make this installed for any buffer of this mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (let ((this-mode-hook (intern-soft (concat (symbol-name major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 "-hook"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (and (boundp this-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if remove-highlight-line-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (add-hook this-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 #'(lambda () (mode-motion+-hook-install nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 'append)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (add-hook this-mode-hook 'mode-motion+-hook-install 'append)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (defun mode-motion+-hook-uninstall (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 "Restore the value of `mode-motion-hook' in BUFFER to what it was at the time `mode-motion+-hook-install' was called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 See also `mode-motion+-hook-install'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (interactive "bRestore `mode-motion-hook' of buffer :")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;; Check for the mode-motion-hook value to make sure it's under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;; the control of mode-motion+.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; The reasonning here is that if the user went trough the hassles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; of list-motion-handlers (or if he's calling this directly from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; his .emacs) , he is prepared to give up on the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; mode-motion-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ;; However, we keep the previous hook value in a buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ;; variable: it will be then possible to revert to the old motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ;; handling behavior with `mode-motion+-hook-uninstall'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; --paquette, Mon Feb 27 08:54:30 1995 (Marc Paquette)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (delete-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (setq mode-motion-extent nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (if (boundp 'mode-motion+-previous-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (setq mode-motion-hook mode-motion+-previous-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (setq mode-motion+-previous-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (let ((this-mode-hook (intern-soft (concat (symbol-name major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 "-hook"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (and (boundp this-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (remove-hook this-mode-hook 'mode-motion+-hook-install))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (error "No previous value for mode-motion-hook")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (defun mode-motion+-motion-hook-revert (&optional buffer-only-p buffer mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 "Revert the `mode-motion-hook' to its original value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 With optional arg BUFFER-ONLY-P non-nil, only revert in BUFFER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 \(defaults to `\(current-buffer\)'\); otherwise, revert for all existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 buffers of MODE \(defaults to `major-mode' of BUFFER\)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (let* ((buffer-only-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (y-or-n-p "Revert mode-motion-hook only for current buffer ? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (buffer (if buffer-only-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (get-buffer (read-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 "Revert mode-motion-hook of buffer : "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (buffer-name (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (mode (if buffer-only-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (intern-soft (completing-read "Major mode: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 'fboundp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (symbol-name major-mode))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (list buffer-only-p buffer mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (if buffer-only-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (mode-motion+-hook-uninstall buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (lambda (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (and (eq mode major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (mode-motion+-hook-uninstall buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (buffer-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;; Setting buffer, mode and default motion handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (defun set-buffer-motion-handler (buffer handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 "Make the motion handler named HANDLER-NAME (a symbol) the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 motion handler of BUFFER. If HANDLER-NAME is nil, the corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 buffer motion handler is removed. If HANDLER-NAME isn't the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 known motion handler, an error is signaled. When called interactively,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 completion is provided for available buffers and motion handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 1.\) buffer motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 2.\) mode motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 3.\) default motion handler"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (interactive (list (read-buffer-name "Set motion handler of buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (buffer-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (read-motion-handler-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; kill old mode motion extent, because the new handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; might want to initialize it differently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (if mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (detach-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (setq mode-motion-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (or (get-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (error "No such buffer: %s" buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (setq buffer-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; remove it if `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (and handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ;; set the handler if known
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (or (find-motion-handler handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ;; error otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (error "Not a known motion handler: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 handler-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (if handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (message "Motion handler for buffer %s is `%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (current-buffer) handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (message "Motion handler removed for buffer %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (defun read-buffer-name (prompt &optional initial-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (completing-read prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (mapcar #'(lambda (buf) (list (buffer-name buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;; don't take buffers that start with a blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 #'(lambda (list) (not (eq (aref (car list) 0) ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 initial-input))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (defun set-mode-motion-handler (mode handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 "Make the motion handler named HANDLER-NAME (a symbol) the mode motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 handler for all buffers with major-mode MODE. If HANDLER-NAME is nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 the corresponding mode motion handler is removed. If HANDLER-NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 isn't the name of a known motion handler, an error is signaled. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 called interactively, completion is provided for available motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 1.\) buffer motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 2.\) mode motion handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 3.\) default motion handler"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (interactive (list (intern (completing-read "Major mode: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 'fboundp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (symbol-name major-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (read-motion-handler-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;; kill old mode motion extent, because the new handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;; might want to initialize it differently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (if mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (detach-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (setq mode-motion-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (put mode 'mode-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; remove it if `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (and handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; set the handler if known
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (or (find-motion-handler handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;; error otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (error "Not a known mode motion handler: %s" handler-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (if handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (message "Motion handler for %s is `%s'." mode handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (message "Mode motion handler for %s removed." mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (defun set-default-motion-handler (handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 "Make the motion handler named HANDLER-NAME (a symbol) the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 If HANDLER-NAME is nil, the current default motion handler is removed. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 HANDLER-NAME isn't the name of a known motion handler, an error is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 signalled. When called interactively, completion is provided for available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 motion handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 The motion handler used in a given buffer is determined by the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 most-specific first list: buffer motion handler, mode motion handler, default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 motion handler."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (interactive (list (read-motion-handler-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;; kill old mode motion extent, because the new handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; might want to initialize it differently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (if mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (detach-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (setq mode-motion-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (setq default-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;; remove it if `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (and handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;; set the handler if known
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (or (find-motion-handler handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 ;; error otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (error "Not a known motion handler: %s" handler-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (if handler-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (message "Default motion handler is `%s'." handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (message "Default motion handler removed.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (defun read-motion-handler-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (intern-soft (completing-read "Motion handler: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (mapcar #'(lambda (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (list (symbol-name (car entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 motion-handler-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 ;; clear the last active motion extent when leaving a frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (defun mode-motion-clear-extent (&optional extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 "Clear EXTENT, i.e. make it have no visible effects on the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 EXTENT defaults to the current buffer's mode-motion-extent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (or extent (setq extent mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (and extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (extent-live-p extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (not (extent-detached-p extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (extent-buffer extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (buffer-name (extent-buffer extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;; unhighlight it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (highlight-extent extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 ;; make it span a region that isn't visible and selectable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;; Can this be done more elegantly?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (detach-extent extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (defun mode-motion-clear-last-extent (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 "Clear the mode-motion-last-extent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (or (popup-menu-up-p) (mode-motion-clear-extent mode-motion-last-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (defun mode-motion+-highlight (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 "Highlight the thing under the mouse using a mode-specfic motion handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 See list-motion-handlers for more details."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (mode-motion-clear-last-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (and (event-buffer event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (cond ((and mouse-grabbed-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 ;; first try to do minibuffer specific highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (find-motion-handler 'minibuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (let ((mode-motion-highlight-lines-when-behind nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (and (event-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (or (extent-at (event-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (event-buffer event) 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (mode-motion-highlight-with-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (find-motion-handler 'minibuffer) event))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (t (mode-motion-highlight-with-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (get-current-motion-handler) event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 ;; Return nil since now this is used as a hook, and we want to let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 ;; any other hook run after us.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (defun get-current-motion-handler ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (or (and (boundp 'buffer-motion-handler) buffer-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (get major-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 default-motion-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (defun mode-motion-highlight-with-handler (handler event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 ;; Perform motion highlighting using HANDLER. Information about the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 ;; current mouse position is taken form EVENT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (and handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (let ((point (event-point event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (window-config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (buffer-save (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (point-save (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;; save-window-excursion and restore buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (select-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; Create a new mode-motion-extent if there isn't one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 ;; (or a destroyed one)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (if (and (extent-live-p mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (extent-buffer mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (setq mode-motion-extent (make-extent nil nil buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (set-extent-priority mode-motion-extent 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;; compute the region to be highlighted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (setq region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (if point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;; compute the mode-motion region using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;; handlers boundary function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (condition-case nil;; c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (motion-handler-boundary-function handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ;; Messages that appear during computing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 ;; region may be displayed not done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 ;; here because it's rather disturbing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 ;; (setq message (format "%s" (car (cdr c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;; otherwise highlight the whole line mouse is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;; behind but only if the line isn't empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (if mode-motion-highlight-lines-when-behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 ;; (message "%s" (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (move-to-window-line
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
1137 (if (and (= emacs-major-version 19)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
1138 (< emacs-minor-version 12))
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
1139 (- (event-y event)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (nth 1 (window-edges window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (event-y event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (if (= (following-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 ;; empty line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (thing-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 ;; for `follow-point' behavoir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;; fetch also the newline, if any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;; -- handy for copying >1 line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (if (eobp) point (1+ point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (goto-char point-save)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;; (message "region: %s" region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; the region might be in reverse order. Stop in this case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (<= (car region) (cdr region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (if (or (not (motion-handler-follow-point handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (pos-visible-in-window-p point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (progn
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1162 (set-extent-endpoints
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1163 mode-motion-extent (car region) (cdr region))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (set-extent-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 mode-motion-extent (motion-handler-face handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;; make point follow the mouse or point to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;; the beginning of the line do not move the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; cursor if a mark is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (cond ((and (motion-handler-follow-point handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (not (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; kludge to keep the cursor out the way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (if (or (eq (motion-handler-boundary-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 'line-boundaries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (eq (motion-handler-boundary-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 'visible-line-boundaries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (beginning-of-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (if (and mode-motion-focus-on-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (or (eq mode-motion-focus-on-window t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (motion-handler-follow-point handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ;; Select the current window FROM OUTSIDE the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 ;; `save-window-excursion' that surrounds the call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;; to the current function. This also avoids
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; conflicts with running process filters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (enqueue-eval-event 'select-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 ;; snap in effect, but it ain't yet workin'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 ;; (message "X: %sl; Y: %s"(event-x event)(event-y event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 ;; (and motion-handler-snap-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ;; (set-mouse-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ;; (window-frame (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;; (event-x event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; (event-y event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (setq mode-motion-last-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;; signal success
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ;; signal failiure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (set-window-configuration window-config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (set-buffer buffer-save)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; Motion Event debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;; Useful to see what information is available from motion events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (defun debug-motion-handler (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (let* ((window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (frame (or (event-frame event) (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (buffer (and window (event-buffer event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (point (and buffer (event-point event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (with-output-to-temp-buffer "*Debug Motion Handler Output*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (format "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 Window: %s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 Frame: %s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 Buffer: %s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (event-x, event-y): (%s, %s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (event-x-pixel, event-y-pixel): (%s, %s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 Point: %s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 Timestamp: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (event-x event) (event-y event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (event-x-pixel event) (event-y-pixel event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (event-timestamp event))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;(let ((mouse-motion-handler 'debug-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ; (temp-buffer-show-function nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ; (read-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 ;; Set of copy/kill/move functions for usage with highlighted regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (put 'mode-motion-move 'pending-delete t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (put 'mode-motion-copy 'pending-delete t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (defun mode-motion-move ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 "Move the motion active region to point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (mode-motion-insert-text (mode-motion-copy/delete t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (defun mode-motion-kill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 "Kill the motion active region and push it onto the kill ring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (mode-motion-copy/delete t t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (defun mode-motion-copy ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 "Copy the motion active region to point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (mode-motion-insert-text (mode-motion-copy/delete)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (defun mode-motion-copy-as-kill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 "Delete the motion active region and push it onto the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 Set point to the place where deletion happened."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (mode-motion-copy/delete nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (message "Text copied to the to ring and cut buffer."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (defun mode-motion-copy/delete (&optional delete copy-as-kill set-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 "Return the string that is designated by the current motion active region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 Arguments are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 EVENT - a mouse click event used to identify the buffer and window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 &optional DELETE - delete the motion active text region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 COPY-AS-KILL - copy the string to the kill ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 SET-POINT - set point to the start of the motion active region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (let ((old-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (old-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (let ((extent (or primary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (and (extentp mode-motion-last-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (not (extent-property mode-motion-last-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 'detached))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 mode-motion-last-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (if (and (extentp extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (set-buffer (extent-buffer extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ;; zero length extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (= (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (extent-end-position extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (let* ((start (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (end (extent-end-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (extent-end-position extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (cond (copy-as-kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (copy-region-as-kill start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (if (or (not kill-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (eq kill-hooks 'ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (x-own-selection-internal 'PRIMARY text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (x-own-clipboard text)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (cond (delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (kill-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (x-own-selection-internal 'PRIMARY text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (if set-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (goto-char start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (setq this-command 'mode-motion+)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (error "No current primary or motion selection.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (set-buffer old-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (select-window old-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (defun mode-motion-insert-text (text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 "Insert TEXT at point. Also insert one space if the
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1316 preceding character is a word constituent or a closing paren."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (or text (error "No highlighted text to copy."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (let ((prec-char-syntax (char-syntax (preceding-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (if (memq prec-char-syntax '(?w ?\))) (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (insert text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 ;; Boundary functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 ;; The following functions are already provided by the thing package:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ;; thing-boundaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ;; thing-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 ;; thing-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (defun char-boundaries (point) (thing-region point (1+ point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (defun visible-line-boundaries (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (if (and (eq major-mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (save-excursion (dired-move-to-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (thing-region start (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (defun line-boundaries (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (if (and (eq major-mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (save-excursion (dired-move-to-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (thing-region start (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (defun cvs-line-boundaries (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (if (looking-at "^[* ] ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (thing-region (point) (progn (end-of-line) (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (defun latex-boundaries (here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (setq *last-thing* 'sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (tex-boundaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 here ?\\ "a-zA-Z"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ;; begin-fwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 "\\\\begin *{ *\\([a-z]*\\) *}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 ;; end-fwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 "\\(\\\\end *{ *%s *}\\)\\|\\(\\\\begin *{ *%s *}\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; begin-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 "\\\\end *{ *\\([a-z]*\\) *}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; begin-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 "\\(\\\\end *{ *%s *}\\)\\|\\(\\\\begin *{ *%s *}\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; param-cmd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 "\\\\[a-zA-Z]+[ \n\t]*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (defvar texinfo-paired-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 "enumerate"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 "example"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 "group"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 "ifinfo"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 "iftex"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 "ignore"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 "itemize"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 "menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 "quotation"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 "table"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 "tex"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 "titlepage"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 "\\|"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (defvar texinfo-begin-fwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (format "@\\(%s\\)" texinfo-paired-commands))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (defvar texinfo-end-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (format "@end *\\(%s\\)" texinfo-paired-commands))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (defun texinfo-boundaries (here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (tex-boundaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 here ?@ "a-z"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 texinfo-begin-fwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 ;; end-fwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 "\\(@end *%s\\)\\|\\(@%s\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 ;; end-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 texinfo-end-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 ;; begin-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 "\\(@end *%s\\)\\|\\(@%s\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ;; param-cmd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 "@\\(TeX\\|[a-zA]+\\)[ \n\t]*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (defun tex-boundaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (here cmd-start-character cmd-word-character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 begin-fwd-regexp end-fwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 end-bwd-regexp begin-bwd-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 param-cmd-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 "Generic TeX dialect scanner.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 Parameters:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 cmd-start-character: character that starts a command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (`\' in (La)TeX, `@' in Texinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 cmd-word-character: regexpression to be used by the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 `skip-chars-backward' allowing to skip over command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 characters other than `cmd-start-character'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 begin-fwd-regexp: regexpression matching the begin part of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 text stretch, used in forward search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 end-fwd-regexp: regexpression matching the end part of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 text stretch, used in forward search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 end-bwd-regexp: regexpression matching the end part of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 text stretch, used in backward search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 begin-bwd-regexp: regexpression matching the begin part of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 text stretch, used in backward search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 param-cmd-regexp: regexpression matching a parameterized command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 \(including the open parenthesis\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (cond ((= (following-char) cmd-start-character)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ((= (char-syntax (following-char)) ?w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (skip-chars-backward cmd-word-character)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (if (/= (preceding-char) cmd-start-character)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (thing-boundaries here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (catch 'return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (cond ((looking-at begin-fwd-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (let* ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (env (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (regexp (format end-fwd-regexp env env))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (while (re-search-forward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (cond ((match-beginning 2) ; \begin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (setq count (1+ count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 ((match-beginning 1) ; \end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (setq count (1- count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (if (= count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (throw 'return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (thing-region start (point)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 ((looking-at end-bwd-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (let* ((end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (env (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (format begin-bwd-regexp env env))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (while (re-search-backward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (cond ((match-beginning 1) ; \end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (setq count (1+ count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ((match-beginning 2) ; \begin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (setq count (1- count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (if (= count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (throw 'return (thing-region (point) end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 ;; tex macros of the form \cmd {...}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ((looking-at param-cmd-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (thing-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (goto-char (1- (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ;; fetch the current macro (with backslash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (t (thing-region (point) (progn (forward-word 1) (point)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 ;; special parse of buffer for valid selectable info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (defun minibuffer-selection-boundaries (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (let ((old-syntax (syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; best syntax table for recognizing symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (set-syntax-table emacs-lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (let ((file-completion (eq minibuffer-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 'read-file-name-internal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 minibuf-string ;contents of minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 buffer-string ;string to be highlighted (or not)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 prefix ;prefix calculated from minibuf-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 string ;string to be verified in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;completion table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (setq region (if file-completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (thing-filename point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (thing-symbol point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 minibuf-string ; contents of minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (set-buffer mouse-grabbed-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 buffer-string ; string to be highlighted (or not)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (buffer-substring (car region) (cdr region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (if file-completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (file-name-nondirectory minibuf-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 minibuf-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (if file-completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (concat (file-name-directory minibuf-string) buffer-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (if (or (and (fboundp 'ange-ftp-ftp-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (or (ange-ftp-ftp-path buffer-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (ange-ftp-ftp-path string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (and (fboundp 'efs-ftp-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (or (efs-ftp-path buffer-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (efs-ftp-path string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 ;; #### Like our counterpart in mode-motion: evil evil evil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (if file-completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (try-completion string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 minibuffer-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 minibuffer-completion-predicate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (eq 't (try-completion string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 minibuffer-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 minibuffer-completion-predicate))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ;; the result is the region to be highlighted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (set-syntax-table old-syntax))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ;; C source code scanner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (defvar c-statement-starting-keyword-regexpr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 "\\(if\\|for\\|while\\|do\\|switch\\|break\\|continue\\)\\b")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (defun c-boundaries (here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (setq *last-thing* 'sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (let ((following-char (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (preceding-char (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 aux)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (if (= (char-syntax following-char) ?w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (skip-chars-backward "a-zA-Z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (setq aux (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (skip-chars-backward "\n\t ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (if (= (preceding-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (goto-char aux))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (if (and (= following-char ?*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (= preceding-char ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (if (and (= following-char ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (= preceding-char ?*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ((= (following-char) ?#) (c-scan-preproc-macros))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 ((looking-at "/\\*") ; begin comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (let ((start (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (if (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (thing-region start (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ((looking-at "\\*/") ; end comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (let ((end (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (if (search-backward "/*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (thing-region (match-beginning 0) end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ((looking-at c-statement-starting-keyword-regexpr) ; if for while do etc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (thing-region (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (c-forward-statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (buffer-substring (match-beginning 1) (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ((looking-at "else\\b")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (thing-region (match-beginning 0) (c-forward-else)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (t (if (= (char-syntax (following-char)) ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (thing-region here (1+ here))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (thing-boundaries here)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (defun c-scan-preproc-macros ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ((looking-at "^#[ \n\t]*include[ \n\t]*[<\"][^>\"]*[>\"]") ; #include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (thing-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 ((looking-at "^#[ \n\t]*\\(define\\|undef\\)") ; #define, #undef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (thing-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (while (= (preceding-char) ?\\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 ;; #if, #ifdef, #ifndef, #else, #elif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ((looking-at "^#[ \n\t]*\\(if\\|ifdef\\|ifndef\\|else\\|elif\\)\\b")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (let ((start (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (counter 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (while (and (>= counter 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 "^#[ \n\t]*\\(if\\|ifdef\\|ifndef\\|endif\\)\\b"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (setq match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (setq counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (if (string= match "endif")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (1- counter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (1+ counter))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (if (= counter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (thing-region start (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 ((looking-at "^#[ \n\t]*endif\\b") ; #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (let ((end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (counter 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (while (and (>= counter 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 "^#[ \n\t]*\\(if\\|ifdef\\|ifndef\\|endif\\)\\b"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (setq match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (setq counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (if (string= match "endif")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (1+ counter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (1- counter))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (if (= counter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (thing-region (match-beginning 0) end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (defun c-skip-over-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (let ((aux (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (skip-chars-forward "\n\t ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (or (and (= (following-char) ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (= (char-after (1+ (point))) ?*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (goto-char aux))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (defun c-forward-statement (&optional keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (c-skip-over-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (skip-chars-forward " \n\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (or keyword (setq keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (if (looking-at c-statement-starting-keyword-regexpr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (if keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (cond ((string= keyword "if")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (c-forward-if))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ((string= keyword "do")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (c-forward-do-while))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 ((member keyword '("for" "while" "switch"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (c-forward-for/while/switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ((member keyword '("break" "continue"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (c-forward-break/continue)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (cond ((= (following-char) ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (forward-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 ;; Here I use that each C statement other then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; a bloc, if, while, for, do ... ends in a `;'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (let (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (catch 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (if (eobp) (throw 'exit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (setq char (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (cond ((= (char-syntax char) ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (if (= char ?\;) (throw 'exit (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (t (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (skip-chars-forward " \n\t"))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (defun c-forward-if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (let (aux)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (forward-word 1) ; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (forward-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (c-forward-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (setq aux (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (skip-chars-forward "\n\t ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (if (looking-at "else\\b")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (c-forward-else)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (goto-char aux))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (defun c-forward-else ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (forward-word 1) ; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (c-forward-statement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (defun c-forward-for/while/switch ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (forward-word 1) ; for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (forward-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (c-forward-statement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (defun c-forward-do-while ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (forward-word 1) ; do ... while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (c-forward-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (c-forward-for/while/switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (defun c-forward-switch ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (forward-word 1) ; switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (forward-list 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (defun c-forward-break/continue ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (forward-word 1) ; keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (c-skip-over-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (skip-chars-forward "\n\t ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (if (= (following-char) ?\;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (goto-char (1+ (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ;; Tcl syntax scanner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (defvar tcl-builtin-commands nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 "Alist of information about tcl syntax for the tcl-boundaries function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 An entry has the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 \(<command-string> . <syntax description>\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 <command-string> is the name of a tcl command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 <syntax description> is one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 list of integers: the number of possible arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 t: any number of arguments")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (defconst tcl-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 ("append" . (2 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ("array" . (2 . 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ("break" . 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ("case" . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ("catch" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ("cd" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ("close" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 ("concat" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 ("continue" . 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ("else" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ("elseif" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ("eof" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ("error" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ("eval" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ("exec" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ("exit" . (0 . 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ("expr" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ("file" . (2 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 ("flush" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ("for" . 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 ("foreach" . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ("format" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 ("gets" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 ("glob" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 ("global" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ("history" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 ("if" . (2 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 ("incr" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 ("info" . (1 . 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ("join" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ("lappend" . (2 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 ("lindex" . 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ("linsert" . (3 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 ("list" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ("llength" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ("lrange" . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ("lreplace" . (3 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 ("lsearch" . 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 ("lsort" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ("open" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ("proc" . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ("puts" . (1 . 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ("pwd" . 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ("read" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ("regexp" . (2 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ("regsub" . (4 . 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 ("rename" . 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ("return" . (0 .1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ("scan" . (3 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ("seek" . (2 . 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ("set" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 ("source" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ("split" . (1 . 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ("string" . (2 . 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ("tell" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 ("time" . (1 .2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 ("trace" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 ("unknown" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 ("unset" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 ("uplevel" . (1 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 ("upvar" . (2 . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ("while" . 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (defconst tk-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 '(("bind" . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ("button" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ("canvas" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ("frame" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ("label" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ("listbox" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 ("menu" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ("menubutton" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ("pack" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 ("scrollbar" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ("tree" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 ("wm" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (defconst tcl-tk-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (nconc tcl-commands tk-commands))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (defconst tcl-tk-commands-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (format "\\(%s\\\)\\W" (mapconcat 'car tcl-tk-commands "\\|")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (defun tcl-boundaries (here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (skip-chars-backward "a-z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (if (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 tcl-tk-commands-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (let* ((count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (keyword (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (syntax-description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (cdr (assoc keyword tcl-tk-commands))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (while (not (looking-at "[ \t]*[]\n;}]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (setq count (1+ count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (tcl-forward-sexp1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ;; skipping over the parentheses of array expressions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (while (not (or (looking-at "[ \t]*[]\n;}]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (= (char-syntax (following-char)) ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (tcl-forward-sexp1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (if (cond ((eq syntax-description t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ((integerp syntax-description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (= syntax-description count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 ((consp syntax-description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (and (<= (car syntax-description) count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (or (null (cdr syntax-description))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 (<= count (cdr syntax-description))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (message "`%s' matched." keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (thing-region start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (message "wrong syntax: `%s'." keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (thing-boundaries here))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (defun tcl-forward-sexp (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 "Move forward across one balanced tcl expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 With argument, do it that many times."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (if (< arg 0) (error "negative argument not allowed"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (or arg (setq arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (tcl-forward-sexp1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (setq arg (1- arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (defun tcl-forward-sexp1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (interactive "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 next-char syntax (first-scan t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (setq next-char (following-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 syntax (char-syntax next-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (while (or (= next-char ?\;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (memq syntax '(? ?>)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (setq next-char (following-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 syntax (char-syntax next-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (condition-case var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (catch 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (setq next-char (following-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 syntax (char-syntax next-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (cond ((= next-char ?\;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (throw 'exit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ((memq syntax (if first-scan '(? ?>) '(? ?> ?\))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (throw 'exit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (goto-char (or (scan-sexps (point) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (setq first-scan nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (error (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (error (car (cdr var)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 ;; (define-key tcl-mode-map "\M-\C-f" 'tcl-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (defun mode-motion-eval-func (eval-func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (let ((old-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (old-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (let ((extent (or primary-selection-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (and (extentp mode-motion-last-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (not (extent-property mode-motion-last-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 'detached))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 mode-motion-last-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (if (and (extentp extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (set-buffer (extent-buffer extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 ;; zero length extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (= (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (extent-end-position extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (let* ((start (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (end (extent-end-position extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (funcall eval-func start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (error "No current primary or motion selection.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (set-buffer old-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (select-window old-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (defun mode-motion-eval-region ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (mode-motion-eval-func 'eval-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 ;; Motion highlight faces and initialization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (defun sect-handler (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 "Return the symbol corresponding to the foo-STRING handler for this sect."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (intern-soft (concat (symbol-name mode-motion+-religion) string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (defun mode-motion-init-handlers-according-to-religion (&optional forcep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 ;; Initialise default motion handlers depending on religious sect!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (let ((foo-thing (sect-handler "-thing"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (foo-c (sect-handler "-c"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (foo-LaTeX (sect-handler "-laTeX"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (foo-line@ (sect-handler "-line@"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (foo-vline@ (sect-handler "-vline@")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (if forcep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (setq default-motion-handler (find-motion-handler foo-thing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (set-mode-motion-handler 'emacs-lisp-mode foo-thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (set-mode-motion-handler 'lisp-interaction-mode foo-thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (set-mode-motion-handler 'c-mode foo-c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (set-mode-motion-handler 'c++-mode foo-c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (set-mode-motion-handler 'c++-c-mode foo-c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (set-mode-motion-handler 'tex-mode foo-LaTeX)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (set-mode-motion-handler 'latex-mode foo-LaTeX)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (set-mode-motion-handler 'Buffer-menu-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (set-mode-motion-handler 'Electric-Buffer-menu-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (set-mode-motion-handler 'gnus-Group-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (set-mode-motion-handler 'gnus-Subject-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (set-mode-motion-handler 'gnus-group-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (set-mode-motion-handler 'gnus-subject-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (set-mode-motion-handler 'gnus-summary-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (set-mode-motion-handler 'dired-mode foo-line@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (set-mode-motion-handler 'compilation-mode foo-line@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (set-mode-motion-handler 'occur-mode foo-line@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (set-mode-motion-handler 'tar-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (set-mode-motion-handler 'rmail-summary-mode foo-vline@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (set-mode-motion-handler 'vm-summary-mode (sect-handler "-line"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (set-mode-motion-handler 'tcl-mode (sect-handler "-tcl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (set-mode-motion-handler 'texinfo-mode (sect-handler "-TeXinfo"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (set-mode-motion-handler 'cvs-mode (sect-handler "-cvs-line")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (setq default-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (or default-motion-handler (find-motion-handler foo-thing)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (or (get 'emacs-lisp-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (set-mode-motion-handler 'emacs-lisp-mode foo-thing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (or (get 'lisp-interaction-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (set-mode-motion-handler 'lisp-interaction-mode foo-thing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (or (get 'c-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (set-mode-motion-handler 'c-mode foo-c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (or (get 'c++-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (set-mode-motion-handler 'c++-mode foo-c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (or (get 'c++-c-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (set-mode-motion-handler 'c++-c-mode foo-c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (or (get 'tex-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (set-mode-motion-handler 'tex-mode foo-LaTeX))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (or (get 'latex-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (set-mode-motion-handler 'latex-mode foo-LaTeX))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (or (get 'Buffer-menu-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (set-mode-motion-handler 'Buffer-menu-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (or (get 'Electric-Buffer-menu-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (set-mode-motion-handler 'Electric-Buffer-menu-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (or (get 'gnus-Group-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (set-mode-motion-handler 'gnus-Group-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (or (get 'gnus-Subject-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (set-mode-motion-handler 'gnus-Subject-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 (or (get 'gnus-group-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (set-mode-motion-handler 'gnus-group-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (or (get 'gnus-subject-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (set-mode-motion-handler 'gnus-subject-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (or (get 'gnus-summary-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (set-mode-motion-handler 'gnus-summary-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (or (get 'dired-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (set-mode-motion-handler 'dired-mode foo-line@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (or (get 'compilation-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (set-mode-motion-handler 'compilation-mode foo-line@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (or (get 'occur-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (set-mode-motion-handler 'occur-mode foo-line@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (or (get 'tar-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (set-mode-motion-handler 'tar-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (or (get 'rmail-summary-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (set-mode-motion-handler 'rmail-summary-mode foo-vline@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (or (get 'vm-summary-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (set-mode-motion-handler 'vm-summary-mode (sect-handler "-line")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (or (get 'tcl-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (set-mode-motion-handler 'tcl-mode (sect-handler "-tcl")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (or (get 'texinfo-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (set-mode-motion-handler 'texinfo-mode (sect-handler "-TeXinfo")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (or (get 'cvs-mode 'mode-motion-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (set-mode-motion-handler 'cvs-mode (sect-handler "-cvs-line"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 ;; Null Handlers (for disabling motion highlighting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (defun thing-null (here) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (make-motion-handler 'no-thing 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (make-motion-handler 'no-c 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (make-motion-handler 'no-laTeX 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (make-motion-handler 'no-line 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (make-motion-handler 'no-line@ 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (make-motion-handler 'no-vline 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (make-motion-handler 'no-vline@ 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (make-motion-handler 'no-tcl 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (make-motion-handler 'no-TeXinfo 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (make-motion-handler 'no-cvs-line 'thing-null)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (defun mode-motion-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 "enable mode-motion+ package"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (setq mode-motion-last-extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (global-set-key '(meta button2) 'mode-motion-copy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (global-set-key '(meta shift button2) 'mode-motion-move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (global-set-key '(meta control button2) 'mode-motion-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (global-set-key '(meta control shift button2) 'mode-motion-copy-as-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (global-set-key '(meta control symbol button2) 'mode-motion-copy-as-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (if mode-motion-setup-cut-and-paste-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (global-set-key 'f16 'mode-motion-copy-as-kill) ; Copy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (global-set-key 'f18 'yank) ; Paste
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (global-set-key 'f20 'mode-motion-kill))) ; Cut
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;; I don't want the thing-boundaries function select whitespaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (setq thing-report-whitespace nil thing-report-char-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 ;; bold motion face (bold, if this is not the default, unbold otherwise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (if (find-face 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (make-face 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (make-face-bold 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (or (face-differs-from-default-p 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (make-face-unbold 'motion-bold)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 ;; an underline face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (if (find-face 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (make-face 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (set-face-underline-p 'motion-underline t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 ;; an inverted face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (if (find-face 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (make-face 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (make-face-bold 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (invert-face 'motion-inverted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (if (find-face 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (make-face 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (set-face-background-pixmap 'motion-gray "gray1.xbm"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 ;; Motion Handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 ;; Special Minibuffer handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (make-motion-handler 'minibuffer 'minibuffer-selection-boundaries 'highlight t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 ;; Things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (make-motion-handler 'bold-thing 'thing-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (make-motion-handler 'gray-thing 'thing-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (make-motion-handler 'highlight-thing 'thing-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (make-motion-handler 'invert-thing 'thing-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (make-motion-handler 'underline-thing 'thing-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;; Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (make-motion-handler 'bold-line 'line-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (make-motion-handler 'gray-line 'line-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (make-motion-handler 'highlight-line 'line-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (make-motion-handler 'invert-line 'line-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (make-motion-handler 'underline-line 'line-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (make-motion-handler 'bold-line@ 'line-boundaries 'motion-bold t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (make-motion-handler 'gray-line@ 'line-boundaries 'motion-gray nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (make-motion-handler 'highlight-line@ 'line-boundaries 'highlight nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (make-motion-handler 'invert-line@ 'line-boundaries 'motion-inverted nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (make-motion-handler 'underline-line@ 'line-boundaries 'motion-underline nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 ;; Visible text of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (make-motion-handler 'bold-vline 'visible-line-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (make-motion-handler 'gray-vline 'visible-line-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (make-motion-handler 'highlight-vline 'visible-line-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (make-motion-handler 'invert-vline 'visible-line-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (make-motion-handler 'underline-vline 'visible-line-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (make-motion-handler 'bold-vline@ 'visible-line-boundaries 'motion-bold t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (make-motion-handler 'gray-vline@ 'visible-line-boundaries 'motion-gray nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (make-motion-handler 'highlight-vline@ 'visible-line-boundaries 'highlight nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (make-motion-handler 'invert-vline@ 'visible-line-boundaries 'motion-inverted nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (make-motion-handler 'underline-vline@ 'visible-line-boundaries 'motion-underline nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 ;; CVS lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (make-motion-handler 'bold-cvs-line 'cvs-line-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (make-motion-handler 'gray-cvs-line 'cvs-line-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (make-motion-handler 'highlight-cvs-line 'cvs-line-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (make-motion-handler 'invert-cvs-line 'cvs-line-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (make-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 'underline-cvs-line 'cvs-line-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 ;; (La)TeX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (make-motion-handler 'bold-LaTeX 'latex-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (make-motion-handler 'gray-LaTeX 'latex-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (make-motion-handler 'highlight-LaTeX 'latex-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (make-motion-handler 'invert-LaTeX 'latex-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (make-motion-handler 'underline-LaTeX 'latex-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; TeXinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (make-motion-handler 'bold-TeXinfo 'texinfo-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (make-motion-handler 'gray-TeXinfo 'texinfo-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (make-motion-handler 'highlight-TeXinfo 'texinfo-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (make-motion-handler 'invert-TeXinfo 'texinfo-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (make-motion-handler 'underline-TeXinfo 'texinfo-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 ;; C and C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (make-motion-handler 'bold-c 'c-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (make-motion-handler 'gray-c 'c-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (make-motion-handler 'highlight-c 'c-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (make-motion-handler 'invert-c 'c-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 (make-motion-handler 'underline-c 'c-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 ;; Tcl/Tk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (make-motion-handler 'bold-tcl 'tcl-boundaries 'motion-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (make-motion-handler 'gray-tcl 'tcl-boundaries 'motion-gray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (make-motion-handler 'highlight-tcl 'tcl-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (make-motion-handler 'invert-tcl 'tcl-boundaries 'motion-inverted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (make-motion-handler 'underline-tcl 'tcl-boundaries 'motion-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 ;; mouse tracker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (make-motion-handler 'track-mouse@ 'char-boundaries nil nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (make-motion-handler 'highlight-char 'char-boundaries 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 ;; augment the basic mouse motion handler (if any)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (setq-default mode-motion-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (if (listp mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (if (memq #'mode-motion+-highlight mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 mode-motion-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (append mode-motion-hook (list #'mode-motion+-highlight)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (list mode-motion-hook #'mode-motion+-highlight)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (or mode-motion+-religion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (setq mode-motion+-religion (if (x-display-color-p) 'underline 'invert)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (add-menu '("Options") (car mode-motion+-options-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (cdr mode-motion+-options-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 "Paren Highlighting")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 ;; shut your eyes, this is a kludge. I didn't have time to find/write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 ;; a function to do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (or (member ["Eval Motion Region" mode-motion-eval-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 lisp-interaction-mode-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (and (setq lisp-interaction-mode-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (copy-sequence lisp-interaction-mode-popup-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (setcdr (nthcdr 1 lisp-interaction-mode-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (cons ["Eval Motion Region" mode-motion-eval-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (nthcdr 2 lisp-interaction-mode-popup-menu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (or (member ["Eval Motion Region" mode-motion-eval-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 emacs-lisp-mode-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (and (setq emacs-lisp-mode-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (copy-sequence emacs-lisp-mode-popup-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (setcdr (nthcdr 3 emacs-lisp-mode-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (cons ["Eval Motion Region" mode-motion-eval-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (nthcdr 4 emacs-lisp-mode-popup-menu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 ;; Clear the last active motion extent when leaving a frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (if (boundp 'mouse-leave-frame-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (add-hook 'mouse-leave-frame-hook 'mode-motion-clear-last-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (add-hook 'mouse-leave-screen-hook 'mode-motion-clear-last-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (run-hooks 'mode-motion+-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (mode-motion-init-handlers-according-to-religion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (if (interactive-p) (message "mode-motion+ enabled")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (if (and (not purify-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (or (not (boundp 'opt-mode-motion+)) opt-mode-motion+))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (mode-motion-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (provide 'mode-motion+)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 ;; end mode-motion+