home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / emacs / 4112 < prev    next >
Encoding:
Text File  |  1993-01-29  |  2.1 KB  |  52 lines

  1. Newsgroups: comp.emacs
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sun4nl!rulway.LeidenUniv.nl!ruls40.LeidenUniv.nl!desmedt
  3. From: desmedt@ruls40.LeidenUniv.nl (Koenraad de Smedt)
  4. Subject: port of Zmacs c-middle to GNU Emacs
  5. Message-ID: <1993Jan28.102735.3343@rulway.LeidenUniv.nl>
  6. Sender: root@rulway.LeidenUniv.nl (System PRIVILEGED Account)
  7. Nntp-Posting-Host: ruls40.leidenuniv.nl
  8. Reply-To: desmedt@ruls40.LeidenUniv.nl (Koenraad de Smedt)
  9. Organization: Leiden University, Netherlands
  10. Date: Thu, 28 Jan 93 10:27:35 GMT
  11. Lines: 39
  12.  
  13. I have been trying to port the behavior of the c-middle mouse button
  14. as defined in Zmacs (on Symbolics) to GNU Emacs 18.58 (under Ultrix
  15. with X11).
  16.  
  17. The functionality I am trying to achieve is the following: when you
  18. click on an S-expression (in any Emacs window), this S-expression will
  19. be immediately inserted at the current point.
  20.  
  21. The code below achieves exactly this functionality in a one-window
  22. Emacs.  However, if in a split-window situation, I click in an Emacs
  23. window other than the one where the point is currently, then the
  24. buffer in the other window is replaced by the current buffer.
  25. Obviously, this is not intended, but I don't understand why it happens
  26. and I don't know how to avoid it.  Any suggestions?
  27.  
  28. (defun x-copy-and-yank-this-s-expression (arg)
  29.   "Copy word being clicked on (without changing current point)
  30.    and yank at current point."
  31.   (save-excursion            ;find s-expression being clicked on
  32.     (let (beg end)
  33.       (x-mouse-set-point arg)
  34.       (if (looking-at ")")
  35.       (progn (forward-char)(backward-sexp)))
  36.       (forward-sexp)
  37.       (setq end (point))
  38.       (backward-sexp)
  39.       (setq beg (point))
  40.       (x-store-cut-buffer (buffer-substring beg end))))
  41.   (if (not (bolp))            ;provide appropriate white space
  42.       (progn (backward-char)
  43.          (if (not (looking-at "[ \t]"))
  44.          (progn (forward-char)
  45.             (insert-string " "))
  46.            (forward-char))))
  47.   (insert (x-get-cut-buffer)))
  48.  
  49. (define-key mouse-map x-button-c-middle 'x-copy-and-yank-this-s-expression)
  50.  
  51. Koenraad de Smedt  (Leiden University)
  52.