annotate lisp/hm--html-menus/hm--html-drag-and-drop.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 131b0175ea99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1 ;;; $Id: hm--html-drag-and-drop.el,v 1.2 1997/02/15 22:21:03 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 contains functions to insert links and other
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 ;;; HTML stuff with the mouse with drag and drop.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26 ;;; For further descriptions look at the file
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
27 ;;; internal-drag-and-drop.el, which implements the basic (and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28 ;;; more genreal functions) for the drag and drop interface.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30 ;;; Installation:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
31 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
32 ;;; Put this file in your load path.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
33 ;;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
34
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
35 (require 'internal-drag-and-drop)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36 (require 'cl)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
37
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
38 ;(defun hm--html-first-non-matching-position (string1 string2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
39 ; "Compares both strings and returns the first position, which is not equal."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
40 ; (let ((n 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
41 ; (max-n (min (length string1) (length string2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
42 ; (continue t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
43 ; (while (and continue (< n max-n))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
44 ; (when (setq continue (= (aref string1 n) (aref string2 n)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
45 ; (setq n (1+ n))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
46 ; n))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
48 ;(defun hm--html-count-subdirs (directory)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
49 ; "Returns the number of subdirectories of DIRECTORY."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
50 ; (let ((n 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
51 ; (max-n (1- (length directory)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
52 ; (count 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
53 ; (while (< n max-n)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
54 ; (when (= ?/ (aref directory n))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
55 ; (setq count (1+ count)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
56 ; (setq n (1+ n)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
57 ; (when (and (not (= 0 (length directory)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
58 ; (not (= ?/ (aref directory 0))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
59 ; (setq count (1+ count)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
60 ; count))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
62 ;(defun hm--html-return-n-backwards (n)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
63 ; "Returns a string with N ../"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
64 ; (cond ((= n 0) "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
65 ; (t (concat "../" (hm--html-return-n-backwards (1- n))))))
2
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 ;(defun* hm--html-file-relative-name (file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
68 ; &optional (directory default-directory))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
69 ; "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
70 ; (let* ((pos (hm--html-first-non-matching-position file-name directory))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
71 ; (backwards (hm--html-count-subdirs (substring directory pos)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
72 ; (relative-name (concat (hm--html-return-n-backwards backwards)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
73 ; (substring file-name pos))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
74 ; (if (= 0 (length relative-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
75 ; "./"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
76 ; (if (= ?/ (aref relative-name 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
77 ; (if (= 1 (length relative-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
78 ; "./"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
79 ; (substring relative-name 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
80 ; relative-name))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
81
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
82 (defun hm--html-idd-add-include-image-from-dired-line (source destination)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
83 "Inserts an include image tag at the DESTINATION.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
84 The name of the image is on a line in a dired buffer. It is specified by the
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
85 SOURCE."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
86 (idd-set-point destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
87 (if hm--html-idd-create-relative-links
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
88 (hm--html-add-image-top (file-relative-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
89 (idd-get-dired-filename-from-line source))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
90 (file-name-nondirectory
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
91 (idd-get-dired-filename-from-line source)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
92 (hm--html-add-image-top (idd-get-dired-filename-from-line source)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
93 (file-name-nondirectory
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
94 (idd-get-dired-filename-from-line source)))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
95
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
96 (defun hm--html-idd-add-link-to-region (link-object destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
97 "Inserts a link with the LINK-OBJECT in the DESTINATION.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
98 It uses the region as the name of the link."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
99 (idd-set-region destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
100 (hm--html-add-normal-link-to-region link-object)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
101 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
102
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
103 (defun hm--html-idd-add-link (link-object destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
104 "Inserts a link with the LINK-OBJECT in the DESTINATION."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
105 (idd-set-point destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
106 (hm--html-add-normal-link link-object))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
107
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
108 (defun hm--html-idd-add-link-to-point-or-region (link-object destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
109 "Inserts a link with the LINK-OBJECT in the DESTINATION.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
110 It uses the region as the name of the link, if the region was active
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
111 in the DESTINATION."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
112 (if (cdr (assoc ':region-active destination))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
113 (hm--html-idd-add-link-to-region link-object destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
114 (hm--html-idd-add-link link-object destination)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
115
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
116 (defun hm--html-idd-add-file-link-to-file-on-dired-line (source destination)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
117 "Inserts a file link in DESTINATION to the file on the dired line of SOURCE."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
118 (idd-set-point destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
119 (if hm--html-idd-create-relative-links
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
120 (hm--html-idd-add-link-to-point-or-region
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
121 (file-relative-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
122 (idd-get-dired-filename-from-line source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
123 destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
124 (hm--html-idd-add-link-to-point-or-region
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
125 (concat "file://" (idd-get-dired-filename-from-line source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
126 destination)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
127
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
128 (defun hm--html-idd-add-file-link-to-buffer (source destination)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
129 "Inserts a file link at DESTINATION to the file of the SOURCE buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
130 (idd-set-point destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
131 (if hm--html-idd-create-relative-links
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
132 (hm--html-idd-add-link-to-point-or-region
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
133 (file-relative-name (idd-get-local-filename source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
134 destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
135 (hm--html-idd-add-link-to-point-or-region
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
136 (concat "file://" (idd-get-local-filename source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
137 destination)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
138
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
139 (defun hm--html-idd-add-file-link-to-directory-of-buffer (source
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
140 destination)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
141 "Inserts a file link at DESTINATION to the directory of the SOURCE buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
142 (idd-set-point destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
143 (if hm--html-idd-create-relative-links
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
144 (hm--html-idd-add-link-to-point-or-region
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
145 (file-relative-name (idd-get-directory-of-buffer source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
146 destination)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
147 (hm--html-idd-add-link-to-point-or-region
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
148 (concat "file://" (idd-get-directory-of-buffer source))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
149 destination)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
150
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
151 (defun hm--html-idd-add-html-link-to-w3-buffer (source destination)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
152 "Inserts a link at DESTINATION to the w3 buffer specified by the SOURCE.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
153 Note: Relative links are currently not supported for this function."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
154 (idd-set-point destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
155 (hm--html-idd-add-link-to-point-or-region (idd-get-buffer-url source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
156 destination))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
157
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
158 (defun hm--html-idd-add-html-link-from-w3-buffer-point (source destination)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
159 "Inserts a link at DESTINATION to a lin in the w3 buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 The link in the w3-buffer is specified by the SOURCE.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
161 Note: Relative links are currently not supported for this function."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
162 (idd-set-point destination)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
163 (hm--html-idd-add-link-to-point-or-region (idd-get-url-at-point source)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
164 destination))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
165
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
166 ;;; Announce the feature hm--html-drag-and-drop
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
167 (provide 'hm--html-drag-and-drop)