The package x-buffer-local-mouse allows one to easily make buffer-specific
mouse bindings.
This package declares some buffer local variables to hold function symbols.
There is one variable for each mouse/key combination.

No keys:                   x-left        x-middle        x-right
Shift:                   x-s-left      x-s-middle      x-s-right
Control:                 x-c-left      x-c-middle      x-c-right
Control-Shift:         x-c-s-left    x-c-s-middle    x-c-s-right
Meta:                    x-m-left      x-m-middle      x-m-right
Meta-Shift:            x-m-s-left    x-m-s-middle    x-m-s-right
Control-Meta:          x-c-m-left    x-c-m-middle    x-c-m-right
Control-Meta-Shift:  x-c-m-s-left  x-c-m-s-middle  x-c-m-s-right

Buffer local variables have a default value, that is used when a buffer
doesn't have a buffer-local value for that variable.  Each buffer may have a
local value for each variable listed above.  The default value is set with
setq-default as follows:
  (setq-default x-c-middle 'x-find-file)
The local value is set with setq for the current buffer as in:
  (setq x-c-middle 'x-find-tag)

This is useful in mode hook functions as in:
  (defun default-simple-sml-mode-hook-function ()
    (if (featurep 'x-buffer-local-mouse)
        (progn
	  (setq x-c-middle 'x-find-tag)
          (setq x-c-right  'x-find-tag-other))))

Using the x-mouse package, one may make mouse bindings as follows:
  (define-key mouse-map x-button-c-left 'x-mouse-select-this)
The function convert-mouse-definitions will convert these to the buffer local
style using setq-default. Set point to beginning of definitions before calling
this function.  Optionally, before invoking, narrow region to just the
definitions. Then type Meta-X convert-mouse-definitions.

If your EMACSLOADPATH lists the directory that contains these files,
you can load the sml stuff and this mouse package as follows:
  (require 'sml-tags)
  (require 'simple-sml-mode)
  (if (getenv "DISPLAY")
      (progn
        (require 'x-buffer-local-mouse)
        (require 'mouse-tags)))
