aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEric S. Raymond1993-04-16 19:23:21 +0000
committerEric S. Raymond1993-04-16 19:23:21 +0000
commit17e2c564c75cbca90e9d396f418ca22da89c454d (patch)
tree5955858cb03898986692c43c08a465ce5868be69 /lisp
parent8ae3bc9f18081524e493c8d4d23aa9e92137fb9e (diff)
downloademacs-17e2c564c75cbca90e9d396f418ca22da89c454d.tar.gz
emacs-17e2c564c75cbca90e9d396f418ca22da89c454d.zip
(shrink-window-if-larger-than-buffer): Moved to window.el.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/electric.el32
1 files changed, 0 insertions, 32 deletions
diff --git a/lisp/electric.el b/lisp/electric.el
index dbb19946d6b..d0aa6f81dfc 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -28,38 +28,6 @@
28 28
29;;; Code: 29;;; Code:
30 30
31;; perhaps this should be in subr.el...
32(defun shrink-window-if-larger-than-buffer (&optional window)
33 "Shrink the WINDOW to be as small as possible to display its contents. Do
34nothing if only one window is displayed or if the buffer contains more lines
35than the present window height."
36 (save-excursion
37 (set-buffer (window-buffer window))
38 (let ((w (selected-window)) ;save-window-excursion can't win
39 (buffer-file-name buffer-file-name)
40 (p (point))
41 (n 0)
42 (window-min-height 0)
43 (buffer-read-only nil)
44 (modified (buffer-modified-p))
45 (buffer (current-buffer)))
46 (unwind-protect
47 (progn
48 (select-window window)
49 (goto-char (point-min))
50 (while (pos-visible-in-window-p (point-max))
51 ;; defeat file locking... don't try this at home, kids!
52 (setq buffer-file-name nil)
53 (insert ?\n) (setq n (1+ n)))
54 (if (> n 0) (shrink-window (1- n))))
55 (delete-region (point-min) (point))
56 (set-buffer-modified-p modified)
57 (goto-char p)
58 (select-window w)
59 ;; Make sure we unbind buffer-read-only
60 ;; with the proper current buffer.
61 (set-buffer buffer)))))
62
63;; This loop is the guts for non-standard modes which retain control 31;; This loop is the guts for non-standard modes which retain control
64;; until some event occurs. It is a `do-forever', the only way out is to 32;; until some event occurs. It is a `do-forever', the only way out is to
65;; throw. It assumes that you have set up the keymap, window, and 33;; throw. It assumes that you have set up the keymap, window, and