diff options
| author | Kenichi Handa | 2005-02-22 06:23:01 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2005-02-22 06:23:01 +0000 |
| commit | ca69e8aabeeba37402a88a5d05e8a727af2f566e (patch) | |
| tree | 9def0e17829860e77bbf99fc3a6c11cc0e83522b | |
| parent | b77ba60f8cba4184abd40c951f2c0efaf9e44e76 (diff) | |
| download | emacs-ca69e8aabeeba37402a88a5d05e8a727af2f566e.tar.gz emacs-ca69e8aabeeba37402a88a5d05e8a727af2f566e.zip | |
(ps-mule-header-string-charsets): Delete it.
(ps-mule-show-warning): New function.
(ps-mule-begin-job): Use ps-mule-show-warning if unprintable
characters are found.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/ps-mule.el | 162 |
2 files changed, 110 insertions, 62 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dd1bc36f284..d906c3d8efe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2005-02-22 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * ps-mule.el (ps-mule-header-string-charsets): Delete it. | ||
| 4 | (ps-mule-show-warning): New function. | ||
| 5 | (ps-mule-begin-job): Use ps-mule-show-warning if unprintable | ||
| 6 | characters are found. | ||
| 7 | |||
| 8 | * ps-print.el (ps-header-footer-string): Return a list of header | ||
| 9 | and footer strings. | ||
| 10 | |||
| 1 | 2005-02-21 Wolfgang Jenkner <wjenkner@inode.at> (tiny change) | 11 | 2005-02-21 Wolfgang Jenkner <wjenkner@inode.at> (tiny change) |
| 2 | 12 | ||
| 3 | * pcvs.el (cvs-retrieve-revision): Fix thinko. | 13 | * pcvs.el (cvs-retrieve-revision): Fix thinko. |
diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el index ec7b3b22fca..6f14538ff4d 100644 --- a/lisp/ps-mule.el +++ b/lisp/ps-mule.el | |||
| @@ -1390,20 +1390,60 @@ FONTTAG should be a string \"/h0\" or \"/h1\"." | |||
| 1390 | (setq string (ps-mule-string-encoding font-spec string nil t)))))) | 1390 | (setq string (ps-mule-string-encoding font-spec string nil t)))))) |
| 1391 | string) | 1391 | string) |
| 1392 | 1392 | ||
| 1393 | ;;;###autoload | 1393 | (defun ps-mule-show-warning (charsets from to header-footer-list) |
| 1394 | (defun ps-mule-header-string-charsets () | 1394 | (let ((table (make-category-table)) |
| 1395 | "Return a list of character sets that appears in header strings." | 1395 | (buf (current-buffer)) |
| 1396 | (let* ((str (ps-header-footer-string)) | 1396 | char-pos-list) |
| 1397 | (len (length str)) | 1397 | (define-category ?u "Unprintable charset" table) |
| 1398 | (i 0) | 1398 | (dolist (cs charsets) |
| 1399 | charset-list) | 1399 | (modify-category-entry (make-char cs) ?u table)) |
| 1400 | (while (< i len) | 1400 | (with-category-table table |
| 1401 | (let ((charset (char-charset (aref str i)))) | 1401 | (save-excursion |
| 1402 | (setq i (1+ i)) | 1402 | (goto-char from) |
| 1403 | (or (eq charset 'ascii) | 1403 | (while (and (< (length char-pos-list) 20) |
| 1404 | (memq charset charset-list) | 1404 | (re-search-forward "\\cu" to t)) |
| 1405 | (setq charset-list (cons charset charset-list))))) | 1405 | (push (cons (preceding-char) (1- (point))) char-pos-list)) |
| 1406 | charset-list)) | 1406 | (setq char-pos-list (nreverse char-pos-list)))) |
| 1407 | (with-output-to-temp-buffer "*Warning*" | ||
| 1408 | (with-current-buffer standard-output | ||
| 1409 | (when char-pos-list | ||
| 1410 | (let ((func #'(lambda (buf pos) | ||
| 1411 | (when (buffer-live-p buf) | ||
| 1412 | (pop-to-buffer buf) | ||
| 1413 | (goto-char pos))))) | ||
| 1414 | (insert "These characters in the buffer can't be printed:\n") | ||
| 1415 | (dolist (elt char-pos-list) | ||
| 1416 | (insert " ") | ||
| 1417 | (insert-text-button (string (car elt)) | ||
| 1418 | :type 'help-xref | ||
| 1419 | 'help-echo | ||
| 1420 | "mouse-2, RET: jump to this character" | ||
| 1421 | 'help-function func | ||
| 1422 | 'help-args (list buf (cdr elt))) | ||
| 1423 | (insert ",")) | ||
| 1424 | ;; Delete the last comma. | ||
| 1425 | (delete-char -1) | ||
| 1426 | (insert "\nClick them to jump to the buffer position,\n" | ||
| 1427 | (substitute-command-keys "\ | ||
| 1428 | or \\[universal-argument] \\[what-cursor-position] will give information about them.\n")))) | ||
| 1429 | |||
| 1430 | (with-category-table table | ||
| 1431 | (let (string-list idx) | ||
| 1432 | (dolist (elt header-footer-list) | ||
| 1433 | (when (stringp elt) | ||
| 1434 | (when (string-match "\\cu+" elt) | ||
| 1435 | (setq elt (copy-sequence elt)) | ||
| 1436 | (put-text-property (match-beginning 0) (match-end 0) | ||
| 1437 | 'face 'highlight elt) | ||
| 1438 | (while (string-match "\\cu+" elt (match-end 0)) | ||
| 1439 | (put-text-property (match-beginning 0) (match-end 0) | ||
| 1440 | 'face 'highlight elt)) | ||
| 1441 | (push elt string-list)))) | ||
| 1442 | (when string-list | ||
| 1443 | (insert | ||
| 1444 | "These highlighted characters in header/footer can't be printed:\n") | ||
| 1445 | (dolist (elt string-list) | ||
| 1446 | (insert " " elt "\n"))))))))) | ||
| 1407 | 1447 | ||
| 1408 | ;;;###autoload | 1448 | ;;;###autoload |
| 1409 | (defun ps-mule-begin-job (from to) | 1449 | (defun ps-mule-begin-job (from to) |
| @@ -1424,58 +1464,55 @@ This checks if all multi-byte characters in the region are printable or not." | |||
| 1424 | enable-multibyte-characters | 1464 | enable-multibyte-characters |
| 1425 | ;; Initialize `ps-mule-charset-list'. If some characters aren't | 1465 | ;; Initialize `ps-mule-charset-list'. If some characters aren't |
| 1426 | ;; printable, warn it. | 1466 | ;; printable, warn it. |
| 1427 | (let ((charsets (find-charset-region from to))) | 1467 | (let ((header-footer-list (ps-header-footer-string)) |
| 1428 | (setq charsets (delq 'ascii (delq 'unknown (delq nil charsets))) | 1468 | unprintable-charsets) |
| 1429 | ps-mule-charset-list charsets) | 1469 | (setq ps-mule-charset-list |
| 1430 | (save-excursion | 1470 | (delq 'ascii (delq 'eight-bit-control |
| 1431 | (goto-char from) | 1471 | (delq 'eight-bit-graphic |
| 1432 | (and (search-forward "\200" to t) | 1472 | (find-charset-region from to)))) |
| 1433 | (setq ps-mule-charset-list | 1473 | ps-mule-header-charsets |
| 1434 | (cons 'composition ps-mule-charset-list)))) | 1474 | (delq 'ascii (delq 'eight-bit-control |
| 1435 | ;; We also have to check non-ASCII charsets in the header strings. | 1475 | (delq 'eight-bit-graphic |
| 1436 | (let ((tail (ps-mule-header-string-charsets))) | 1476 | (find-charset-string |
| 1437 | (while tail | 1477 | (mapconcat |
| 1438 | (unless (eq (car tail) 'ascii) | 1478 | 'identity header-footer-list "")))))) |
| 1439 | (setq ps-mule-header-charsets | 1479 | (dolist (cs ps-mule-charset-list) |
| 1440 | (cons (car tail) ps-mule-header-charsets)) | 1480 | (or (ps-mule-printable-p cs) |
| 1441 | (or (memq (car tail) charsets) | 1481 | (push cs unprintable-charsets))) |
| 1442 | (setq charsets (cons (car tail) charsets)))) | 1482 | (dolist (cs ps-mule-header-charsets) |
| 1443 | (setq tail (cdr tail)))) | 1483 | (or (ps-mule-printable-p cs) |
| 1444 | (while charsets | 1484 | (memq cs unprintable-charsets) |
| 1445 | (setq charsets | 1485 | (push cs unprintable-charsets))) |
| 1446 | (cond | 1486 | (when unprintable-charsets |
| 1447 | ((or (eq (car charsets) 'composition) | 1487 | (ps-mule-show-warning unprintable-charsets from to |
| 1448 | (ps-mule-printable-p (car charsets))) | 1488 | header-footer-list) |
| 1449 | (cdr charsets)) | 1489 | (or |
| 1450 | ((y-or-n-p | 1490 | (y-or-n-p "Font for some characters not found, continue anyway? ") |
| 1451 | "Font for some characters not found, continue anyway? ") | 1491 | (error "Printing cancelled"))) |
| 1452 | nil) | 1492 | |
| 1453 | (t | 1493 | (or ps-mule-composition-prologue-generated |
| 1454 | (error "Printing cancelled"))))))) | 1494 | (let ((use-composition (nth 2 (find-composition from to)))) |
| 1495 | (or use-composition | ||
| 1496 | (let (str) | ||
| 1497 | (while header-footer-list | ||
| 1498 | (setq str (car header-footer-list)) | ||
| 1499 | (if (and (stringp str) | ||
| 1500 | (nth 2 (find-composition 0 (length str) str))) | ||
| 1501 | (setq use-composition t | ||
| 1502 | header-footer-list nil) | ||
| 1503 | (setq header-footer-list (cdr header-footer-list)))))) | ||
| 1504 | (when use-composition | ||
| 1505 | (progn | ||
| 1506 | (ps-mule-prologue-generated) | ||
| 1507 | (ps-output-prologue ps-mule-composition-prologue) | ||
| 1508 | (setq ps-mule-composition-prologue-generated t))))))) | ||
| 1455 | 1509 | ||
| 1456 | (setq ps-mule-current-charset 'ascii) | 1510 | (setq ps-mule-current-charset 'ascii) |
| 1457 | 1511 | ||
| 1458 | (if (and (nth 2 (find-composition from to)) | ||
| 1459 | (not ps-mule-composition-prologue-generated)) | ||
| 1460 | (progn | ||
| 1461 | (ps-mule-prologue-generated) | ||
| 1462 | (ps-output-prologue ps-mule-composition-prologue) | ||
| 1463 | (setq ps-mule-composition-prologue-generated t))) | ||
| 1464 | |||
| 1465 | (if (or ps-mule-charset-list ps-mule-header-charsets) | 1512 | (if (or ps-mule-charset-list ps-mule-header-charsets) |
| 1466 | (let ((the-list (append ps-mule-header-charsets ps-mule-charset-list)) | 1513 | (dolist (elt (append ps-mule-header-charsets ps-mule-charset-list)) |
| 1467 | font-spec elt) | ||
| 1468 | (ps-mule-prologue-generated) | 1514 | (ps-mule-prologue-generated) |
| 1469 | ;; If external functions are necessary, generate prologues for them. | 1515 | (ps-mule-init-external-library (ps-mule-get-font-spec elt 'normal)))) |
| 1470 | (while the-list | ||
| 1471 | (setq elt (car the-list) | ||
| 1472 | the-list (cdr the-list)) | ||
| 1473 | (cond ((and (eq elt 'composition) | ||
| 1474 | (not ps-mule-composition-prologue-generated)) | ||
| 1475 | (ps-output-prologue ps-mule-composition-prologue) | ||
| 1476 | (setq ps-mule-composition-prologue-generated t)) | ||
| 1477 | ((setq font-spec (ps-mule-get-font-spec elt 'normal)) | ||
| 1478 | (ps-mule-init-external-library font-spec)))))) | ||
| 1479 | 1516 | ||
| 1480 | ;; If ASCII font is also specified in ps-mule-font-info-database, | 1517 | ;; If ASCII font is also specified in ps-mule-font-info-database, |
| 1481 | ;; use it instead of what specified in ps-font-info-database. | 1518 | ;; use it instead of what specified in ps-font-info-database. |
| @@ -1496,7 +1533,8 @@ This checks if all multi-byte characters in the region are printable or not." | |||
| 1496 | ;; If the header contains non-ASCII and non-Latin1 characters, prepare a font | 1533 | ;; If the header contains non-ASCII and non-Latin1 characters, prepare a font |
| 1497 | ;; and glyphs for the first occurrence of such characters. | 1534 | ;; and glyphs for the first occurrence of such characters. |
| 1498 | (if (and ps-mule-header-charsets | 1535 | (if (and ps-mule-header-charsets |
| 1499 | (not (eq (car ps-mule-header-charsets) 'latin-iso8859-1))) | 1536 | (not (eq (car ps-mule-header-charsets) 'latin-iso8859-1)) |
| 1537 | (= (charset-dimension (car ps-mule-header-charsets)) 1)) | ||
| 1500 | (let ((font-spec (ps-mule-get-font-spec (car ps-mule-header-charsets) | 1538 | (let ((font-spec (ps-mule-get-font-spec (car ps-mule-header-charsets) |
| 1501 | 'normal))) | 1539 | 'normal))) |
| 1502 | (if font-spec | 1540 | (if font-spec |