Mercurial > emacs
comparison lisp/ehelp.el @ 160:84efc09a36b4
*** empty log message ***
author | root <root> |
---|---|
date | Fri, 11 Jan 1991 19:38:45 +0000 |
parents | 9697c13298e5 |
children | 74504bd76aaa |
comparison
equal
deleted
inserted
replaced
159:e7abb99c2a38 | 160:84efc09a36b4 |
---|---|
70 When the user exits (with electric-help-exit, or otherwise) the help | 70 When the user exits (with electric-help-exit, or otherwise) the help |
71 buffer's window disappears (ie we use save-window-excursion) | 71 buffer's window disappears (ie we use save-window-excursion) |
72 BUFFER is put into default-major-mode (or fundamental-mode) when we exit" | 72 BUFFER is put into default-major-mode (or fundamental-mode) when we exit" |
73 (setq buffer (get-buffer-create (or buffer "*Help*"))) | 73 (setq buffer (get-buffer-create (or buffer "*Help*"))) |
74 (let ((one (one-window-p t)) | 74 (let ((one (one-window-p t)) |
75 (two nil)) | 75 (config (current-window-configuration)) |
76 (save-window-excursion | 76 (bury nil)) |
77 (save-excursion | 77 (unwind-protect |
78 (if one (goto-char (window-start (selected-window)))) | 78 (save-excursion |
79 (let ((pop-up-windows t)) | 79 (if one (goto-char (window-start (selected-window)))) |
80 (pop-to-buffer buffer)) | 80 (let ((pop-up-windows t)) |
81 (unwind-protect | 81 (pop-to-buffer buffer)) |
82 (progn | 82 (save-excursion |
83 (save-excursion | 83 (set-buffer buffer) |
84 (set-buffer buffer) | 84 (electric-help-mode) |
85 (electric-help-mode) | 85 (setq buffer-read-only nil) |
86 (setq buffer-read-only nil) | 86 (or noerase (erase-buffer))) |
87 (or noerase (erase-buffer))) | 87 (let ((standard-output buffer)) |
88 (let ((standard-output buffer)) | 88 (if (not (funcall thunk)) |
89 (if (funcall thunk) | 89 (progn |
90 () | 90 (set-buffer buffer) |
91 (set-buffer buffer) | 91 (set-buffer-modified-p nil) |
92 (set-buffer-modified-p nil) | 92 (goto-char (point-min)) |
93 (goto-char (point-min)) | 93 (if one (shrink-window-if-larger-than-buffer (selected-window)))))) |
94 (if one (shrink-window-if-larger-than-buffer (selected-window))))) | 94 (set-buffer buffer) |
95 (set-buffer buffer) | 95 (run-hooks 'electric-help-mode-hook) |
96 (run-hooks 'electric-help-mode-hook) | 96 (if (eq (car-safe (electric-help-command-loop)) |
97 (setq two (electric-help-command-loop)) | 97 'retain) |
98 (cond ((eq (car-safe two) 'retain) | 98 (setq config (current-window-configuration)) |
99 (setq two (vector (window-height (selected-window)) | 99 (setq bury t))) |
100 (window-start (selected-window)) | 100 (message "") |
101 (window-hscroll (selected-window)) | 101 (set-buffer buffer) |
102 (point)))) | 102 (setq buffer-read-only nil) |
103 (t (setq two nil)))) | 103 (condition-case () |
104 | 104 (funcall (or default-major-mode 'fundamental-mode)) |
105 (message "") | 105 (error nil)) |
106 (set-buffer buffer) | 106 (set-window-configuration config) |
107 (setq buffer-read-only nil) | 107 (if bury |
108 (condition-case () | 108 (progn |
109 (funcall (or default-major-mode 'fundamental-mode)) | 109 ;;>> Perhaps this shouldn't be done. |
110 (error nil))))) | 110 ;; so that when we say "Press space to bury" we mean it |
111 (if two | 111 (replace-buffer-in-windows buffer) |
112 (let ((pop-up-windows t) | 112 ;; must do this outside of save-window-excursion |
113 tem) | 113 (bury-buffer buffer)))))) |
114 (pop-to-buffer buffer) | |
115 (setq tem (- (window-height (selected-window)) (elt two 0))) | |
116 (if (> tem 0) (shrink-window tem)) | |
117 (set-window-start (selected-window) (elt two 1) t) | |
118 (set-window-hscroll (selected-window) (elt two 2)) | |
119 (goto-char (elt two 3))) | |
120 ;;>> Perhaps this shouldn't be done. | |
121 ;; so that when we say "Press space to bury" we mean it | |
122 (replace-buffer-in-windows buffer) | |
123 ;; must do this outside of save-window-excursion | |
124 (bury-buffer buffer)))) | |
125 | 114 |
126 (defun electric-help-command-loop () | 115 (defun electric-help-command-loop () |
127 (catch 'exit | 116 (catch 'exit |
128 (if (pos-visible-in-window-p (point-max)) | 117 (if (pos-visible-in-window-p (point-max)) |
129 (progn (message "<<< Press Space to bury the help buffer >>>") | 118 (progn (message "<<< Press Space to bury the help buffer >>>") |