]> code.delx.au - gnu-emacs/blobdiff - lisp/help-mode.el
Merge from mainline.
[gnu-emacs] / lisp / help-mode.el
index f115e4253252f44471358f68595fa6d3476833e2..51d18235e1bed74362acdb490a67d8f025191cf9 100644 (file)
@@ -1,10 +1,11 @@
 ;;; help-mode.el --- `help-mode' used by *Help* buffers
 
-;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2011
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help, internal
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
 (require 'view)
 (eval-when-compile (require 'easymenu))
 
-(defvar help-mode-map (make-sparse-keymap)
+(defvar help-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map button-buffer-map)
+
+    (define-key map [mouse-2] 'help-follow-mouse)
+    (define-key map "\C-c\C-b" 'help-go-back)
+    (define-key map "\C-c\C-f" 'help-go-forward)
+    (define-key map "\C-c\C-c" 'help-follow-symbol)
+    ;; Documentation only, since we use minor-mode-overriding-map-alist.
+    (define-key map "\r" 'help-follow)
+    map)
   "Keymap for help mode.")
 
-(set-keymap-parent help-mode-map button-buffer-map)
-
-(define-key help-mode-map [mouse-2] 'help-follow-mouse)
-(define-key help-mode-map "\C-c\C-b" 'help-go-back)
-(define-key help-mode-map "\C-c\C-f" 'help-go-forward)
-(define-key help-mode-map "\C-c\C-c" 'help-follow-symbol)
-;; Documentation only, since we use minor-mode-overriding-map-alist.
-(define-key help-mode-map "\r" 'help-follow)
-
 (easy-menu-define help-mode-menu help-mode-map
   "Menu for Help Mode."
   '("Help-Mode"
@@ -244,6 +246,25 @@ The format is (FUNCTION ARGS...).")
                       (message "Unable to find location in file"))))
   'help-echo (purecopy "mouse-2, RET: find face's definition"))
 
+(define-button-type 'help-package
+  :supertype 'help-xref
+  'help-function 'describe-package
+  'help-echo (purecopy "mouse-2, RET: Describe package"))
+
+(define-button-type 'help-package-def
+  :supertype 'help-xref
+  'help-function (lambda (file) (dired file))
+  'help-echo (purecopy "mouse-2, RET: visit package directory"))
+
+(define-button-type 'help-theme-def
+  :supertype 'help-xref
+  'help-function 'find-file
+  'help-echo (purecopy "mouse-2, RET: visit theme file"))
+
+(define-button-type 'help-theme-edit
+  :supertype 'help-xref
+  'help-function 'customize-create-theme
+  'help-echo (purecopy "mouse-2, RET: edit this theme file"))
 \f
 ;;;###autoload
 (defun help-mode ()
@@ -272,6 +293,9 @@ Commands:
          (with-current-buffer buffer
            (bury-buffer))))
 
+  (set (make-local-variable 'revert-buffer-function)
+       'help-mode-revert-buffer)
+
   (run-mode-hooks 'help-mode-hook))
 
 ;;;###autoload
@@ -302,6 +326,15 @@ Commands:
     ;; View mode's read-only status of existing *Help* buffer is lost
     ;; by with-output-to-temp-buffer.
     (toggle-read-only 1)
+
+    (save-excursion
+      (goto-char (point-min))
+      (let ((inhibit-read-only t))
+       (when (re-search-forward "^This \\w+ is advised.$" nil t)
+         (put-text-property (match-beginning 0)
+                            (match-end 0)
+                            'face 'font-lock-warning-face))))
+
     (help-make-xrefs (current-buffer))))
 \f
 ;; Grokking cross-reference information in doc strings and
@@ -376,13 +409,16 @@ restore it properly when going back."
 (defun help-buffer ()
   "Return the name of a buffer for inserting help.
 If `help-xref-following' is non-nil, this is the name of the
-current buffer.
-Otherwise, it is *Help*; if no buffer with that name currently
-exists, it is created."
+current buffer.  Signal an error if this buffer is not derived
+from `help-mode'.
+Otherwise, return \"*Help*\", creating a buffer with that name if
+it does not already exist."
   (buffer-name                         ;for with-output-to-temp-buffer
-   (if help-xref-following
-       (current-buffer)
-     (get-buffer-create "*Help*"))))
+   (if (not help-xref-following)
+       (get-buffer-create "*Help*")
+     (unless (derived-mode-p 'help-mode)
+       (error "Current buffer is not in Help mode"))
+     (current-buffer))))
 
 (defvar help-xref-override-view-map
   (let ((map (make-sparse-keymap)))
@@ -783,6 +819,17 @@ Show all docs for that symbol as either a variable, function or face."
              (fboundp sym) (facep sym))
       (help-do-xref pos #'help-xref-interned (list sym)))))
 
+(defun help-mode-revert-buffer (ignore-auto noconfirm)
+  (when (or noconfirm (yes-or-no-p "Revert help buffer? "))
+    (let ((pos (point))
+         (item help-xref-stack-item)
+         ;; Pretend there is no current item to add to the history.
+         (help-xref-stack-item nil)
+         ;; Use the current buffer.
+         (help-xref-following t))
+      (apply (car item) (cdr item))
+      (goto-char pos))))
+
 (defun help-insert-string (string)
   "Insert STRING to the help buffer and install xref info for it.
 This function can be used to restore the old contents of the help buffer
@@ -795,5 +842,4 @@ help buffer by other means."
 
 (provide 'help-mode)
 
-;; arch-tag: 850954ae-3725-4cb4-8e91-0bf6d52d6b0b
 ;;; help-mode.el ends here