(scan_sexps_forward): Fix previous change.
[bpt/emacs.git] / lisp / reposition.el
index 5802e6d..e961d4e 100644 (file)
@@ -1,11 +1,16 @@
-;;; -*- 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
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -17,7 +22,7 @@
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
-;;; Written by Michael D. Ernst, mernst@theory.lcs.mit.edu, Jan 1991.
+;;; Commentary:
 
 ;;; Reposition-window makes an entire function definition or comment visible,
 ;;; or, if it is already visible, places it at the top of the window;
@@ -31,6 +36,8 @@
 ;;; after one of the same name in ZMACS, but the code is all-new and the
 ;;; behavior in some situations differs.
 
+;;; Code:
+
 ;;;###autoload
 (defun reposition-window (&optional arg)
   "Make the current definition and/or comment visible.
@@ -63,13 +70,14 @@ first comment line visible (if point is in a comment)."
               (repos-count-screen-lines-signed
                ;; the beginning of the preceding comment
                (save-excursion
-                 (forward-char 1) (end-of-defun -1) 
+                 (if (not (eobp)) (forward-char 1))
+                 (end-of-defun -1)
                  ;; Skip whitespace, newlines, and form feeds.
-                 (re-search-forward "[^\\s \n\014]")
-                 (backward-char 1)
+                 (if (re-search-forward "[^ \t\n\f]" nil t)
+                     (backward-char 1))
                  (point))
                here)))
-        (defun-height 
+        (defun-height
           (repos-count-screen-lines-signed
            (save-excursion
              (end-of-defun 1) ; so comments associate with following defuns
@@ -111,16 +119,16 @@ first comment line visible (if point is in a comment)."
           ;; 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")
                  )
-                
+
                 ;; This condition, copied from case 4, may not be quite right
-                
+
                 ((and arg (< ht comment-height))
                  ;; Can't get first comment line onscreen.
                  ;; Go there and try again.
@@ -161,6 +169,8 @@ first comment line visible (if point is in a comment)."
           ;;(repos-debug-macro "4")
           ))))
 
+;;;###autoload (define-key esc-map "\C-l" 'reposition-window)
+
 ;;; Auxiliary functions
 
 ;; Return number of screen lines between START and END.
@@ -184,3 +194,4 @@ first comment line visible (if point is in a comment)."
 ;       (concat "Case " (, case-no) ": %s %s %s %s %s")
 ;       ht line comment-height defun-height defun-depth)))
 
+;;; reposition.el ends here