-;;; -*- Mode: Emacs-lisp -*-
-;; Copyright (C) 1991 Free Software Foundation, Inc.
+;;; reposition.el --- center a Lisp function or comment on the screen
+
+;; Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+
+;; Author: Michael D. Ernst <mernst@theory.lcs.mit.edu>
+;; Created: Jan 1991
+;; Maintainer: FSF
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;;; Reposition-window makes an entire function definition or comment visible,
;;; or, if it is already visible, places it at the top of the window;
;;; Reposition-window makes an entire function definition or comment visible,
;;; or, if it is already visible, places it at the top of the window;
;;; code. For the gory details, see the documentation for reposition-window;
;;; rather than reading that, you may just want to play with it.
;;; code. For the gory details, see the documentation for reposition-window;
;;; rather than reading that, you may just want to play with it.
;;; This tries pretty hard to do the recentering correctly; the precise
;;; action depends on what the buffer looks like. If you find a situation
;;; where it doesn't behave well, let me know. This function is modeled
;;; after one of the same name in ZMACS, but the code is all-new and the
;;; behavior in some situations differs.
;;; This tries pretty hard to do the recentering correctly; the precise
;;; action depends on what the buffer looks like. If you find a situation
;;; where it doesn't behave well, let me know. This function is modeled
;;; after one of the same name in ZMACS, but the code is all-new and the
;;; behavior in some situations differs.
(defun reposition-window (&optional arg)
"Make the current definition and/or comment visible.
Further invocations move it to the top of the window or toggle the
(defun reposition-window (&optional arg)
"Make the current definition and/or comment visible.
Further invocations move it to the top of the window or toggle the
;; whose first line is offscreen.
;; Avoid moving definition up even if defun runs offscreen;
;; we care more about getting the comment onscreen.
;; whose first line is offscreen.
;; Avoid moving definition up even if defun runs offscreen;
;; we care more about getting the comment onscreen.
(cond ((= line ht)
;; cursor on last screen line (and so in a comment)
(if arg (progn (end-of-defun) (beginning-of-defun)))
(recenter 0)
;;(repos-debug-macro "2a")
)
(cond ((= line ht)
;; cursor on last screen line (and so in a comment)
(if arg (progn (end-of-defun) (beginning-of-defun)))
(recenter 0)
;;(repos-debug-macro "2a")
)
((and arg (< ht comment-height))
;; Can't get first comment line onscreen.
;; Go there and try again.
((and arg (< ht comment-height))
;; Can't get first comment line onscreen.
;; Go there and try again.
; (concat "Case " (, case-no) ": %s %s %s %s %s")
; ht line comment-height defun-height defun-depth)))
; (concat "Case " (, case-no) ": %s %s %s %s %s")
; ht line comment-height defun-height defun-depth)))