comparison lisp/prim/reposition.el @ 72:b9518feda344 r20-0b31

Import from CVS: tag r20-0b31
author cvs
date Mon, 13 Aug 2007 09:03:46 +0200
parents 131b0175ea99
children
comparison
equal deleted inserted replaced
71:bae944334fa4 72:b9518feda344
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of 17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details. 19 ;; General Public License for more details.
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; Free Software Foundation, 59 Temple Place - Suite 330, 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; Boston, MA 02111-1307, USA. 24 ;; 02111-1307, USA.
25 25
26 ;;; Synched up with: FSF 19.30. 26 ;;; Synched up with: FSF 19.34.
27 27
28 ;;; Commentary: 28 ;;; Commentary:
29 29
30 ;;; Reposition-window makes an entire function definition or comment visible, 30 ;; Reposition-window makes an entire function definition or comment visible,
31 ;;; or, if it is already visible, places it at the top of the window; 31 ;; or, if it is already visible, places it at the top of the window;
32 ;;; additional invocations toggle the visibility of comments preceding the 32 ;; additional invocations toggle the visibility of comments preceding the
33 ;;; code. For the gory details, see the documentation for reposition-window; 33 ;; code. For the gory details, see the documentation for reposition-window;
34 ;;; rather than reading that, you may just want to play with it. 34 ;; rather than reading that, you may just want to play with it.
35 35
36 ;;; This tries pretty hard to do the recentering correctly; the precise 36 ;; This tries pretty hard to do the recentering correctly; the precise
37 ;;; action depends on what the buffer looks like. If you find a situation 37 ;; action depends on what the buffer looks like. If you find a situation
38 ;;; where it doesn't behave well, let me know. This function is modeled 38 ;; where it doesn't behave well, let me know. This function is modeled
39 ;;; after one of the same name in ZMACS, but the code is all-new and the 39 ;; after one of the same name in ZMACS, but the code is all-new and the
40 ;;; behavior in some situations differs. 40 ;; behavior in some situations differs.
41 41
42 ;;; Code: 42 ;;; Code:
43 43
44 ;;;###autoload 44 ;;;###autoload
45 (defun reposition-window (&optional arg) 45 (defun reposition-window (&optional arg)
72 (max 0 72 (max 0
73 (repos-count-screen-lines-signed 73 (repos-count-screen-lines-signed
74 ;; the beginning of the preceding comment 74 ;; the beginning of the preceding comment
75 (save-excursion 75 (save-excursion
76 (if (not (eobp)) (forward-char 1)) 76 (if (not (eobp)) (forward-char 1))
77 (end-of-defun -1) 77 (end-of-defun -1)
78 ;; Skip whitespace, newlines, and form feeds. 78 ;; Skip whitespace, newlines, and form feeds.
79 (if (re-search-forward "[^ \t\n\f]" nil t) 79 (if (re-search-forward "[^ \t\n\f]" nil t)
80 (backward-char 1)) 80 (backward-char 1))
81 (point)) 81 (point))
82 here))) 82 here)))
83 (defun-height 83 (defun-height
84 (repos-count-screen-lines-signed 84 (repos-count-screen-lines-signed
85 (save-excursion 85 (save-excursion
86 (end-of-defun 1) ; so comments associate with following defuns 86 (end-of-defun 1) ; so comments associate with following defuns
87 (beginning-of-defun 1) 87 (beginning-of-defun 1)
88 (point)) 88 (point))
120 (< defun-height 0))) 120 (< defun-height 0)))
121 ;; Defun line or cursor at top of screen, OR cursor in comment 121 ;; Defun line or cursor at top of screen, OR cursor in comment
122 ;; whose first line is offscreen. 122 ;; whose first line is offscreen.
123 ;; Avoid moving definition up even if defun runs offscreen; 123 ;; Avoid moving definition up even if defun runs offscreen;
124 ;; we care more about getting the comment onscreen. 124 ;; we care more about getting the comment onscreen.
125 125
126 (cond ((= line ht) 126 (cond ((= line ht)
127 ;; cursor on last screen line (and so in a comment) 127 ;; cursor on last screen line (and so in a comment)
128 (if arg (progn (end-of-defun) (beginning-of-defun))) 128 (if arg (progn (end-of-defun) (beginning-of-defun)))
129 (recenter 0) 129 (recenter 0)
130 ;;(repos-debug-macro "2a") 130 ;;(repos-debug-macro "2a")
131 ) 131 )
132 132
133 ;; This condition, copied from case 4, may not be quite right 133 ;; This condition, copied from case 4, may not be quite right
134 134
135 ((and arg (< ht comment-height)) 135 ((and arg (< ht comment-height))
136 ;; Can't get first comment line onscreen. 136 ;; Can't get first comment line onscreen.
137 ;; Go there and try again. 137 ;; Go there and try again.
138 (forward-line (- comment-height)) 138 (forward-line (- comment-height))
139 (beginning-of-line) 139 (beginning-of-line)