diff lisp/descr-text.el @ 4480:74caf140505b

Wrap field descriptions, descr-text.el; name created buffer more uniquely. 2008-07-19 Aidan Kehoe <kehoea@parhasard.net> * descr-text.el (describe-property-list): Move the (require 'hyper-apropos) call to top level, this isn't the only function that uses the relevant face. (describe-char): Wrap the Unihan field descriptions if they are longer than the windows width minus 50. Rename the created buffer to reflect the character's position as well as its value.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 19 Jul 2008 15:19:59 +0200
parents 78738a40e31e
children f9c70d94f427
line wrap: on
line diff
--- a/lisp/descr-text.el	Thu Jul 17 22:50:22 2008 +0200
+++ b/lisp/descr-text.el	Sat Jul 19 15:19:59 2008 +0200
@@ -32,6 +32,8 @@
 
 (eval-when-compile (require 'wid-edit))
 
+(require 'hyper-apropos)
+
 ;;; Describe-Text Utilities.
 
 (defun describe-text-widget (widget)
@@ -82,7 +84,6 @@
 into help buttons that call `describe-text-category' or
 `describe-face' when pushed."
   ;; Sort the properties by the size of their value.
-  (require 'hyper-apropos)
   (dolist (elt (sort (let (ret)
 		       (while properties
 			 (push (list (pop properties) (pop properties)) ret))
@@ -1029,7 +1030,8 @@
 		  (describe-text-properties pos tmp-buf)
 		  (with-current-buffer tmp-buf (buffer-string)))
 	      (kill-buffer tmp-buf))))
-	 item-list max-width unicode unicode-formatted unicode-error)
+	 item-list max-width unicode unicode-formatted unicode-error
+	 unicodedata (max-unicode-description-width (- (window-width) 50)))
 
 
     (setq unicode-error
@@ -1185,13 +1187,29 @@
 				     `(insert-gui-button
                                        (make-gui-button
                                         ,(symbol-name face)))))))
-	    ,@(let ((unicodedata (and unicode
-				      (describe-char-unicode-data unicode))))
+	    ,@(progn 
+		(setq unicodedata (and unicode
+				       (describe-char-unicode-data unicode)))
 		(if unicodedata
 		    (cons (list "Unicode data" " ") unicodedata)))))
     (setq max-width (apply #'max (mapcar #'(lambda (x)
 					     (if (cadr x) (length (car x)) 0))
 					 item-list)))
+    (when (and unicodedata (> max-width max-unicode-description-width))
+      (setq max-width max-unicode-description-width)
+      (with-temp-buffer
+	(let ((fill-column max-unicode-description-width)
+	      (indent-tabs-mode nil))
+	  (dolist (unidata-line unicodedata)
+	    (when (cadr unidata-line)
+	      (setf (car unidata-line)
+		    (progn (insert (car unidata-line))
+			   (goto-char (point-min))
+			   (fill-paragraph 'right)
+			   (delete-region (1- (point-max))
+					  (point-max))
+			   (buffer-string)))
+	      (delete-region (point-min) (point-max)))))))
     ; (help-setup-xref nil (interactive-p))
     (with-displaying-help-buffer
      (lambda ()
@@ -1274,7 +1292,7 @@
 ;        (setq help-xref-stack-item (list 'help-insert-string (buffer-string)))
          (toggle-read-only 1)
          (print-help-return-message)))
-     (format "Describe %c" (char-after pos)))))
+       (format "Describe %c <%d>" (char-after pos) pos))))
 
 (defalias 'describe-char-after 'describe-char)
 (make-obsolete 'describe-char-after 'describe-char "22.1")