comparison lisp/help-mode.el @ 91085:880960b70474

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
author Miles Bader <miles@gnu.org>
date Sun, 11 Nov 2007 00:56:44 +0000
parents 424b655804ca 4077065d3026
children 606f2d163a64
comparison
equal deleted inserted replaced
91084:a4347a111894 91085:880960b70474
219 (interactive) 219 (interactive)
220 (kill-all-local-variables) 220 (kill-all-local-variables)
221 (use-local-map help-mode-map) 221 (use-local-map help-mode-map)
222 (setq mode-name "Help") 222 (setq mode-name "Help")
223 (setq major-mode 'help-mode) 223 (setq major-mode 'help-mode)
224
224 (view-mode) 225 (view-mode)
225 (make-local-variable 'view-no-disable-on-exit) 226 (set (make-local-variable 'view-no-disable-on-exit) t)
226 (setq view-no-disable-on-exit t) 227 ;; With Emacs 22 `view-exit-action' could delete the selected window
227 (setq view-exit-action (lambda (buffer) 228 ;; disregarding whether the help buffer was shown in that window at
228 (or (window-minibuffer-p (selected-window)) 229 ;; all. Since `view-exit-action' is called with the help buffer as
229 (one-window-p t) 230 ;; argument it seems more appropriate to have it work on the buffer
230 (delete-window)))) 231 ;; only and leave it to `view-mode-exit' to delete any associated
232 ;; window(s).
233 (setq view-exit-action
234 (lambda (buffer)
235 ;; Use `with-current-buffer' to make sure that `bury-buffer'
236 ;; also removes BUFFER from the selected window.
237 (with-current-buffer buffer
238 (bury-buffer))))
239
231 (run-mode-hooks 'help-mode-hook)) 240 (run-mode-hooks 'help-mode-hook))
232 241
233 ;;;###autoload 242 ;;;###autoload
234 (defun help-mode-setup () 243 (defun help-mode-setup ()
235 (help-mode) 244 (help-mode)
236 (setq buffer-read-only nil)) 245 (setq buffer-read-only nil))
237 246
238 ;;;###autoload 247 ;;;###autoload
239 (defun help-mode-finish () 248 (defun help-mode-finish ()
240 (let ((entry (assq (selected-window) view-return-to-alist))) 249 (if (eq help-window t)
241 (if entry 250 ;; If `help-window' is t, `view-return-to-alist' is handled by
242 ;; When entering Help mode from the Help window, 251 ;; `with-help-window'. In this case set `help-window' to the
243 ;; such as by following a link, preserve the same 252 ;; selected window since now is the only moment where we can
244 ;; meaning for the q command. 253 ;; unambiguously identify it.
245 ;; (setcdr entry (cons (selected-window) help-return-method)) 254 (setq help-window (selected-window))
246 nil 255 (let ((entry (assq (selected-window) view-return-to-alist)))
247 (setq view-return-to-alist 256 (if entry
248 (cons (cons (selected-window) help-return-method) 257 ;; When entering Help mode from the Help window,
249 view-return-to-alist)))) 258 ;; such as by following a link, preserve the same
259 ;; meaning for the q command.
260 ;; (setcdr entry (cons (selected-window) help-return-method))
261 nil
262 (setq view-return-to-alist
263 (cons (cons (selected-window) help-return-method)
264 view-return-to-alist)))))
265
250 (when (eq major-mode 'help-mode) 266 (when (eq major-mode 'help-mode)
251 ;; View mode's read-only status of existing *Help* buffer is lost 267 ;; View mode's read-only status of existing *Help* buffer is lost
252 ;; by with-output-to-temp-buffer. 268 ;; by with-output-to-temp-buffer.
253 (toggle-read-only 1) 269 (toggle-read-only 1)
254 (help-make-xrefs (current-buffer)))) 270 (help-make-xrefs (current-buffer))))
319 (setq help-xref-stack-item item))) 335 (setq help-xref-stack-item item)))
320 336
321 (defvar help-xref-following nil 337 (defvar help-xref-following nil
322 "Non-nil when following a help cross-reference.") 338 "Non-nil when following a help cross-reference.")
323 339
340 ;;;###autoload
324 (defun help-buffer () 341 (defun help-buffer ()
325 (buffer-name ;for with-output-to-temp-buffer 342 (buffer-name ;for with-output-to-temp-buffer
326 (if help-xref-following 343 (if help-xref-following
327 (current-buffer) 344 (current-buffer)
328 (get-buffer-create "*Help*")))) 345 (get-buffer-create "*Help*"))))
666 (apply method args) 683 (apply method args)
667 (with-current-buffer buffer 684 (with-current-buffer buffer
668 (if (get-buffer-window buffer) 685 (if (get-buffer-window buffer)
669 (set-window-point (get-buffer-window buffer) position) 686 (set-window-point (get-buffer-window buffer) position)
670 (goto-char position))))) 687 (goto-char position)))))
671 688
672 (defun help-go-back () 689 (defun help-go-back ()
673 "Go back to previous topic in this help buffer." 690 "Go back to previous topic in this help buffer."
674 (interactive) 691 (interactive)
675 (if help-xref-stack 692 (if help-xref-stack
676 (help-xref-go-back (current-buffer)) 693 (help-xref-go-back (current-buffer))
677 (error "No previous help buffer"))) 694 (error "No previous help buffer")))
678 695
679 (defun help-go-forward () 696 (defun help-go-forward ()
680 "Go back to next topic in this help buffer." 697 "Go back to next topic in this help buffer."
681 (interactive) 698 (interactive)
682 (if help-xref-forward-stack 699 (if help-xref-forward-stack
683 (help-xref-go-forward (current-buffer)) 700 (help-xref-go-forward (current-buffer))