annotate lisp/hm--html-menus/internal-drag-and-drop.el @ 155:43dd3413c7c7 r20-3b4

Import from CVS: tag r20-3b4
author cvs
date Mon, 13 Aug 2007 09:39:39 +0200
parents 25f70ba0133c
children 6075d714658b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
1 ;;; $Id: internal-drag-and-drop.el,v 1.4 1997/05/29 23:49:44 steve Exp $
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
2 ;;;
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
3 ;;; Copyright (C) 1996, 1997 Heiko Muenkel
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
4 ;;; email: muenkel@tnt.uni-hannover.de
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
5 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
6 ;;; This program is free software; you can redistribute it and/or modify
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
7 ;;; it under the terms of the GNU General Public License as published by
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
8 ;;; the Free Software Foundation; either version 1, or (at your option)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
9 ;;; any later version.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
10 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
11 ;;; This program is distributed in the hope that it will be useful,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
14 ;;; GNU General Public License for more details.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
15 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
16 ;;; You should have received a copy of the GNU General Public License
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
17 ;;; along with this program; if not, write to the Free Software
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
18 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
19 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
20 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
21 ;;; Description:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
22 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
23 ;;; This package provides functions to define and call internal
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 ;;; drag and drop actions in the emacs. One could start such an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 ;;; action by clicking with the mouse in the source buffer and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26 ;;; then in the destination buffer. The action could depend on
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
27 ;;; the points where you've clicked with the mouse, on the state
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28 ;;; of the region, the point, the mark and any other properties
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 ;;; of the source and the destination buffers. The actions are
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30 ;;; defined by the variable `idd-actions', which is a buffer local
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
31 ;;; variable. The following is an example for the hm--html-mode:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
32 ;;; (defvar hm--html-idd-actions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
33 ;;; '((nil (((idd-if-major-mode-p . dired-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
34 ;;; (idd-if-dired-file-on-line-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
35 ;;; . ".*\\.\\(gif\\)\\|\\(jpq\\)"))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36 ;;; hm--html-idd-add-include-image-from-dired-line)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
37 ;;; (((idd-if-major-mode-p . dired-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
38 ;;; (idd-if-dired-no-file-on-line-p . nil))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
39 ;;; hm--html-idd-add-file-link-to-file-on-dired-line)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
40 ;;; (((idd-if-major-mode-p . dired-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
41 ;;; (idd-if-dired-no-file-on-line-p . t))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
42 ;;; hm--html-idd-add-file-link-to-directory-of-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
43 ;;; (((idd-if-major-mode-p . w3-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
44 ;;; (idd-if-url-at-point-p . t))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
45 ;;; hm--html-idd-add-html-link-from-w3-buffer-point)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
46 ;;; (((idd-if-major-mode-p . w3-mode))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47 ;;; hm--html-idd-add-html-link-to-w3-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
48 ;;; (((idd-if-local-file-p . t))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
49 ;;; hm--html-idd-add-file-link-to-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
50 ;;; Look at the variable `idd-actions' for further descriptions.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
51 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
52 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
53 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
54 ;;; Installation:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
55 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
56 ;;; Put this file in one of your load path directories.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
57 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
58 ;;; Put the following in your .emacs:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
59 ;;; (autoload 'idd-mouse-drag-and-drop "internal-drag-and-drop"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
60 ;;; "Performs a drag and drop action.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61 ;;; At first you must click on the source and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
62 ;;; after that on the destination."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
63 ;;; t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
64 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
65 ;;; Define actions in the variable `idd-actions'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
66 ;;;
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
67 ;;; The variable `idd-global-mouse-keys' defines the mouse keys,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
68 ;;; which are bound to the drag and drop command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
69 ;;;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
70 ;;; The variable `idd-global-help-mouse-keys' defines the mouse keys,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
71 ;;; which are bound to the drag and drop help command.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
72 ;;;
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
73 ;;; The variable `idd-drag-and-drop-mouse-binding-type' determines
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
74 ;;; if you've to hold a mouse button down during moving the mouse
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
75 ;;; from the source to the destination or not.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
76 ;;;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
77 ;;; Emacs 19 users should read carefully the whole comments of
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
78 ;;; `idd-drag-and-drop-mouse-binding-type', `idd-global-mouse-keys'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
79 ;;; and `idd-global-help-mouse-keys', if they would like to change
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
80 ;;; any of these variables or the mouse bindings!
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
81 ;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
82
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
83 (require 'adapt)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
84 (require 'cl)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
85
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
86 (defvar idd-drag-and-drop-mouse-binding-type 'click
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
87 "*The type of the drag and drop mouse binding.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
88 The value maybe `click' or `press-button-during-move'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
89 A value of `click' means, that you've to click over the source, leave
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
90 the button and click it again over the destination.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
91 A value of `press-button-during-move' means, that you've to press
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
92 the button down over the source and hold it until the mouse pointer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
93 is over the destination.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
94
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
95 The disadvantage of the `press-button-during-move' type compared with
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
96 the `click' type is, that you can't select a destination region and
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
97 therefore a drag and drop action depending on a selected region can't
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
98 be started with that type of mouse binding.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
99
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
100 Note: In the Emacs 19 you'll have to change also the keybindings of
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
101 the drag and drop commands, if you change this variable. Look at the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
102 variables `idd-global-mouse-keys' and `idd-global-help-mouse-keys' for
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
103 this.")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
104
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
105 (defvar idd-global-mouse-keys (if (adapt-emacs19p)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
106 (if (eq idd-drag-and-drop-mouse-binding-type
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
107 'click)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
108 [(meta control mouse-1)]
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
109 [(meta control down-mouse-1)])
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
110 [(meta control button1)])
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
111 "The mouse keys for the command `idd-mouse-drag-and-drop'.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
112 The command `idd-mouse-drag-and-drop' is bound during the loading
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
113 of the package internal-drag-and-drop to this keys in the global
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
114 key map.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
115
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
116 Set it to nil, if you don't want to bind this function during loading.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
117
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
118 If the command is already bound in the global keymap during loading,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
119 then this key sequence will not be bind.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
120
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
121 Note: In the Emacs 19 the mouse keys must contain the modifier
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
122 `down', if `idd-drag-and-drop-mouse-binding-type' is set to
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
123 `press-button-during-move' and must not contain the modifier, if it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
124 is set to `click'. If you set `idd-drag-and-drop-mouse-binding-type'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
125 before loading the package internal-drag-and-drop, the mouse will
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
126 be bind in the right way.")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
127
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
128 (defvar idd-global-help-mouse-keys
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
129 (if (adapt-emacs19p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
130 (if (eq idd-drag-and-drop-mouse-binding-type 'click)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
131 [(meta control mouse-3)]
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
132 [(meta control down-mouse-3)])
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
133 [(meta control button3)])
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
134 "The mouse keys for the command `idd-help-mouse-drag-and-drop'.
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
135 The command `idd-help-mouse-drag-and-drop' is bound during the loading
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
136 of the package internal-drag-and-drop to this keys in the global
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
137 key map.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
138
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
139 Set it to nil, if you don't want to bind this function during loading.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
140
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
141 If the command is already bound in the global keymap during loading,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
142 then this key sequence will not be bind.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
143
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
144 Note: In the Emacs 19 the mouse keys must contain the modifier
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
145 `down', if `idd-drag-and-drop-mouse-binding-type' is set to
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
146 `press-button-during-move' and must not contain the modifier, if it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
147 is set to `click'. If you set `idd-drag-and-drop-mouse-binding-type'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
148 before loading the package internal-drag-and-drop, the mouse will
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
149 be bind in the right way.")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
150
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
151 (defvar idd-actions '((((idd-if-region-active-p . nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
152 (((idd-if-region-active-p . t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
153 idd-action-copy-region))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
154
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
155 (((idd-if-region-active-p . t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
156 (((idd-if-region-active-p . t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
157 idd-action-copy-replace-region))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
158
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
159 (((idd-if-region-active-p . nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 (idd-if-modifiers-p . nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
161 (((idd-if-region-active-p . t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
162 idd-action-move-region))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
163
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
164 (((idd-if-region-active-p . t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
165 (idd-if-modifiers-p . nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
166 (((idd-if-region-active-p . t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
167 idd-action-move-replace-region))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
168 )
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
169 "The list with actions, depending on the source and the destination.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
170 The list looks like:
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
171 '((<destination-specification-1> (<source-specification-1> <action-1-1>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
172 (<source-specification-2> <action-1-2>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
173 :
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
174 )
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
175 (<destination-specification-2> (<source-specification-1> <action-2-1>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
176 (<source-specification-2> <action-2-2>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
177 :
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
178 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
179 :
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
180 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
181 The <source-specification> looks like the following:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
182 '([(<specification-type> <value>)])
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
183 with <specification-type> :== idd-if-minor-mode-p | idd-if-buffer-name-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
184 | idd-if-region-active-p | idd-if-url-at-point-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
185 | idd-if-major-mode-p | idd-if-variable-non-nil-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
186 | idd-if-dired-file-on-line-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
187 | idd-if-dired-no-file-on-line-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
188 | idd-if-local-file-p | idd-if-buffer-name-p
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
189 | idd-if-modifiers-p | ...
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
190
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
191 The <specification-type> - functions must have two arguments, the first one
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
192 is the source or destination and the second is the <value>. It must return
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
193 nil, if the test wasn't successfull and a number (in general 1), which
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
194 specifies the weight of the test function. The weights of all single tests
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
195 are added to a summary weight and assigned to the action. The action
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
196 with the highest weight is called from the action handler. Look at
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
197 the definition of `idd-if-major-mode-p', `idd-if-minor-mode-p' and so on for
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
198 examples. Look at the function `idd-get-source-or-destination-alist', if
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
199 you wan't to know the structure of the 'source-or-destination' argument
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
200 of these functions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
201
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
202 The <destination-specification> looks like <source-specification>,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
203 but in general it could be set to nil in mode specific idd-action
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
204 lists.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
205
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
206 If <destination-specification-1> or <source-specification-1> is set to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
207 nil, then every source or source matches. `idd-actions' is a
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 46
diff changeset
208 buffer local variable, which should be at least mode depended. So if
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
209 the <destination-specification-1> is set to nil it says, that the destination
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 46
diff changeset
210 buffer must only have a specific mode. But however, it's also possible
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
211 to define a general `idd-actions' list, where the destination mode is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
212 specified by `idd-if-major-mode-p'.
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 2
diff changeset
213
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
214 <action> ist a function, which has two arguments, the first specifies the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
215 source and the second the destination. Look at the function definition
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
216 of `idd-action-copy-region' and `idd-action-copy-replace-region'. They are
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
217 examples for such actions.")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
218
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
219 (make-variable-buffer-local 'idd-actions)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
220
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
221 (defvar idd-help-instead-of-action nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
222 "*If this variable is t, then a help buffer is displayed.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
223 No action will be performed if this variable is t.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
224
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
225 (defvar idd-help-start-action-keymap nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
226 "Keymap used in an extent in the help buffer to start the action.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
227
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
228 (defvar idd-help-source nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
229 "Contains the source of an action. Used only in the help buffer.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
230
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
231 (defvar idd-help-destination nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
232 "Contains the destination of an action. Used only in the help buffer.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
233
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
234 (defvar idd-help-start-extent nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
235 "The start extent in the help buffer.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
236
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
237 (defun idd-compare-a-specification (source-or-destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
238 specification)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
239 "Tests if SOURCE-OR-DESTINATION matches the SPECIFICATION.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
240 It returns a value (1 in general) if both are matching or nil."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
241 (eval (list (car specification)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
242 'source-or-destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
243 '(cdr specification))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
244
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
245 (defun idd-compare-specifications-1 (source-or-destination
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
246 specifications
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
247 value)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
248 "Internal function of `idd-compare-specifications'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
249 VALUE is the value of the last matches."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
250 (cond ((not specifications) value)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
251 (t (let ((match (idd-compare-a-specification source-or-destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
252 (car specifications))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
253 (cond ((not match) 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
254 (t (idd-compare-specifications-1 source-or-destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
255 (cdr specifications)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
256 (+ value match))))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
257
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
258 (defun idd-compare-specifications (source-or-destination
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
259 specifications)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
260 "Determines how good SOURCE-OR-DESTINATION and SPECIFICATIONS are matching.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
261 A return value of zero means, that they don't match. The higher the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
262 return value the better is the matching."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
263 (cond ((not specifications) 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
264 (t (idd-compare-specifications-1 source-or-destination
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
265 specifications
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
266 0))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
267
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
268 (defun idd-get-action-depending-on-source (source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
269 actions-depending-on-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
270 destination-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
271 value-action-pair)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
272 "Internal function of `idd-get-action-depending-on-source-and-destination'."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
273 (let ((source-value (idd-compare-specifications
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
274 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
275 (car (car actions-depending-on-source)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
276 (cond ((not actions-depending-on-source) value-action-pair)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
277 ((or (= source-value 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
278 (<= (+ destination-value source-value) (car value-action-pair)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
279 (idd-get-action-depending-on-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
280 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
281 (cdr actions-depending-on-source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
282 destination-value
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
283 value-action-pair))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
284 (t (idd-get-action-depending-on-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
285 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
286 (cdr actions-depending-on-source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
287 destination-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
288 (cons (+ destination-value source-value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
289 (second (car actions-depending-on-source))))))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
290
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
291 (defun idd-get-action-depending-on-source-and-destination (source
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
292 destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
293 actions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
294 value-action-pair)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
295 "Internal function of `idd-get-action'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
296 VALUE-ACTION-PAIR is a list like (<value> <action>).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
297 It returns VALUE-ACTION-PAIR, if no other action is found, which has a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
298 value higher than (car VALUE-ACTION-PAIR)."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
299 (let ((destination-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
300 (idd-compare-specifications destination (car (car actions)))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
301 (cond ((not actions) value-action-pair)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
302 ((= destination-value 0)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
303 (idd-get-action-depending-on-source-and-destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
304 source
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
305 destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
306 (cdr actions)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
307 value-action-pair))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
308 (t (idd-get-action-depending-on-source-and-destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
309 source
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
310 destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
311 (cdr actions)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
312 (idd-get-action-depending-on-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
313 source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
314 (cdr (car actions))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
315 destination-value
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
316 value-action-pair))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
317
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
318 (defun idd-get-action (source destination actions)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
319 "Returns the action, which depends on the SOURCE and the DESTINATION.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
320 The list ACTIONS contains all possible actions. Look at the variable
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
321 `idd-actions' for a description of the format of this list."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
322 (idd-get-action-depending-on-source-and-destination source
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
323 destination
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
324 actions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
325 '(0 . nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
326
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
327 ;(autoload 'ange-ftp-ftp-path "ange-ftp"
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
328 ; "Parse PATH according to ange-ftp-path-format (which see).
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
329 ;Returns a list (HOST USER PATH), or nil if PATH does not match the format.")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
330
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
331 (defun idd-get-buffer (source-or-destination)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
332 "Returns the buffer of the SOURCE-OR-DESTINATION."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
333 (cdr (assoc ':buffer source-or-destination)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
334
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
335 (defun idd-set-point (source-or-destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
336 "Sets the point and buffer to SOURCE-OR-DESTINATION."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
337 (set-buffer (idd-get-buffer source-or-destination))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
338 (goto-char (cdr (assoc ':drag-or-drop-point source-or-destination))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
339
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
340 (defun idd-set-region (source-or-destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
341 "Sets the point, mark and buffer to SOURCE-OR-DESTINATION.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
342 The region is active after this function is called."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
343 (set-buffer (idd-get-buffer source-or-destination))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
344 (goto-char (car (cdr (assoc ':region-active source-or-destination))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
345 (set-mark (cdr (cdr (assoc ':region-active source-or-destination))))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
346 (if (adapt-xemacsp)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
347 (activate-region))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
348 )
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
349
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
350
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
351 ;;; Specification type functions for the list `idd-actions'
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
352
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
353 (defun idd-if-region-active-p (source-or-destination value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
354 "Checks if the region in the SOURCE-OR-DESTINATION was active.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
355 It returns 1, if the region was active and VALUE is t, or if
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
356 the region was not active and VALUE is nil. Otherwise it returns
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
357 nil."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
358 (if (cdr (assoc ':region-active source-or-destination))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
359 (if value 1 nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
360 (if value nil 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
361
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
362 (defun idd-get-buffer-url (source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
363 "Returns the URL of the buffer specified by SOURCE-OR-DESTINATION."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
364 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
365 (idd-set-point source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
366 (url-view-url t)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
367
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
368 (defun idd-get-url-at-point (source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
369 "Returns the URL at the point specified by SOURCE-OR-DESTINATION.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
370 It returns nil, if there is no URL."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
371 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
372 (idd-set-point source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
373 (w3-view-this-url t)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
374
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
375 (defun idd-if-url-at-point-p (source-or-destination value)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
376 "Checks if there is an URL at the point of SOURCE-OR-DESTINATION.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
377 If that is t and VALUE is t, or that is nil and VALUE is nil, then 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
378 is returned. Otherwise nil is returned."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
379 (if value
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
380 (if (idd-get-url-at-point source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
381 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
382 nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
383 (if (idd-get-url-at-point source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
384 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
385 1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
386
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
387 (defun idd-if-major-mode-p (source-or-destination mode)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
388 "Checks, if the major mode of SOURCE-OR-DESTINATION is MODE.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
389 It returns 1, if that is t and nil otherwise."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
390 (save-excursion
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
391 (set-buffer (idd-get-buffer source-or-destination))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
392 (if (eq major-mode mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
393 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
394 nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
395
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
396 (defun idd-if-variable-non-nil-p (source-or-destination variable)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
397 "Checks, if the variable named VARIABLE isn't t in SOURCE-OR-DESTINATION.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
398 It returns 1, if this is t."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
399 (save-excursion
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
400 (set-buffer (idd-get-buffer source-or-destination))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
401 (if (eval variable)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
402 1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
403 nil)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
404
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
405 (defun idd-if-minor-mode-p (source-or-destination minor-mode-variable)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
406 "Checks, if the variable MINOR-MODE-VARIABLE is t in SOURCE-OR-DESTINATION.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
407 MINOR-MODE-VARIABLE is the name of the variable!."
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
408 (idd-if-variable-non-nil-p source-or-destination minor-mode-variable))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
409
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
410 (defun idd-get-dired-filename-from-line (source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
411 "Returns the filename form the line in a dired buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
412 The position and the buffer is specified by SOURCE-OR-DESTINATION."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
413 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
414 (idd-set-point source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
415 (dired-get-filename nil t)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
416
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
417 (defun idd-if-dired-file-on-line-p (source-or-destination filename-regexp)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
418 "Checks, if the filename on the line match FILENAME-REGEXP.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
419 The function `dired-get-filename' is used, to get the filename from
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
420 the SOURCE-OR-DESTINATION. It returns 1, if it matchs or nil."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
421 (let ((case-fold-search t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
422 (if (and (idd-get-dired-filename-from-line source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
423 (string-match filename-regexp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
424 (idd-get-dired-filename-from-line
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
425 source-or-destination)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
426 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
427 nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
428
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
429 (defun idd-if-dired-no-file-on-line-p (source-or-destination value)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
430 "Checks, if a filename is in the dired buffer of SOURCE-OR-DESTINATION.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
431 It returns 1, if a filename is on the line and if VALUE is t, or if
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
432 no filename is on the line and VALUE is nil, otherwise it returns
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
433 nil. For the test the function `dired-get-filename' is used."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
434 (if (idd-get-dired-filename-from-line source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
435 (if value nil 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
436 (if value 1 nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
437
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
438 (defun idd-get-local-filename (source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
439 "Returns the filename of a local file specified by SOURCE-OR-DESTINATION."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
440 (buffer-file-name (idd-get-buffer source-or-destination)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
441
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
442 (defun idd-get-directory-of-buffer (source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
443 "Returns the directory name assigned to the SOURCE-OR-DESTINATION buffer."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
444 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
445 (idd-set-point source-or-destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
446 default-directory))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
447
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
448 (defun idd-if-local-file-p (source-or-destination value)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
449 "Checks, if SOURCE-OR-DESTINATION has a file on the local filesystem.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
450 If that is t and VALUE is t, or that is nil and VALUE is nil, then 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
451 is returned. Otherwise nil is returned."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
452 (let ((filename (idd-get-local-filename source-or-destination)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
453 (if (and filename
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
454 ; (not (ange-ftp-ftp-path filename)))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
455 (not (file-remote-p filename)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
456 (if value 1 nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
457 (if value nil 1))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
458
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
459 (defun idd-if-buffer-name-p (source-or-destination buffer-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
460 "Checks, if SOURCE-OR-DESTINATION has a buffer called BUFFER-NAME.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
461 It returns 1 if this is the case or nil otherwise."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
462 (if (string= buffer-name
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
463 (buffer-name (idd-get-buffer source-or-destination)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
464 1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
465 nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
466
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
467 (defun idd-list-1-subset-of-list-2 (list-1 list-2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
468 "Returns t, if LIST-1 is a subset of LIST-2."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
469 (cond ((not list-1))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
470 ((member (car list-1) list-2)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
471 (idd-list-1-subset-of-list-2 (cdr list-1) list-2))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
472 (t nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
473
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
474 (defun idd-same-elements-p (list-1 list-2)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
475 "Returns t, if both list have the same modifiers."
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
476 (and (= (length list-1) (length list-2))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
477 (idd-list-1-subset-of-list-2 list-1 list-2)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
478
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
479 (defun idd-if-modifiers-p (source-or-destination modifiers)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
480 "Checks, if the MODIFIERS hold during selecting the SOURCE-OR-DESTINATION.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
481 Returns 1, if the list MODIFIERS contains the same modifiers,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
482 or if any modyfiers are hold and MODIFIERS is t,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
483 or if no modyfiers are hold and MODIFIERS is nil.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
484 Otherwise nil is returned."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
485 (let ((event-modifiers (event-modifiers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
486 (cdr (assoc ':event source-or-destination)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
487 (cond ((not modifiers)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
488 (if event-modifiers nil 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
489 ((listp modifiers)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
490 (if (idd-same-elements-p modifiers event-modifiers)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
491 1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
492 nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
493 (t (if event-modifiers 1 nil)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
494
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
495 ;;; action functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
496
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
497 (defun idd-action-copy-region (source destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
498 "Copy the region from DESTINATION to SOURCE."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
499 (idd-set-region source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
500 (let ((region-contents (buffer-substring (point) (mark))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
501 (idd-set-point destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
502 (insert region-contents)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
503
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
504 (defun idd-action-copy-replace-region (source destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
505 "Copy the region from SOURCE and replace the DESTINATION region with it."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
506 (idd-set-region source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
507 (let ((region-contents (buffer-substring (point) (mark))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
508 (idd-set-region destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
509 (delete-region (point) (mark))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
510 (insert region-contents)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
511
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
512 (defmacro* idd-with-source-and-destination (source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
513 destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
514 &key
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
515 do-in-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
516 do-in-destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
517 "Macro, usefull for the definition of action functions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
518 Look at the example `idd-action-move-region'."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
519 `(progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
520 (if (idd-if-region-active-p ,source t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
521 (idd-set-region ,source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
522 (idd-set-point ,source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
523 ,(when do-in-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
524 (cons 'progn do-in-source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
525 (if (idd-if-region-active-p ,destination t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
526 (idd-set-region ,destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
527 (idd-set-point ,destination))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
528 ,(when do-in-destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
529 (cons 'progn do-in-destination))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
530
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
531 (defun idd-action-move-region (source destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
532 "Move the region from SOURCE to DESTINATION."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
533 (let ((region))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
534 (idd-with-source-and-destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
535 source destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
536 :do-in-source ((setq region (buffer-substring (point) (mark)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
537 (delete-region (point) (mark)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
538 :do-in-destination ((insert region)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
539
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
540
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
541 (defun idd-action-move-replace-region (source destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
542 "Delete the region at SOURCE and overwrite the DESTINATION region with it."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
543 (let ((region))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
544 (idd-with-source-and-destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
545 source destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
546 :do-in-source ((setq region (buffer-substring (point) (mark)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
547 (delete-region (point) (mark)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
548 :do-in-destination ((delete-region (point) (mark))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
549 (insert region)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
550
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
551
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
552 ;;; Performing the drag and drop
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
553
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
554 (defun idd-display-help-about-action (action source destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
555 "Display a help buffer with information about the action."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
556 (if (> (car action) 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
557 (if (symbol-function (cdr action))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
558 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
559 (with-displaying-help-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
560 '(lambda ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
561 (set-buffer "*Help*")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
562 (setq idd-help-source source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
563 (setq idd-help-destination destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
564 (insert "Drag and drop action: `")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
565 (let ((start (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
566 (insert (format "%s" (cdr action)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
567 (setq idd-help-start-extent (make-extent start (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
568 (set-extent-mouse-face idd-help-start-extent 'highlight)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
569 (set-extent-face idd-help-start-extent 'bold)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
570 (if (adapt-xemacsp)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
571 (set-extent-keymap idd-help-start-extent
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
572 idd-help-start-action-keymap)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
573 )
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
574 )
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
575 (insert "'\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
576 (insert (format "Source buffer : `%s'\n"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
577 (buffer-name (cdr (assoc ':buffer source)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
578 (insert (format "Destination buffer : `%s'\n"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
579 (buffer-name (cdr (assoc ':buffer destination))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
580 )))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
581 (insert "=================================================="
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
582 "====================\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
583 (insert "Look at `idd-actions' in the "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
584 "destination buffer for other actions!\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
585 (insert (format "The documentation of `%s':\n\n"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
586 (cdr action)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
587 (insert (documentation (cdr action)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
588 )
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
589 (error "Error: Action %s isn't a valid function!" (cdr action)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
590 (message "No valid action defined for this source and this destination!")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
591
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
592 (defun idd-call-action (action source destination)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
593 "Calls the drag and drop ACTION with its arguments SOURCE and DESTINATION."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
594 (if (> (car action) 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
595 (if (symbol-function (cdr action))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
596 (eval (list (cdr action) 'source 'destination))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
597 (error "Error: Action %s isn't a valid function!" (cdr action)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
598 (message "No valid action defined for this source and this destination!")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
599
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
600 (defun idd-start-help-mouse-drag-and-drop ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
601 "Starts help on `idd-start-mouse-drag-and-drop'."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
602 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
603 (let ((idd-help-instead-of-action t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
604 (idd-start-mouse-drag-and-drop)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
605
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
606 (defun idd-start-mouse-drag-and-drop ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
607 "Starts a drag and drop command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
608 This command could be used to start a drag and drop command without a
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
609 button event. Therefore this should not be bind direct to a mouse button."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
610 (interactive)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
611 (let ((source-event)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
612 (drag-and-drop-message "Drag&Drop: Click on the source!"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
613 (message drag-and-drop-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
614 (setq source-event
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
615 (next-command-event nil drag-and-drop-message))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
616 (if (button-press-event-p source-event)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
617 (progn
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
618 (when (and (adapt-emacs19p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
619 (mouse-event-p source-event)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
620 (eq idd-drag-and-drop-mouse-binding-type 'click))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
621 (while (not (button-release-event-p (next-command-event)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
622 (idd-mouse-drag-and-drop source-event))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
623 (message "Wrong event! Exit drag and drop."))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
624
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
625 (defun idd-help-mouse-drag-and-drop (source-event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
626 "Displays help about the drag and drop action."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
627 (interactive "@e")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
628 (let ((idd-help-instead-of-action t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
629 (idd-mouse-drag-and-drop source-event)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
630
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
631 (defun idd-mouse-drag-and-drop (source-event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
632 "Performs a drag and drop action.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
633 It calls the command `idd-mouse-drag-and-drop-click' or
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
634 `idd-mouse-drag-and-drop-press-button-during-move' depending on
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
635 the value of `idd-drag-and-drop-mouse-binding-type'."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
636 (interactive "@e")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
637 (if (eq idd-drag-and-drop-mouse-binding-type 'click)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
638 (idd-mouse-drag-and-drop-click source-event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
639 (idd-mouse-drag-and-drop-press-button-during-move source-event)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
640
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
641 (defun idd-get-source-or-destination-alist (event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
642 "Returns an alist with the description of a source or destination point.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
643 The EVENT must be the button event, which has selected the source or
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
644 destination of the drag and drop command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
645
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
646 The alist has the following structure:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
647 '((:buffer . <buffer-of-the-event>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
648 (:drag-or-drop-point . <closest-point-to-the-event>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
649 (:region-active . <t-or-nil>)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
650 (:event . EVENT))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
651
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
652 Note: <closest-point-to-the-event> is (event-closest-point EVENT),
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
653 if the EVENT is a mouse event and if it isn't nil. Otherwise the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
654 point is used."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
655 ; (set-buffer (event-buffer event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
656 (list (cons ':buffer (event-buffer event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
657 (cons ':drag-or-drop-point (set-marker
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
658 (make-marker)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
659 (if (mouse-event-p event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
660 (or (event-closest-point event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
661 (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
662 (point))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
663 (cons ':region-active (if (region-active-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
664 (cons (set-marker (make-marker) (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
665 (set-marker (make-marker) (mark)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
666 (cons ':event event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
667 )
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
668
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
669 (defun idd-mouse-drag-and-drop-press-button-during-move (source-event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
670 "Performs a drag and drop action.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
671 At first you must press the button down over the source and then
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
672 move with the pressed button to the destination, where you must leave
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
673 the button up.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
674 This must be bind to a mouse button. The SOURCE-EVENT must be a
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
675 button-press-event.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
676
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
677 The disadvantage of this command compared with the command
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
678 `idd-mouse-drag-and-drop-click' is, that you can't select a
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
679 destination region."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
680 (interactive "@e")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
681 (let ((drag-and-drop-message
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
682 "Drag&Drop: Leave the button over the destination!")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
683 (source (idd-get-source-or-destination-alist source-event))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
684 (destination nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
685 (destination-event))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
686 (message drag-and-drop-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
687 (setq destination-event
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
688 (next-command-event nil drag-and-drop-message))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
689 (message "")
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
690 (cond ((or (button-release-event-p destination-event)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
691 (and (adapt-emacs19p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
692 (button-drag-event-p destination-event)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
693 (setq destination (idd-get-source-or-destination-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
694 destination-event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
695 (idd-set-point destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
696 (if idd-help-instead-of-action
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
697 (idd-display-help-about-action (idd-get-action source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
698 destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
699 idd-actions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
700 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
701 destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
702 (idd-call-action (idd-get-action source destination idd-actions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
703 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
704 destination)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
705 (t (message "Wrong event! Exit drag and drop.") nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
706
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
707 (defun idd-mouse-drag-and-drop-click (source-event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
708 "Performs a drag and drop action.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
709 At first you must click on the source and after that on the destination.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
710 This must be bind to a mouse button. The SOURCE-EVENT must be a
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
711 button-press-event."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
712 (interactive "@e")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
713 (let ((drag-and-drop-message "Drag&Drop: Click on the destination!")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
714 (source (idd-get-source-or-destination-alist source-event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
715 (destination nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
716 (destination-event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
717 (message drag-and-drop-message)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
718 (when (and (adapt-xemacsp) (mouse-event-p source-event))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
719 (dispatch-event (next-command-event)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
720 (setq destination-event
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
721 (next-command-event nil drag-and-drop-message))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
722 (message "")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
723 (cond ((button-press-event-p destination-event)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
724 (mouse-track destination-event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
725 (setq destination (idd-get-source-or-destination-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
726 destination-event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
727 (idd-set-point destination)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
728 ; (when (adapt-emacs19p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
729 ; (while (not (button-release-event-p (next-command-event)))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
730 (if idd-help-instead-of-action
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
731 (idd-display-help-about-action (idd-get-action source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
732 destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
733 idd-actions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
734 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
735 destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
736 (idd-call-action (idd-get-action source destination idd-actions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
737 source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
738 destination)))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
739 ((and (adapt-emacs19p)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
740 (button-click-event-p destination-event))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
741 (setq destination (idd-get-source-or-destination-alist
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
742 destination-event))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
743 (idd-set-point destination)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
744 (if idd-help-instead-of-action
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
745 (idd-display-help-about-action (idd-get-action source
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
746 destination
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
747 idd-actions)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
748 source
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
749 destination)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
750 (idd-call-action (idd-get-action source destination idd-actions)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
751 source
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
752 destination)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
753 (t (message "Wrong event! Exit drag and drop.") nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
754
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
755 ;; Useful for debugging
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
756 ;; (setq idd-last-source source)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
757 ;; (setq idd-last-destination destination)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
758
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 116
diff changeset
759 ))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
760
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
761 (defun idd-help-start-action (event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
762 "Used to start the action from the help buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
763 (interactive "@e")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
764 (idd-set-point idd-help-destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
765 (idd-call-action (idd-get-action idd-help-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
766 idd-help-destination
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
767 idd-actions)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
768 idd-help-source
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
769 idd-help-destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
770 (delete-extent idd-help-start-extent))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
771
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
772 ;; keymap for help buffer extents
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
773 (if (not idd-help-start-action-keymap)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
774 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
775 (setq idd-help-start-action-keymap
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
776 (make-sparse-keymap 'idd-help-start-action-keymap))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
777 (if (adapt-emacs19p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
778 (define-key idd-help-start-action-keymap [(mouse-2)]
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
779 'idd-help-start-action)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
780 (define-key idd-help-start-action-keymap "[(button2)]"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
781 'idd-help-start-action))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
782
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
783 ;; global key bindings
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
784 (when idd-global-mouse-keys
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
785 (unless (where-is-internal 'idd-mouse-drag-and-drop global-map t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
786 (define-key global-map idd-global-mouse-keys 'idd-mouse-drag-and-drop))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
787 (unless (where-is-internal 'idd-help-mouse-drag-and-drop global-map t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
788 (define-key global-map
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
789 idd-global-help-mouse-keys 'idd-help-mouse-drag-and-drop)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
790
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
791
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
792 (provide 'internal-drag-and-drop)