home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / epoch / epoch-profile.el < prev    next >
Encoding:
Text File  |  1991-03-30  |  6.6 KB  |  210 lines

  1. ; Subject: Re: Bugs and gripes
  2. ; Date: Thu, 27 Sep 90 17:29:06 -0000
  3. ; From: Colas Nahaboo <colas@avahi.inria.fr>
  4. ; > Mouse should abort isearch:
  5. ; >    Is there a way to make mouse functions abort isearch?  It is sometimes
  6. ; >    bothersome to do a bunch of mouse functions (cut, paste, set-point),
  7. ; >    then type something only to realize that an isearch is still in
  8. ; >    progress!  The same is true of electric functions.
  9. ; >    Electric-buffer-menu-mode provides a catch that can be used with a local
  10. ; >    mouse map, but mousing in other screens or windows leads to the same
  11. ; >    problem as with isearch.  Maybe the proper way to fix these things is to
  12. ; >    modify the elisp to temporarily install its own mouse handler.
  13. ; I ise x-mouse-set-point (defined below) which fixes the problem.
  14. ; Also, I have added (epoch::redisplay-screen) on all mouse functions to
  15. ; "fix" the delayed display bugs
  16. ; The full contents of my epoch-profile.el file follows, if you want more
  17. ; goodies
  18. ; This is a .emacs file for initializing gnuemacs.  Customize however
  19. ; you like
  20.  
  21. ;; target-buffer is used by random bits of the epoch code.
  22.  
  23. (setq target-buffer (get-buffer "*scratch*"))
  24.  
  25. ;; live dangerously
  26.  
  27. (put 'eval-expression 'disabled nil)
  28.  
  29. ;; because I have so many screens open all the time, and idle C-xC-c can
  30. ;; really screw things up for me.  So make sure we dont exit without
  31. ;; confirmation, and rebind C-xC-c appropriately
  32.  
  33. (defun exit-emacs-with-confirm ()
  34.   (interactive)
  35.   (if (yes-or-no-p "Do you want to exit ")
  36.       (save-buffers-kill-emacs)))
  37.  
  38. (global-set-key "\C-x\C-c" 'exit-emacs-with-confirm)
  39.  
  40. ;(setq exec-path (append '("/usr/local/lib/epoch/etc/") exec-path))
  41. ;(setq exec-directory "/usr/local/lib/epoch/etc/")
  42.  
  43. ;; load epoch files
  44.  
  45.     (load "epoch-util" () t)
  46.     (load "epoch" () t)
  47.     (load "button" () t)
  48.     (load "mouse" () t)
  49.     (load "motion" () t)
  50.     (load "property" () t)
  51.     (load "message" () t)
  52.     (load "server" () t)
  53. ;(load "maintain-screen-titles" () t)
  54.  
  55. (setq epoch::buttons-modify-buffer nil)
  56.  
  57. (setq auto-raise-screen ())
  58. (setq include-system-name ())
  59.  
  60. ;; mouse bindings
  61. (defun x-scroll-region (arg)
  62.   "Scroll window by ARG lines, up or down.
  63.  ARG is line-count between cursor and mouse."
  64.   (select-screen (nth 3 arg))
  65.   (select-window (nth 2 arg))
  66.   (if (> (dot) (car arg))
  67.       (scroll-up (- (count-lines (car arg) (dot))
  68.                    (if (bolp) 0 1)))
  69.     (let ((opoint (dot)))
  70.       (goto-char (car arg))
  71.       (scroll-down (- (count-lines opoint (dot))
  72.                      (if (bolp) 0 1)))
  73.       (goto-char opoint))))
  74.  
  75. (defun x-select-word (arg)
  76.   "Select word under cursor"
  77.   ;;  (epoch::set-motion-hints ())
  78.   (save-window-excursion
  79.     (let (opoint beg end)
  80.       (mouse::set-point arg)
  81.       (forward-char)
  82.       (forward-word -1)
  83.       (setq opoint (point))
  84.       (forward-word 1)
  85.       (epoch::delete-button drag-button)
  86.       (set-marker mouse-down-marker opoint)
  87.       (setq beg (min opoint (point))
  88.            end (max opoint (point)))
  89.       (setq drag-button (epoch::add-button beg end 1 nil))
  90.       (epoch::redisplay-screen)
  91.       (epoch::store-cut-buffer (buffer-substring beg end))
  92.       (copy-region-as-kill beg end)
  93.       )))
  94.  
  95. (defun x-cut-text (arg)
  96.   "selects text and wipe it"
  97.   (select-screen (nth 3 arg))
  98.   (select-window (nth 2 arg))
  99.   (epoch::store-cut-buffer (buffer-substring (dot) (car arg)))
  100.   (kill-region (dot) (car arg)))
  101.  
  102. (defun x-mouse-set-mark (arg)
  103.   "puts mark at mouse cursor"
  104.   (select-screen (nth 3 arg))
  105.   (select-window (nth 2 arg))
  106.   (set-mark (dot))
  107.   (goto-char (car arg))
  108.   (exchange-point-and-mark))
  109.  
  110. (defun x-mouse-set-region (arg)
  111.   "selects text, then makes it the current region"
  112.   (extend-mouse-drag arg)
  113.   (end-mouse-drag arg)
  114.   (set-mark (dot))
  115.   (goto-char (car arg))
  116.   (copy-region-as-kill))
  117.  
  118. (defun x-mouse-paste (arg)
  119.   "paste, moves cursor there, and redraws due to a bug in 3.2b"
  120.   (select-screen (nth 3 arg))
  121.   (select-window (nth 2 arg))
  122.   (goto-char (car arg))
  123.   (insert (epoch::get-cut-buffer))
  124.   (undo-boundary)
  125.   (epoch::redisplay-screen))
  126.  
  127. (defun x-mouse-paste-no-move (arg)
  128.   "paste, moves cursor there, and redraws due to a bug in 3.2b"
  129.   (mouse::paste-cut-buffer arg)
  130.   (epoch::redisplay-screen))
  131.  
  132. (defun x-mouse-set-point (arg)
  133.   "sets point but exit from incremental search"
  134.   (start-mouse-drag arg)
  135.   (abort-isearch)
  136.   (epoch::redisplay-screen))
  137.  
  138.                                        ; mouse key bindings
  139.  
  140. (global-set-mouse mouse-left mouse-down  'x-mouse-set-point)
  141. (global-set-mouse mouse-middle mouse-down  'x-mouse-paste)
  142.  
  143. (global-set-mouse mouse-left  mouse-shift  'x-scroll-region)
  144. (global-set-mouse mouse-middle mouse-shift 'x-mouse-set-mark)
  145. (global-set-mouse mouse-right mouse-shift 'x-mouse-set-region)
  146.  
  147. (global-set-mouse mouse-left  mouse-control     'x-select-word)
  148. (global-set-mouse mouse-middle mouse-control    'x-mouse-paste-no-move)
  149. (global-set-mouse mouse-right mouse-control  'x-cut-text)
  150.  
  151. (global-set-mouse mouse-left mouse-control-shift 'x-mouse-set-mark)
  152.  
  153. ;; \M-\C-y yanks the contents of the cut buffer
  154.  
  155. (defun yank-cut-buffer ()
  156.   "yanks the contents of the cut buffer at the text cursor position."
  157.   (interactive)
  158.   (insert (epoch::get-cut-buffer)))
  159. (global-set-key "\M-\C-y" 'yank-cut-buffer)
  160.  
  161. ;(display-time)
  162.  
  163. ; Wakes up epochs event handler and adminsters caffeine.
  164. ; Ripped bodily out of epoch.el: epoch 3.1 only.
  165. ;    Simon Spero, zmacx07@cc.ic.ac.uk
  166. ;
  167. (defun epoch::oh-no-epochs-buggered-again ()
  168.   (interactive)
  169.   (epoch::map-screen (epoch::minibuf-screen))
  170.   )
  171.  
  172.  
  173. (global-set-key "\C-z=" 'epoch::oh-no-epochs-buggered-again)
  174.  
  175. ;; murthy@cs.cornell.edu (Chet Murthy): exit from isearch
  176.  
  177. (defun abort-isearch ()
  178.   (condition-case err
  179.          (throw 'search-done t)
  180.   (no-catch nil)))
  181.  
  182. (defun x (key param)
  183.   "sets various X parameters of current screen"
  184.   (interactive "cSet what? Font, Back, Text, Cursor: \nsset to: ")
  185.   (cond ((char-equal ?f key) (epoch::font param))
  186.        ((char-equal ?c key) (epoch::cursor-glyph (string-to-int param)))
  187.        ((char-equal ?b key) (epoch::background param))
  188.        ((char-equal ?t key) (epoch::foreground param)))
  189.   (recenter))
  190.  
  191. (defun rename-screen (&optional name)
  192.   (interactive)
  193.   (let ((curr-scr-name (epoch::get-property "WM_NAME")))
  194.     (if (not (or (string= curr-scr-name "Mh-Rmail")
  195.                 (string= curr-scr-name "Calendar")))
  196.        (epoch::set-property "WM_NAME" (or name (concat (buffer-name)
  197.                                                     (sys-name)))))))
  198.  
  199. (defun iconify-screen-and-set-icon (&optional arg)
  200.   (interactive)
  201.   (epoch::set-property "WM_ICON_NAME" (epoch::get-property "WM_NAME"))
  202.   (epoch::iconify-screen arg))
  203.  
  204. (global-set-key "\C-zi" 'iconify-screen-and-set-icon)
  205.