Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/lisp/hm--html-menus/hm--html-drag-and-drop.el Mon Aug 13 09:12:43 2007 +0200 +++ b/lisp/hm--html-menus/hm--html-drag-and-drop.el Mon Aug 13 09:13:56 2007 +0200 @@ -1,6 +1,6 @@ -;;; $Id: hm--html-drag-and-drop.el,v 1.1.1.1 1996/12/18 22:43:20 steve Exp $ +;;; $Id: hm--html-drag-and-drop.el,v 1.2 1997/02/15 22:21:03 steve Exp $ ;;; -;;; Copyright (C) 1996 Heiko Muenkel +;;; Copyright (C) 1996, 1997 Heiko Muenkel ;;; email: muenkel@tnt.uni-hannover.de ;;; ;;; This program is free software; you can redistribute it and/or modify @@ -35,133 +35,133 @@ (require 'internal-drag-and-drop) (require 'cl) -(defun hm--html-first-non-matching-position (string1 string2) - "Compares both strings and returns the first position, which is not equal." - (let ((n 0) - (max-n (min (length string1) (length string2))) - (continue t)) - (while (and continue (< n max-n)) - (when (setq continue (= (aref string1 n) (aref string2 n))) - (setq n (1+ n)))) - n)) +;(defun hm--html-first-non-matching-position (string1 string2) +; "Compares both strings and returns the first position, which is not equal." +; (let ((n 0) +; (max-n (min (length string1) (length string2))) +; (continue t)) +; (while (and continue (< n max-n)) +; (when (setq continue (= (aref string1 n) (aref string2 n))) +; (setq n (1+ n)))) +; n)) -(defun hm--html-count-subdirs (directory) - "Returns the number of subdirectories of DIRECTORY." - (let ((n 0) - (max-n (1- (length directory))) - (count 0)) - (while (< n max-n) - (when (= ?/ (aref directory n)) - (setq count (1+ count))) - (setq n (1+ n))) - (when (and (not (= 0 (length directory))) - (not (= ?/ (aref directory 0)))) - (setq count (1+ count))) - count)) +;(defun hm--html-count-subdirs (directory) +; "Returns the number of subdirectories of DIRECTORY." +; (let ((n 0) +; (max-n (1- (length directory))) +; (count 0)) +; (while (< n max-n) +; (when (= ?/ (aref directory n)) +; (setq count (1+ count))) +; (setq n (1+ n))) +; (when (and (not (= 0 (length directory))) +; (not (= ?/ (aref directory 0)))) +; (setq count (1+ count))) +; count)) -(defun hm--html-return-n-backwards (n) - "Returns a string with N ../" - (cond ((= n 0) "") - (t (concat "../" (hm--html-return-n-backwards (1- n)))))) +;(defun hm--html-return-n-backwards (n) +; "Returns a string with N ../" +; (cond ((= n 0) "") +; (t (concat "../" (hm--html-return-n-backwards (1- n)))))) -(defun* hm--html-file-relative-name (file-name - &optional (directory default-directory)) - "Convert FILENAME to be relative to DIRECTORY (default: default-directory)." - (let* ((pos (hm--html-first-non-matching-position file-name directory)) - (backwards (hm--html-count-subdirs (substring directory pos))) - (relative-name (concat (hm--html-return-n-backwards backwards) - (substring file-name pos)))) - (if (= 0 (length relative-name)) - "./" - (if (= ?/ (aref relative-name 0)) - (if (= 1 (length relative-name)) - "./" - (substring relative-name 1)) - relative-name)))) +;(defun* hm--html-file-relative-name (file-name +; &optional (directory default-directory)) +; "Convert FILENAME to be relative to DIRECTORY (default: default-directory)." +; (let* ((pos (hm--html-first-non-matching-position file-name directory)) +; (backwards (hm--html-count-subdirs (substring directory pos))) +; (relative-name (concat (hm--html-return-n-backwards backwards) +; (substring file-name pos)))) +; (if (= 0 (length relative-name)) +; "./" +; (if (= ?/ (aref relative-name 0)) +; (if (= 1 (length relative-name)) +; "./" +; (substring relative-name 1)) +; relative-name)))) (defun hm--html-idd-add-include-image-from-dired-line (source destination) - "Inserts an include image tag at the SOURCE. + "Inserts an include image tag at the DESTINATION. The name of the image is on a line in a dired buffer. It is specified by the -destination." - (idd-set-point source) +SOURCE." + (idd-set-point destination) (if hm--html-idd-create-relative-links - (hm--html-add-image-top (hm--html-file-relative-name - (idd-get-dired-filename-from-line destination)) + (hm--html-add-image-top (file-relative-name + (idd-get-dired-filename-from-line source)) (file-name-nondirectory - (idd-get-dired-filename-from-line destination))) - (hm--html-add-image-top (idd-get-dired-filename-from-line destination) + (idd-get-dired-filename-from-line source))) + (hm--html-add-image-top (idd-get-dired-filename-from-line source) (file-name-nondirectory - (idd-get-dired-filename-from-line destination))))) + (idd-get-dired-filename-from-line source))))) -(defun hm--html-idd-add-link-to-region (link-object source) - "Inserts a link with the LINK-OBJECT in the SOURCE. +(defun hm--html-idd-add-link-to-region (link-object destination) + "Inserts a link with the LINK-OBJECT in the DESTINATION. It uses the region as the name of the link." - (idd-set-region source) + (idd-set-region destination) (hm--html-add-normal-link-to-region link-object) ) -(defun hm--html-idd-add-link (link-object source) - "Inserts a link with the LINK-OBJECT in the SOURCE." - (idd-set-point source) +(defun hm--html-idd-add-link (link-object destination) + "Inserts a link with the LINK-OBJECT in the DESTINATION." + (idd-set-point destination) (hm--html-add-normal-link link-object)) -(defun hm--html-idd-add-link-to-point-or-region (link-object source) - "Inserts a link with the LINK-OBJECT in the SOURCE. +(defun hm--html-idd-add-link-to-point-or-region (link-object destination) + "Inserts a link with the LINK-OBJECT in the DESTINATION. It uses the region as the name of the link, if the region was active -in the SOURCE." - (if (cdr (assoc ':region-active source)) - (hm--html-idd-add-link-to-region link-object source) - (hm--html-idd-add-link link-object source))) +in the DESTINATION." + (if (cdr (assoc ':region-active destination)) + (hm--html-idd-add-link-to-region link-object destination) + (hm--html-idd-add-link link-object destination))) (defun hm--html-idd-add-file-link-to-file-on-dired-line (source destination) - "Inserts a file link in SOURCE to the file on the dired line of DESTINATION." - (idd-set-point source) + "Inserts a file link in DESTINATION to the file on the dired line of SOURCE." + (idd-set-point destination) (if hm--html-idd-create-relative-links (hm--html-idd-add-link-to-point-or-region - (hm--html-file-relative-name - (idd-get-dired-filename-from-line destination)) - source) + (file-relative-name + (idd-get-dired-filename-from-line source)) + destination) (hm--html-idd-add-link-to-point-or-region - (concat "file://" (idd-get-dired-filename-from-line destination)) - source))) + (concat "file://" (idd-get-dired-filename-from-line source)) + destination))) (defun hm--html-idd-add-file-link-to-buffer (source destination) - "Inserts a file link at SOURCE to the file of DESTINATION." - (idd-set-point source) + "Inserts a file link at DESTINATION to the file of the SOURCE buffer." + (idd-set-point destination) (if hm--html-idd-create-relative-links (hm--html-idd-add-link-to-point-or-region - (hm--html-file-relative-name (idd-get-local-filename destination)) - source) + (file-relative-name (idd-get-local-filename source)) + destination) (hm--html-idd-add-link-to-point-or-region - (concat "file://" (idd-get-local-filename destination)) - source))) + (concat "file://" (idd-get-local-filename source)) + destination))) (defun hm--html-idd-add-file-link-to-directory-of-buffer (source destination) - "Inserts a file link at SOURCE to the directory of the DESTINATION buffer." - (idd-set-point source) + "Inserts a file link at DESTINATION to the directory of the SOURCE buffer." + (idd-set-point destination) (if hm--html-idd-create-relative-links (hm--html-idd-add-link-to-point-or-region - (hm--html-file-relative-name (idd-get-directory-of-buffer destination)) - source) + (file-relative-name (idd-get-directory-of-buffer source)) + destination) (hm--html-idd-add-link-to-point-or-region - (concat "file://" (idd-get-directory-of-buffer destination)) - source))) + (concat "file://" (idd-get-directory-of-buffer source)) + destination))) (defun hm--html-idd-add-html-link-to-w3-buffer (source destination) - "Inserts a link at SOURCE to the w3 buffer specified by the DESTINATION. + "Inserts a link at DESTINATION to the w3 buffer specified by the SOURCE. Note: Relative links are currently not supported for this function." - (idd-set-point source) - (hm--html-idd-add-link-to-point-or-region (idd-get-buffer-url destination) - source)) + (idd-set-point destination) + (hm--html-idd-add-link-to-point-or-region (idd-get-buffer-url source) + destination)) (defun hm--html-idd-add-html-link-from-w3-buffer-point (source destination) - "Inserts a link at SOURCE to a lin in the w3 buffer. -The link in the w3-buffer is specified by the DESTINATION. + "Inserts a link at DESTINATION to a lin in the w3 buffer. +The link in the w3-buffer is specified by the SOURCE. Note: Relative links are currently not supported for this function." - (idd-set-point source) - (hm--html-idd-add-link-to-point-or-region (idd-get-url-at-point destination) - source)) + (idd-set-point destination) + (hm--html-idd-add-link-to-point-or-region (idd-get-url-at-point source) + destination)) ;;; Announce the feature hm--html-drag-and-drop (provide 'hm--html-drag-and-drop)