[gnu.emacs] How can I find the most-recently-used window?

don@sunfs2.camex.uucp (Don Levinstone) (05/24/89)

;; In GNU EMACS, is there a way to know which WINDOW or BUFFER one was
;;   last in, i.e., prior to entering the MINIBUFFER?
;;
;; I'd like the following command to drop the name of the last major window
;;   or buffer into the minibuffer, but '(other-window 1)' always goes to
;;   the TOP window, not the 'most recent'...
;;
;; There is a 'get-lru-window' command, but I think I need something more
;;   like a 'get-mru-window' .
;; 
;; I used to have something like this for buffers, directories, file names,
;;   etc., under Prime EMACS, and I miss it!
;; 
(define-key ctl-x-4-map "b" 'drop-buffername)	; ^X-4-B
(define-key ctl-x-4-map "B" 'drop-buffername)
;;
(defun drop-buffername ()
  "Command to drop current MAJOR WINDOW's buffername in buffer"
  ;; Currently:  this works if invoked within a SINGLE displayed window,
  ;;   or within the the TOP window or BOTTOM window of 2 displayed windows,
  ;;   or from within the MINIBUFFER, when minibuffer was entered from the TOP
  ;;   window.
  ;; Bug:  when invoked from within the MINIBUFFER, when minibuffer was entered
  ;;   from the BOTTOM window, the name of the buffer in the TOP window is
  ;;   dropped into the minibuffer...
  ;;
  (interactive)
  (let (  (a (buffer-name)) )
    (if  (equal a " *Minibuf-0*")
	(progn (other-window 1) (setq a (buffer-name))
	       (delete-other-windows) (other-window -1))
    )
  (set-mark (point)) (insert a) ) nil)
-- 
Don Levinstone       UUCP: don@lloyd.uucp or husc6!lloyd!don
Camex, Inc.          ARPA: don%lloyd@husc6.harvard.edu  (untested)
75 Kneeland St., Boston, MA 02111
Tel: (617) 426-3577 x494   Fax: 426-9285          I do not speak for Camex.