annotate lisp/packages/mode-motion+.el @ 0:376386a54a3c r19-14

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