]> code.delx.au - gnu-emacs/blobdiff - lisp/reposition.el
(xscheme-insert-expression): Use add-to-history.
[gnu-emacs] / lisp / reposition.el
index 0dda524f079c9d5d99f3867f9a398177d02d55af..a87b72443df9c1dd4418889e3779113f41482ab6 100644 (file)
@@ -1,6 +1,7 @@
 ;;; reposition.el --- center a Lisp function or comment on the screen
 
-;; Copyright (C) 1991 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1994, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Michael D. Ernst <mernst@theory.lcs.mit.edu>
 ;; Created: Jan 1991
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; 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, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; 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;
-;;; additional invocations toggle the visibility of comments preceding the
-;;; code.  For the gory details, see the documentation for reposition-window;
-;;; rather than reading that, you may just want to play with it.
+;; Reposition-window makes an entire function definition or comment visible,
+;; or, if it is already visible, places it at the top of the window;
+;; additional invocations toggle the visibility of comments preceding the
+;; 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.
 
 ;;; Code:
 
@@ -71,13 +73,13 @@ first comment line visible (if point is in a comment)."
                ;; the beginning of the preceding comment
                (save-excursion
                  (if (not (eobp)) (forward-char 1))
-                 (end-of-defun -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
@@ -119,16 +121,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.
@@ -169,8 +171,7 @@ first comment line visible (if point is in a comment)."
           ;;(repos-debug-macro "4")
           ))))
 
-;;;###autoload
-(define-key esc-map "\C-l" 'reposition-window)
+;;;###autoload (define-key esc-map "\C-l" 'reposition-window)
 
 ;;; Auxiliary functions
 
@@ -190,9 +191,11 @@ first comment line visible (if point is in a comment)."
        lines
       (- lines))))
 
-; (defmacro repos-debug-macro (case-no)
-;   (` (message
-;       (concat "Case " (, case-no) ": %s %s %s %s %s")
-;       ht line comment-height defun-height defun-depth)))
+;; (defmacro repos-debug-macro (case-no)
+;;   `(message (concat "Case " ,case-no ": %s %s %s %s %s")
+;;             ht line comment-height defun-height defun-depth))
+
+(provide 'reposition)
 
+;;; arch-tag: 79487039-3bd7-4ab5-a3e8-ecf3b4919010
 ;;; reposition.el ends here