]> code.delx.au - gnu-emacs/blobdiff - lisp/descr-text.el
Regenerate, and restore by hand the shell function message lost in
[gnu-emacs] / lisp / descr-text.el
index 76d6ae6be095e99005d4c2f459080acde0c6c5b5..d14aba7ae6f40b31dc304867b5fe93c62622f5c5 100644 (file)
@@ -1,7 +1,7 @@
 ;;; descr-text.el --- describe text mode
 
 ;; Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <boris@gnu.org>
 ;; Maintainer: FSF
@@ -11,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -30,7 +30,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'button) (require 'quail))
+(eval-when-compile (require 'quail))
+(require 'help-fns)
 
 ;;; Describe-Text Utilities.
 
   (insert-text-button
    (symbol-name (if (symbolp widget) widget (car widget)))
    'action `(lambda (&rest ignore)
-             (widget-browse ',widget)))
+             (widget-browse ',widget))
+   'help-echo "mouse-2, RET: browse this widget")
   (insert " ")
-  (insert-text-button "(widget)Top"
-                     'action (lambda (&rest ignore) (info "(widget)Top"))
-                     'help-echo "mouse-2, RET: read this Info node"))
+  (insert-text-button
+   "(widget)Top" 'type 'help-info 'help-args '("(widget)Top")))
 
 (defun describe-text-sexp (sexp)
   "Insert a short description of SEXP in the current buffer."
@@ -59,7 +60,7 @@
              (t t))
        (insert pp)
       (insert-text-button
-       "show" 'action `(lambda (&rest ignore)
+       "[Show]" 'action `(lambda (&rest ignore)
                        (with-output-to-temp-buffer
                            "*Pp Eval Output*"
                          (princ ',pp)))
@@ -81,15 +82,17 @@ into help buttons that call `describe-text-category' or
     (let ((key (nth 0 elt))
          (value (nth 1 elt)))
       (insert (propertize (format "  %-20s " key)
-                         'face 'italic))
+                         'face 'help-argument-name))
       (cond ((eq key 'category)
-            (insert-text-button (symbol-name value)
-                                'action `(lambda (&rest ignore)
-                                           (describe-text-category ',value))
-                                'help-echo
-                                "mouse-2, RET: describe this category"))
+            (insert-text-button
+             (symbol-name value)
+             'action `(lambda (&rest ignore)
+                        (describe-text-category ',value))
+             'help-echo "mouse-2, RET: describe this category"))
             ((memq key '(face font-lock-face mouse-face))
-            (insert (concat "`" (format "%S" value) "'")))
+            (insert-text-button
+             (format "%S" value)
+             'type 'help-face 'help-args (list value)))
             ((widgetp value)
             (describe-text-widget value))
            (t
@@ -100,7 +103,8 @@ into help buttons that call `describe-text-category' or
 
 (defun describe-text-category (category)
   "Describe a text property category."
-  (interactive "S")
+  (interactive "SCategory: ")
+  (help-setup-xref (list #'describe-text-category category) (interactive-p))
   (save-excursion
     (with-output-to-temp-buffer "*Help*"
       (set-buffer standard-output)
@@ -159,8 +163,8 @@ otherwise."
       ;; Buttons
       (when (and button (not (widgetp wid-button)))
        (newline)
-       (insert "Here is a " (format "%S" button-type)
-               " button labeled `" button-label "'.\n\n"))
+       (insert "Here is a `" (format "%S" button-type)
+               "' button labeled `" button-label "'.\n\n"))
       ;; Overlays
       (when overlays
        (newline)
@@ -181,13 +185,13 @@ otherwise."
 \f
 (defcustom describe-char-unicodedata-file nil
   "Location of Unicode data file.
-This is the UnicodeData.txt file from the Unicode consortium, used for
+This is the UnicodeData.txt file from the Unicode Consortium, used for
 diagnostics.  If it is non-nil `describe-char' will print data
 looked up from it.  This facility is mostly of use to people doing
 multilingual development.
 
-This is a fairly large file, not typically present on GNU systems.  At
-the time of writing it is at the URL
+This is a fairly large file, not typically present on GNU systems.
+At the time of writing it is at the URL
 `http://www.unicode.org/Public/UNIDATA/UnicodeData.txt'."
   :group 'mule
   :version "22.1"
@@ -208,11 +212,10 @@ The list is null if CHAR isn't found in `describe-char-unicodedata-file'."
   (when describe-char-unicodedata-file
     (unless (file-exists-p describe-char-unicodedata-file)
       (error "`unicodedata-file' %s not found" describe-char-unicodedata-file))
-    (with-current-buffer
-       ;; Find file in fundamental mode to avoid, e.g. flyspell turned
-       ;; on for .txt.  Don't use RAWFILE arg in case of DOS line endings.
-       (let ((auto-mode-alist))
-         (find-file-noselect describe-char-unicodedata-file))
+    (with-current-buffer (get-buffer-create " *Unicode Data*")
+      (when (zerop (buffer-size))
+       ;; Don't use -literally in case of DOS line endings.
+       (insert-file-contents describe-char-unicodedata-file))
       (goto-char (point-min))
       (let ((hex (format "%04X" char))
            found first last)
@@ -428,13 +431,13 @@ as well as widgets, buttons, overlays, and text properties."
                                 (single-key-description char)
                               (string-to-multibyte
                                (char-to-string char)))))
-         (text-props-desc
-          (let ((tmp-buf (generate-new-buffer " *text-props*")))
-            (unwind-protect
-                (progn
-                  (describe-text-properties pos tmp-buf)
-                  (with-current-buffer tmp-buf (buffer-string)))
-              (kill-buffer tmp-buf))))
+        (text-props-desc
+         (let ((tmp-buf (generate-new-buffer " *text-props*")))
+           (unwind-protect
+               (progn
+                 (describe-text-properties pos tmp-buf)
+                 (with-current-buffer tmp-buf (buffer-string)))
+             (kill-buffer tmp-buf))))
         item-list max-width unicode)
 
     (if (or (< char 256)
@@ -444,36 +447,36 @@ as well as widgets, buttons, overlays, and text properties."
                          (encode-char char 'ucs))))
     (setq item-list
          `(("character"
-           ,(format "%s (%d, #o%o, #x%x%s)"
-                    (apply 'propertize char-description
-                           (text-properties-at pos))
-                    char char char
-                    (if unicode
-                        (format ", U+%04X" unicode)
-                      "")))
+            ,(format "%s (%d, #o%o, #x%x%s)"
+                     (apply 'propertize char-description
+                            (text-properties-at pos))
+                     char char char
+                     (if unicode
+                         (format ", U+%04X" unicode)
+                       "")))
            ("charset"
             ,`(insert-text-button
-               (symbol-name charset)
-               'action `(lambda (&rest ignore)
-                          (describe-character-set ',charset))
-               'help-echo
-               "mouse-2, RET: describe this character set")
+               ,(symbol-name charset)
+               'type 'help-character-set 'help-args '(,charset))
             ,(format "(%s)" (charset-description charset)))
            ("code point"
             ,(let ((split (split-char char)))
-               `(insert-text-button ,(if (= (charset-dimension charset) 1)
-                                         (format "%d" (nth 1 split))
-                                       (format "%d %d" (nth 1 split)
-                                               (nth 2 split)))
-                'action (lambda (&rest ignore)
-                          (list-charset-chars ',charset)
-                          (with-selected-window
-                              (get-buffer-window "*Character List*" 0)
-                            (goto-char (point-min))
-                              (forward-line 2) ;Skip the header.
-                              (let ((case-fold-search nil))
-                                (search-forward ,(char-to-string char)
-                                                nil t)))))))
+               `(insert-text-button
+                 ,(if (= (charset-dimension charset) 1)
+                      (format "#x%02X" (nth 1 split))
+                    (format "#x%02X #x%02X" (nth 1 split)
+                            (nth 2 split)))
+                 'action (lambda (&rest ignore)
+                           (list-charset-chars ',charset)
+                           (with-selected-window
+                               (get-buffer-window "*Character List*" 0)
+                             (goto-char (point-min))
+                             (forward-line 2) ;Skip the header.
+                             (let ((case-fold-search nil))
+                               (search-forward ,(char-to-string char)
+                                               nil t))))
+                 'help-echo
+                 "mouse-2, RET: show this character in its character set")))
            ("syntax"
             ,(let ((syntax (syntax-after pos)))
                (with-temp-buffer
@@ -503,10 +506,9 @@ as well as widgets, buttons, overlays, and text properties."
                                      key-list " or ")
                           "with"
                           `(insert-text-button
-                            (symbol-name current-input-method)
-                            'action (lambda (&rest ignore)
-                                      (describe-input-method
-                                       ',current-input-method)))))))
+                            ,current-input-method
+                            'type 'help-input-method
+                            'help-args '(,current-input-method))))))
            ("buffer code"
             ,(encoded-string-description
               (string-as-unibyte (char-to-string char)) nil))
@@ -526,11 +528,11 @@ as well as widgets, buttons, overlays, and text properties."
                  (setq char (aref disp-vector i))
                  (aset disp-vector i
                        (cons char (describe-char-display
-                                   pos (logand char #x7ffff)))))
+                                   pos (glyph-char char)))))
                (format "by display table entry [%s] (see below)"
                        (mapconcat
                         #'(lambda (x)
-                            (format "?%c" (logand (car x) #x7ffff)))
+                            (format "?%c" (glyph-char (car x))))
                         disp-vector " ")))
               (composition
                (let ((from (car composition))
@@ -575,8 +577,9 @@ as well as widgets, buttons, overlays, and text properties."
                          ((and (< char 32) (not (memq char '(9 10))))
                           'escape-glyph)))))
                (if face (list (list "hardcoded face"
-                                    '(insert
-                                      (concat "`" (symbol-name face) "'"))))))
+                                    `(insert-text-button
+                                      ,(symbol-name face)
+                                      'type 'help-face 'help-args '(,face))))))
            ,@(let ((unicodedata (and unicode
                                      (describe-char-unicode-data unicode))))
                (if unicodedata
@@ -624,25 +627,19 @@ as well as widgets, buttons, overlays, and text properties."
              (progn
                (insert "these fonts (glyph codes):\n")
                (dotimes (i (length disp-vector))
-                 (insert (logand (car (aref disp-vector i)) #x7ffff) ?:
+                 (insert (glyph-char (car (aref disp-vector i))) ?:
                          (propertize " " 'display '(space :align-to 5))
                          (if (cdr (aref disp-vector i))
                              (format "%s (#x%02X)" (cadr (aref disp-vector i))
                                      (cddr (aref disp-vector i)))
                            "-- no font --")
                          "\n")
-                 (when (> (car (aref disp-vector i)) #x7ffff)
-                   (let* ((face-id (lsh (car (aref disp-vector i)) -19))
-                          (face (car (delq nil (mapcar
-                                                (lambda (face)
-                                                  (and (eq (face-id face)
-                                                           face-id) face))
-                                                (face-list))))))
-                     (when face
-                       (insert (propertize " " 'display '(space :align-to 5))
-                               "face: ")
-                       (insert (concat "`" (symbol-name face) "'"))
-                       (insert "\n"))))))
+                 (let ((face (glyph-face (car (aref disp-vector i)))))
+                   (when face
+                     (insert (propertize " " 'display '(space :align-to 5))
+                             "face: ")
+                     (insert (concat "`" (symbol-name face) "'"))
+                     (insert "\n")))))
            (insert "these terminal codes:\n")
            (dotimes (i (length disp-vector))
              (insert (car (aref disp-vector i))
@@ -687,6 +684,7 @@ as well as widgets, buttons, overlays, and text properties."
                  "the meaning of the rule.\n"))
 
         (if text-props-desc (insert text-props-desc))
+       (setq help-xref-stack-item (list 'help-insert-string (buffer-string)))
        (toggle-read-only 1)
        (print-help-return-message)))))