[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8. Internal Drag And Drop

The file `internal-drag-and-drop.el', which is shipped with `hm--html-menus', provides a general package for internal drag and drop in emacs. "General" means that it can be used apart from hm--html-mode in any other mode.

You can start such an action by clicking with the mouse in the source buffer and then in the destination buffer. The action may depend on the points where you've clicked with the mouse, on the state of the region, the point, the mark and any other properties of the source and the destination buffers. The actions are defined by the variable idd-actions, which is a buffer local variable.

8.1 Drag And Drop Customization  
8.2 The Drag And Drop Commands  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 Drag And Drop Customization

Since the XEmacs 19.15 and 20.2 a special package can be used for the customization of lisp packages. The internal drag and drop package uses now also this feature. Therefore you can set all user variables with the help of the Customize submenu, which can be selected in the Option menu. If you use it, the variables will currently be saved in a special customization file. Please look at the `NEWS' file or the info manuals of the XEmacs to find out more about the customization package.

The internal drag and drop functions may be used in all modes. Therefore their general customization isn't done in `hm--html-configuration.el'. Its variables are defined in the file `internal-drag-and-drop.el' instead. You can set them in your `.emacs' or in one of the other emacs init files (e.g. `default.el'). The following subsections describe the main customization variables.

8.1.1 Defining The Drag And Drop Actions  
8.1.2 The Mouse Bindings  
8.1.3 The Drag And Drop Mouse Pointer  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1.1 Defining The Drag And Drop Actions

The drag and drop actions are commands which are called after an internal drag and drop. They depend on the source and the destination of the drag and drop. Drag and drop actions are defined by the variable:

The list looks like:

 
'((<destination-specification-1> (<source-specification-1> <action-1-1>)
                            (<source-specification-2> <action-1-2>)
                                            :
   )
  (<destination-specification-2> (<source-specification-1> <action-2-1>)
                            (<source-specification-2> <action-2-2>)
                                            :
   )
                          :
  )
The <source-specification> looks like the following:
 
'([(<specification-type> <value>)])
with
 
<specification-type> :==
idd-if-minor-mode-p | idd-if-buffer-name-p | idd-if-region-active-p | idd-if-url-at-point-p | idd-if-major-mode-p | idd-if-variable-non-nil-p | idd-if-dired-file-on-line-p | idd-if-dired-no-file-on-line-p | idd-if-local-file-p | idd-if-buffer-name-p | idd-if-modifiers-p | ...

The <specification-type> - functions must have two arguments. The first one is the source or destination and the second is the <value>. It must return nil, if the test wasn't successful, and a number (in general 1), which specifies the weight of the test function. The weights of all single tests are added to a summary weight and assigned to the action. The action with the highest weight is called from the action handler. Look at the definition of idd-if-major-mode-p, idd-if-minor-mode-p and so on for examples. Look at the function idd-get-source-or-destination-alist, if you want to know the structure of the source-or-destination argument of these functions.

The <destination-specification> looks like <source-specification>, but in general it could be set to nil in mode specific idd-action lists.

If <destination-specification-1> or <source-specification-1> is set to nil, then every source or source matches. idd-actions is a buffer local variable, which should be at least mode depended. So if the <destination-specification-1> is set to nil it says, that the destination buffer must only have a specific mode. However, it's also possible to define a general idd-actions list, where the destination mode is specified by idd-if-major-mode-p.

<action> is a function which has two arguments. The first specifies the source and the second the destination. Look at the function definition of idd-action-copy-region and idd-action-copy-replace-region. They are examples for such actions.

The following is an example for hm--html-mode:

 
(defvar idd-actions
  '((nil (((idd-if-major-mode-p . dired-mode)
           (idd-if-dired-file-on-line-p . ".*\\.\\(gif\\)\\|\\(jpq\\)"))
          hm--html-idd-add-include-image-from-dired-line)
         (((idd-if-major-mode-p . dired-mode)
           (idd-if-dired-no-file-on-line-p . nil))
          hm--html-idd-add-file-link-to-file-on-dired-line)
         (((idd-if-major-mode-p . dired-mode)
           (idd-if-dired-no-file-on-line-p . t))
          hm--html-idd-add-file-link-to-directory-of-buffer)
         (((idd-if-major-mode-p . w3-mode)
           (idd-if-url-at-point-p . t))
          hm--html-idd-add-html-link-from-w3-buffer-point)
         (((idd-if-major-mode-p . w3-mode))
          hm--html-idd-add-html-link-to-w3-buffer)
         (((idd-if-local-file-p . t))
          hm--html-idd-add-file-link-to-buffer)))


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1.2 The Mouse Bindings

The following three variables determine the mouse bindings and the mouse behaviour for the internal drag and drop package:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1.3 The Drag And Drop Mouse Pointer

In the XEmacs the mouse pointer glyph (shape) can be set to any glyph. This is used during the drag and drop command to indicate, that the command is active. There exists the following three variables to customize this:

If one of the variables idd-mouse-pointer-image or idd-data-directory is changed, the command idd-make-drag-and-drop-pointer-glyph must be called. This command builds the mouse pointer glyph, which is stored in idd-drag-and-drop-pointer-glyph.

I don't know how to set the mouse pointer in the Emacs to a drag and drop image. Any hints for doing this are welcome.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2 The Drag And Drop Commands

There are 2 groups of commands. The first contains commands which perform the drag and drop action and the second displays help messages about a possible drag and drop action.

8.2.1 Performing The Drag And Drop Action  
8.2.2 Displaying Help On Drag And Drop  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2.1 Performing The Drag And Drop Action

The following five commands perform internal drag and drop actions:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2.2 Displaying Help On Drag And Drop

It's possible to display a buffer with a help message describing the action being considered before actually performing it. To perform the action, you then click on a special extent in the help buffer. To get the help buffer, you do the same things as you do to perform the action itself. Only the mouse key differs. There are two commands for this:


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html