home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!amdahl!JUTS!climb!tlp00
- From: tlp00@climb.as (Tibor Polgar)
- Newsgroups: alt.lucid-emacs.help
- Subject: Minibuffer button2 binding
- Message-ID: <b7IY02SX2aqr01@JUTS.ccc.amdahl.com>
- Date: 12 Nov 92 03:38:32 GMT
- Sender: netnews@ccc.amdahl.com
- Reply-To: tlp00@climb.as
- Organization: Sun Microsystems
- Lines: 44
-
- In 19.2 (pre mode-motion) i could swear it was possible to cut/paste into the
- minibuffer using the middle mouse button which guess was bound to
- x-set-point-and-insert-selection but now its minibuf-select....
-
- Anyway here is a function that does both, giving first priority to a highlighted
- region. It also fixes what i think is a bug with minibuf-select-highlighted...
- where it doesn't check to be sure that the cursor is in the minibuffer before it
- does the completion. code was heavily borrowed from both the above functions.
- -------------------------------------------------------------------------------------
- ;;
- ;; fix/modify minibuffer paste to allow completions or text insertion
- ;; also fixes "feature" with mode-motion completion where the cursor is in
- ;; completion window at the time of the selection.
- ;;
- (defun minibuf-select-valid-insertion (event)
- "Select either the highlighted text under the mouse as a minibuffer
- response, or insert the selected region text.
-
- When the minibuffer is being used to prompt the user for a completion,
- any valid completions which are visible on the screen will highlight
- when the mouse moves over them. Clicking \\<minibuffer-local-map>\
- \\[minibuf-select-valid-insertion] will select the
- highlighted completion under the mouse or insert the selected text at the mouse."
- (interactive "e")
- (let ((no-motion-p
- (save-excursion
- (minibuf-mouse-tracker event) ; make sure we're sync'd
- (set-buffer (window-buffer (event-window event)))
- (or (null mode-motion-extent)
- (= (extent-start-position mode-motion-extent)
- (extent-end-position mode-motion-extent))))))
- (if no-motion-p
- (progn
- (let ((text (or (condition-case () (x-get-selection) (error ()))
- (x-get-cutbuffer)
- (error "No highlighted completion, selection or cut buffer available"))))
- (mouse-set-point event)
- (insert text)))
- (progn
- (while (not (string-match "\^\\*Minibuf-" (buffer-name)))
- (other-window 1))
- (minibuf-select-highlighted-completion event)))))
-
- (define-key minibuffer-local-map 'button2 'minibuf-select-valid-insertion)
-