🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #1339

Mouse interface for buffer list

#1339
From: Brian L. Kahn
Date: Tue, 09 Jun 1992 18:36
73 lines
2929 bytes
Here's a bit of code that I've found to be a real nice interface for
the buffer list.  This creates a window at the bottom of the screen
with a buffer list in it, invoked by clicking on any modeline with the
middle mouse button.  Mouse clicks in buff-ed call up the buffers.


----------snip snip----------

;;; buff-ed mouse interface for epoch
;;; Brian L. Kahn, blk@mitre.org, Tue Jun  9 12:25:16 1992




(defmacro funct (args &rest body)
  "Returns an instant, nameless, interactive function with ARGS and BODY."
  (` (function (lambda (, args) (interactive) (,@ body )))))


;;; from sun-mouse.el
(defmacro eval-in-window (window &rest forms)
  "Switch to WINDOW, evaluate FORMS, return to original window."
  (` (let ((OriginallySelectedWindow (selected-window)))
       (unwind-protect
	   (progn
	     (select-window (, window))
	     (,@ forms))
	 (select-window OriginallySelectedWindow)))))


(defun shrink-window-to-buffer (&optional window)
  "Shrinks current window or WINDOW to fit buffer, if buffer is smaller."
  (eval-in-window 
   (or window (selected-window))
   (let ((buffSize (1+ (count-lines (point-min)(point-max)))))
     (if (< buffSize (window-height))
	 (shrink-window (- (window-height) buffSize))
       ))))


(defun buffer-menu-sized (&optional args)
  "Buffer menu, sized to fit."
  (interactive)
  (list-buffers)
  (shrink-window-to-buffer (get-buffer-window "*Buffer List*"))
  )


(setq buffer-menu-mode-hook
      (funct ()
       (local-set-mouse mouse-left mouse-down
			'mouse::set-point)
       (local-set-mouse mouse-middle mouse-down
			(funct (args)
			       (mouse::set-point args)
			       (Buffer-menu-1-window)))
       (local-set-mouse mouse-right mouse-down
			(funct (args)
			       (mouse::set-point args)
			       (Buffer-menu-other-window)))
       (local-set-mouse mouse-left mouse-up ())
       (local-set-mouse mouse-middle mouse-up ())
       (local-set-mouse mouse-right mouse-up ())
       (message 
	"[left]-Select  [middle]-Full Screen  [right]-Split Screen")))


(global-set-mouse mouse-mode-middle mouse-down 'buffer-menu-sized)


--
B<   Brian Kahn   blk@security.mitre.org   "may the farce be with you"
Technical Details
Message-ID: <BLK.92Jun9133621@vanity.mitre.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!agate!linus!linus.mitre.org!news!mbunix!blk

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc7ee,7d41a7e68f213ec2,start
X-Google-Attributes: gidfc7ee,public
X-Google-ArrivalTime: 1992-06-09 07:18:30 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!agate!linus!linus.mitre.org!news!mbunix!blk
From: blk@mitre.org (Brian L. Kahn)
Newsgroups: gnu.epoch.misc
Subject: Mouse interface for buffer list
Message-ID: <BLK.92Jun9133621@vanity.mitre.org>
Date: 9 Jun 92 18:36:21 GMT
Article-I.D.: vanity.BLK.92Jun9133621
Sender: news@linus.mitre.org (News Service)
Distribution: gnu
Organization: The MITRE Corp. Bedford, MA
Lines: 73
Nntp-Posting-Host: vanity.mitre.org