diff options
| author | Nick Roberts | 2005-12-26 11:41:22 +0000 |
|---|---|---|
| committer | Nick Roberts | 2005-12-26 11:41:22 +0000 |
| commit | e5a5c80cd5bb81a2319532a2254b8f5088ccf0ad (patch) | |
| tree | 8d3b5ae50ccd12fa5c6475ad7581cac5a69fea6c /lisp | |
| parent | 0932395f4ab3e18891479fcdb545346f29d76de4 (diff) | |
| download | emacs-e5a5c80cd5bb81a2319532a2254b8f5088ccf0ad.tar.gz emacs-e5a5c80cd5bb81a2319532a2254b8f5088ccf0ad.zip | |
2005-12-27 Nick Roberts <nickrob@snap.net.nz>
* descr-text.el (describe-char): Add optional argument for buffer.
Set buffer appropriately. Call help-setup-xref.
Suggested by Stefan Monnier.
2005-12-27 Juri Linkov <juri@jurta.org>
* descr-text.el (help-fns): Require. Don't require button for
byte compilation.
(describe-text-widget): Add help echo for first button. Use
'help-info for second.
(describe-property-list): Use 'help-argument-name instead of 'italic.
(describe-text-category): Prompt in minibuffer. Call help-setup-xref.
(describe-char): Use 'help-character-set. Add help echo. Use
'help-input-method. Remove superfluous insert.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/descr-text.el | 112 |
1 files changed, 58 insertions, 54 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 76d6ae6be09..663ec8dffeb 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el | |||
| @@ -30,7 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (eval-when-compile (require 'button) (require 'quail)) | 33 | (eval-when-compile (require 'quail)) |
| 34 | (require 'help-fns) | ||
| 34 | 35 | ||
| 35 | ;;; Describe-Text Utilities. | 36 | ;;; Describe-Text Utilities. |
| 36 | 37 | ||
| @@ -39,11 +40,11 @@ | |||
| 39 | (insert-text-button | 40 | (insert-text-button |
| 40 | (symbol-name (if (symbolp widget) widget (car widget))) | 41 | (symbol-name (if (symbolp widget) widget (car widget))) |
| 41 | 'action `(lambda (&rest ignore) | 42 | 'action `(lambda (&rest ignore) |
| 42 | (widget-browse ',widget))) | 43 | (widget-browse ',widget)) |
| 44 | 'help-echo "mouse-2, RET: browse this widget") | ||
| 43 | (insert " ") | 45 | (insert " ") |
| 44 | (insert-text-button "(widget)Top" | 46 | (insert-text-button |
| 45 | 'action (lambda (&rest ignore) (info "(widget)Top")) | 47 | "(widget)Top" 'type 'help-info 'help-args '("(widget)Top"))) |
| 46 | 'help-echo "mouse-2, RET: read this Info node")) | ||
| 47 | 48 | ||
| 48 | (defun describe-text-sexp (sexp) | 49 | (defun describe-text-sexp (sexp) |
| 49 | "Insert a short description of SEXP in the current buffer." | 50 | "Insert a short description of SEXP in the current buffer." |
| @@ -81,13 +82,13 @@ into help buttons that call `describe-text-category' or | |||
| 81 | (let ((key (nth 0 elt)) | 82 | (let ((key (nth 0 elt)) |
| 82 | (value (nth 1 elt))) | 83 | (value (nth 1 elt))) |
| 83 | (insert (propertize (format " %-20s " key) | 84 | (insert (propertize (format " %-20s " key) |
| 84 | 'face 'italic)) | 85 | 'face 'help-argument-name)) |
| 85 | (cond ((eq key 'category) | 86 | (cond ((eq key 'category) |
| 86 | (insert-text-button (symbol-name value) | 87 | (insert-text-button |
| 87 | 'action `(lambda (&rest ignore) | 88 | (symbol-name value) |
| 88 | (describe-text-category ',value)) | 89 | 'action `(lambda (&rest ignore) |
| 89 | 'help-echo | 90 | (describe-text-category ',value)) |
| 90 | "mouse-2, RET: describe this category")) | 91 | 'help-echo "mouse-2, RET: describe this category")) |
| 91 | ((memq key '(face font-lock-face mouse-face)) | 92 | ((memq key '(face font-lock-face mouse-face)) |
| 92 | (insert (concat "`" (format "%S" value) "'"))) | 93 | (insert (concat "`" (format "%S" value) "'"))) |
| 93 | ((widgetp value) | 94 | ((widgetp value) |
| @@ -100,7 +101,8 @@ into help buttons that call `describe-text-category' or | |||
| 100 | 101 | ||
| 101 | (defun describe-text-category (category) | 102 | (defun describe-text-category (category) |
| 102 | "Describe a text property category." | 103 | "Describe a text property category." |
| 103 | (interactive "S") | 104 | (interactive "SCategory: ") |
| 105 | (help-setup-xref (list #'describe-text-category category) (interactive-p)) | ||
| 104 | (save-excursion | 106 | (save-excursion |
| 105 | (with-output-to-temp-buffer "*Help*" | 107 | (with-output-to-temp-buffer "*Help*" |
| 106 | (set-buffer standard-output) | 108 | (set-buffer standard-output) |
| @@ -402,13 +404,15 @@ character)") | |||
| 402 | 404 | ||
| 403 | 405 | ||
| 404 | ;;;###autoload | 406 | ;;;###autoload |
| 405 | (defun describe-char (pos) | 407 | (defun describe-char (pos &optional buf) |
| 406 | "Describe the character after POS (interactively, the character after point). | 408 | "Describe the character after POS (interactively, the character after point). |
| 407 | The information includes character code, charset and code points in it, | 409 | The information includes character code, charset and code points in it, |
| 408 | syntax, category, how the character is encoded in a file, | 410 | syntax, category, how the character is encoded in a file, |
| 409 | character composition information (if relevant), | 411 | character composition information (if relevant), |
| 410 | as well as widgets, buttons, overlays, and text properties." | 412 | as well as widgets, buttons, overlays, and text properties." |
| 411 | (interactive "d") | 413 | (interactive "d") |
| 414 | (let ((help-buffer (help-buffer))) | ||
| 415 | (with-current-buffer (if buf buf (current-buffer)) | ||
| 412 | (if (>= pos (point-max)) | 416 | (if (>= pos (point-max)) |
| 413 | (error "No character follows specified position")) | 417 | (error "No character follows specified position")) |
| 414 | (let* ((char (char-after pos)) | 418 | (let* ((char (char-after pos)) |
| @@ -428,13 +432,13 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 428 | (single-key-description char) | 432 | (single-key-description char) |
| 429 | (string-to-multibyte | 433 | (string-to-multibyte |
| 430 | (char-to-string char))))) | 434 | (char-to-string char))))) |
| 431 | (text-props-desc | 435 | (text-props-desc |
| 432 | (let ((tmp-buf (generate-new-buffer " *text-props*"))) | 436 | (let ((tmp-buf (generate-new-buffer " *text-props*"))) |
| 433 | (unwind-protect | 437 | (unwind-protect |
| 434 | (progn | 438 | (progn |
| 435 | (describe-text-properties pos tmp-buf) | 439 | (describe-text-properties pos tmp-buf) |
| 436 | (with-current-buffer tmp-buf (buffer-string))) | 440 | (with-current-buffer tmp-buf (buffer-string))) |
| 437 | (kill-buffer tmp-buf)))) | 441 | (kill-buffer tmp-buf)))) |
| 438 | item-list max-width unicode) | 442 | item-list max-width unicode) |
| 439 | 443 | ||
| 440 | (if (or (< char 256) | 444 | (if (or (< char 256) |
| @@ -444,36 +448,36 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 444 | (encode-char char 'ucs)))) | 448 | (encode-char char 'ucs)))) |
| 445 | (setq item-list | 449 | (setq item-list |
| 446 | `(("character" | 450 | `(("character" |
| 447 | ,(format "%s (%d, #o%o, #x%x%s)" | 451 | ,(format "%s (%d, #o%o, #x%x%s)" |
| 448 | (apply 'propertize char-description | 452 | (apply 'propertize char-description |
| 449 | (text-properties-at pos)) | 453 | (text-properties-at pos)) |
| 450 | char char char | 454 | char char char |
| 451 | (if unicode | 455 | (if unicode |
| 452 | (format ", U+%04X" unicode) | 456 | (format ", U+%04X" unicode) |
| 453 | ""))) | 457 | ""))) |
| 454 | ("charset" | 458 | ("charset" |
| 455 | ,`(insert-text-button | 459 | ,`(insert-text-button |
| 456 | (symbol-name charset) | 460 | ,(symbol-name charset) |
| 457 | 'action `(lambda (&rest ignore) | 461 | 'type 'help-character-set 'help-args '(,charset)) |
| 458 | (describe-character-set ',charset)) | ||
| 459 | 'help-echo | ||
| 460 | "mouse-2, RET: describe this character set") | ||
| 461 | ,(format "(%s)" (charset-description charset))) | 462 | ,(format "(%s)" (charset-description charset))) |
| 462 | ("code point" | 463 | ("code point" |
| 463 | ,(let ((split (split-char char))) | 464 | ,(let ((split (split-char char))) |
| 464 | `(insert-text-button ,(if (= (charset-dimension charset) 1) | 465 | `(insert-text-button |
| 465 | (format "%d" (nth 1 split)) | 466 | ,(if (= (charset-dimension charset) 1) |
| 466 | (format "%d %d" (nth 1 split) | 467 | (format "%d" (nth 1 split)) |
| 467 | (nth 2 split))) | 468 | (format "%d %d" (nth 1 split) |
| 468 | 'action (lambda (&rest ignore) | 469 | (nth 2 split))) |
| 469 | (list-charset-chars ',charset) | 470 | 'action (lambda (&rest ignore) |
| 470 | (with-selected-window | 471 | (list-charset-chars ',charset) |
| 471 | (get-buffer-window "*Character List*" 0) | 472 | (with-selected-window |
| 472 | (goto-char (point-min)) | 473 | (get-buffer-window "*Character List*" 0) |
| 473 | (forward-line 2) ;Skip the header. | 474 | (goto-char (point-min)) |
| 474 | (let ((case-fold-search nil)) | 475 | (forward-line 2) ;Skip the header. |
| 475 | (search-forward ,(char-to-string char) | 476 | (let ((case-fold-search nil)) |
| 476 | nil t))))))) | 477 | (search-forward ,(char-to-string char) |
| 478 | nil t)))) | ||
| 479 | 'help-echo | ||
| 480 | "mouse-2, RET: show this character in its character set"))) | ||
| 477 | ("syntax" | 481 | ("syntax" |
| 478 | ,(let ((syntax (syntax-after pos))) | 482 | ,(let ((syntax (syntax-after pos))) |
| 479 | (with-temp-buffer | 483 | (with-temp-buffer |
| @@ -503,10 +507,9 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 503 | key-list " or ") | 507 | key-list " or ") |
| 504 | "with" | 508 | "with" |
| 505 | `(insert-text-button | 509 | `(insert-text-button |
| 506 | (symbol-name current-input-method) | 510 | ,(symbol-name current-input-method) |
| 507 | 'action (lambda (&rest ignore) | 511 | 'type 'help-input-method |
| 508 | (describe-input-method | 512 | 'help-args '(,current-input-method)))))) |
| 509 | ',current-input-method))))))) | ||
| 510 | ("buffer code" | 513 | ("buffer code" |
| 511 | ,(encoded-string-description | 514 | ,(encoded-string-description |
| 512 | (string-as-unibyte (char-to-string char)) nil)) | 515 | (string-as-unibyte (char-to-string char)) nil)) |
| @@ -575,8 +578,7 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 575 | ((and (< char 32) (not (memq char '(9 10)))) | 578 | ((and (< char 32) (not (memq char '(9 10)))) |
| 576 | 'escape-glyph))))) | 579 | 'escape-glyph))))) |
| 577 | (if face (list (list "hardcoded face" | 580 | (if face (list (list "hardcoded face" |
| 578 | '(insert | 581 | (concat "`" (symbol-name face) "'"))))) |
| 579 | (concat "`" (symbol-name face) "'")))))) | ||
| 580 | ,@(let ((unicodedata (and unicode | 582 | ,@(let ((unicodedata (and unicode |
| 581 | (describe-char-unicode-data unicode)))) | 583 | (describe-char-unicode-data unicode)))) |
| 582 | (if unicodedata | 584 | (if unicodedata |
| @@ -584,8 +586,10 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 584 | (setq max-width (apply #'max (mapcar #'(lambda (x) | 586 | (setq max-width (apply #'max (mapcar #'(lambda (x) |
| 585 | (if (cadr x) (length (car x)) 0)) | 587 | (if (cadr x) (length (car x)) 0)) |
| 586 | item-list))) | 588 | item-list))) |
| 587 | (help-setup-xref nil (interactive-p)) | 589 | (help-setup-xref |
| 588 | (with-output-to-temp-buffer (help-buffer) | 590 | (list #'describe-char pos (if buf buf (current-buffer))) |
| 591 | (interactive-p)) | ||
| 592 | (with-output-to-temp-buffer help-buffer | ||
| 589 | (with-current-buffer standard-output | 593 | (with-current-buffer standard-output |
| 590 | (set-buffer-multibyte multibyte-p) | 594 | (set-buffer-multibyte multibyte-p) |
| 591 | (let ((formatter (format "%%%ds:" max-width))) | 595 | (let ((formatter (format "%%%ds:" max-width))) |
| @@ -688,7 +692,7 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 688 | 692 | ||
| 689 | (if text-props-desc (insert text-props-desc)) | 693 | (if text-props-desc (insert text-props-desc)) |
| 690 | (toggle-read-only 1) | 694 | (toggle-read-only 1) |
| 691 | (print-help-return-message))))) | 695 | (print-help-return-message))))))) |
| 692 | 696 | ||
| 693 | (defalias 'describe-char-after 'describe-char) | 697 | (defalias 'describe-char-after 'describe-char) |
| 694 | (make-obsolete 'describe-char-after 'describe-char "22.1") | 698 | (make-obsolete 'describe-char-after 'describe-char "22.1") |