emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: describe-char


From: Juri Linkov
Subject: Re: describe-char
Date: Fri, 23 Dec 2005 19:42:32 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

> Yes, but I think we're saying that to keep things simple, it should be done
> with help buttons not widgets.

That's good news that now descr-text.el uses help buttons instead of widgets.
Thanks, Nick.

Now finally it is possible to fix an old problem where going back
to the previous topic in the xref stack in the help buffer didn't
restore the old contents of the buffer created by `C-u C-x ='.
I propose the following patch that stores the contents of such help
buffer as text and puts it with a new special function help-insert-string
on the xref stack.

This patch also fixes the xref stack for the command `describe-text-category';
replaces the `action' keyword of some help buttons with the `type' keyword
with predefined types; uses the face `help-argument-name' instead of `italic'
for key names, and other minor fixes.

Index: lisp/help-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/help-mode.el,v
retrieving revision 1.41
diff -c -r1.41 help-mode.el
*** lisp/help-mode.el   20 Dec 2005 09:02:23 -0000      1.41
--- lisp/help-mode.el   23 Dec 2005 17:31:44 -0000
***************
*** 648,653 ****
--- 652,666 ----
                (fboundp sym) (facep sym))
        (help-do-xref pos #'help-xref-interned (list sym))))))
  
+ (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
+ when going back to the previous topic in the xref stack.  It is needed
+ in case when it is impossible to recompute the old contents of the
+ help buffer by other means."
+   (help-setup-xref (list #'help-insert-string string) (interactive-p))
+   (with-output-to-temp-buffer (help-buffer)
+     (insert string)))
  
  (provide 'help-mode)
  
Index: lisp/descr-text.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/descr-text.el,v
retrieving revision 1.46
diff -c -r1.46 descr-text.el
*** lisp/descr-text.el  23 Dec 2005 01:51:44 -0000      1.46
--- lisp/descr-text.el  23 Dec 2005 17:33:27 -0000
***************
*** 30,36 ****
  
  ;;; Code:
  
! (eval-when-compile (require 'button) (require 'quail))
  
  ;;; Describe-Text Utilities.
  
--- 30,37 ----
  
  ;;; Code:
  
! (eval-when-compile (require 'quail))
! (require 'help-fns)
  
  ;;; Describe-Text Utilities.
  
***************
*** 39,49 ****
    (insert-text-button
     (symbol-name (if (symbolp widget) widget (car widget)))
     'action `(lambda (&rest ignore)
!             (widget-browse ',widget)))
    (insert " ")
!   (insert-text-button "(widget)Top"
!                     'action (lambda (&rest ignore) (info "(widget)Top"))
!                     'help-echo "mouse-2, RET: read this Info node"))
  
  (defun describe-text-sexp (sexp)
    "Insert a short description of SEXP in the current buffer."
--- 40,50 ----
    (insert-text-button
     (symbol-name (if (symbolp widget) widget (car widget)))
     'action `(lambda (&rest ignore)
!             (widget-browse ',widget))
!    'help-echo "mouse-2, RET: browse this widget")
    (insert " ")
!   (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."
***************
*** 81,93 ****
      (let ((key (nth 0 elt))
          (value (nth 1 elt)))
        (insert (propertize (format "  %-20s " key)
!                         'face 'italic))
        (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"))
              ((memq key '(face font-lock-face mouse-face))
             (insert (concat "`" (format "%S" value) "'")))
              ((widgetp value)
--- 82,94 ----
      (let ((key (nth 0 elt))
          (value (nth 1 elt)))
        (insert (propertize (format "  %-20s " key)
!                         '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"))
              ((memq key '(face font-lock-face mouse-face))
             (insert (concat "`" (format "%S" value) "'")))
              ((widgetp value)
***************
*** 100,106 ****
  
  (defun describe-text-category (category)
    "Describe a text property category."
!   (interactive "S")
    (save-excursion
      (with-output-to-temp-buffer "*Help*"
        (set-buffer standard-output)
--- 101,108 ----
  
  (defun describe-text-category (category)
    "Describe a text property category."
!   (interactive "SCategory: ")
!   (help-setup-xref (list #'describe-text-category category) (interactive-p))
    (save-excursion
      (with-output-to-temp-buffer "*Help*"
        (set-buffer standard-output)
***************
*** 453,479 ****
                       "")))
            ("charset"
             ,`(insert-text-button
!               (symbol-name charset)
!               'action `(lambda (&rest ignore)
!                          (describe-character-set ',charset))
!               'help-echo
!               "mouse-2, RET: describe this character set")
             ,(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)))))))
            ("syntax"
             ,(let ((syntax (syntax-after pos)))
                (with-temp-buffer
--- 455,480 ----
                       "")))
            ("charset"
             ,`(insert-text-button
!               ,(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))))
!                 'help-echo
!                 "mouse-2, RET: Show this character in its character set")))
            ("syntax"
             ,(let ((syntax (syntax-after pos)))
                (with-temp-buffer
***************
*** 503,512 ****
                                      key-list " or ")
                           "with"
                           `(insert-text-button
!                            (symbol-name current-input-method)
!                            'action (lambda (&rest ignore)
!                                      (describe-input-method
!                                       ',current-input-method)))))))
            ("buffer code"
             ,(encoded-string-description
               (string-as-unibyte (char-to-string char)) nil))
--- 504,512 ----
                                      key-list " or ")
                           "with"
                           `(insert-text-button
!                            ,(symbol-name 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))
***************
*** 575,582 ****
                          ((and (< char 32) (not (memq char '(9 10))))
                           'escape-glyph)))))
                (if face (list (list "hardcoded face"
!                                    '(insert
!                                      (concat "`" (symbol-name face) "'"))))))
            ,@(let ((unicodedata (and unicode
                                      (describe-char-unicode-data unicode))))
                (if unicodedata
--- 575,581 ----
                          ((and (< char 32) (not (memq char '(9 10))))
                           'escape-glyph)))))
                (if face (list (list "hardcoded face"
!                                    (concat "`" (symbol-name face) "'")))))
            ,@(let ((unicodedata (and unicode
                                      (describe-char-unicode-data unicode))))
                (if unicodedata
***************
*** 687,692 ****
--- 686,692 ----
                  "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)))))

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]