home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / alt / lucidem / help / 682 < prev    next >
Encoding:
Text File  |  1992-11-11  |  2.4 KB  |  56 lines

  1. Path: sparky!uunet!charon.amdahl.com!amdahl!JUTS!climb!tlp00
  2. From: tlp00@climb.as (Tibor Polgar)
  3. Newsgroups: alt.lucid-emacs.help
  4. Subject: Minibuffer button2 binding
  5. Message-ID: <b7IY02SX2aqr01@JUTS.ccc.amdahl.com>
  6. Date: 12 Nov 92 03:38:32 GMT
  7. Sender: netnews@ccc.amdahl.com
  8. Reply-To: tlp00@climb.as
  9. Organization: Sun Microsystems
  10. Lines: 44
  11.  
  12. In 19.2 (pre mode-motion) i could swear it was possible to cut/paste into the 
  13. minibuffer using the middle mouse button which guess was bound to 
  14. x-set-point-and-insert-selection  but now its minibuf-select.... 
  15.  
  16. Anyway here is a function that does both, giving first priority to a highlighted 
  17. region.   It also fixes what i think is a bug with minibuf-select-highlighted...
  18. where it doesn't check to be sure that the cursor is in the minibuffer before it
  19. does the completion.    code was heavily borrowed from both the above functions.
  20. -------------------------------------------------------------------------------------
  21. ;;
  22. ;; fix/modify minibuffer paste to allow completions or text insertion
  23. ;;  also fixes "feature" with mode-motion completion where the cursor is in 
  24. ;;  completion window at the time of the selection.
  25. ;;
  26. (defun minibuf-select-valid-insertion (event)
  27.   "Select either the highlighted text under the mouse as a minibuffer
  28. response, or insert the selected region text.
  29.  
  30. When the minibuffer is being used to prompt the user for a completion,
  31. any valid completions which are visible on the screen will highlight
  32. when the mouse moves over them.  Clicking \\<minibuffer-local-map>\
  33. \\[minibuf-select-valid-insertion] will select the
  34. highlighted completion under the mouse or insert the selected text at the mouse."
  35.   (interactive "e")
  36.   (let ((no-motion-p
  37.      (save-excursion  
  38.        (minibuf-mouse-tracker event) ; make sure we're sync'd
  39.        (set-buffer (window-buffer (event-window event)))
  40.        (or (null mode-motion-extent)
  41.            (= (extent-start-position mode-motion-extent)
  42.           (extent-end-position mode-motion-extent))))))
  43.     (if no-motion-p
  44.     (progn 
  45.       (let ((text (or (condition-case () (x-get-selection) (error ()))
  46.               (x-get-cutbuffer)
  47.               (error "No highlighted completion, selection or cut buffer available"))))
  48.         (mouse-set-point event)
  49.         (insert text)))
  50.       (progn 
  51.     (while (not (string-match "\^\\*Minibuf-" (buffer-name)))
  52.       (other-window 1))
  53.     (minibuf-select-highlighted-completion event)))))
  54.  
  55. (define-key minibuffer-local-map 'button2 'minibuf-select-valid-insertion)
  56.