diff options
| author | Eli Zaretskii | 2001-10-22 09:45:39 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2001-10-22 09:45:39 +0000 |
| commit | 2840d65358dfe3488bcdacf08ca101ef41f85be5 (patch) | |
| tree | 22f43ae190b84ce113ff2f0a18ee6b74d70eb11c /lisp | |
| parent | af0569548bc90f166de0499651cd82bf3fa67b52 (diff) | |
| download | emacs-2840d65358dfe3488bcdacf08ca101ef41f85be5.tar.gz emacs-2840d65358dfe3488bcdacf08ca101ef41f85be5.zip | |
(sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
(sgml-name-8bit-mode): Doc fix.
(sgml-char-names-table): New variable.
(sgml-name-char): Support non-ASCII and mule-unicode-* characters. Doc fix.
(sgml-maybe-name-self): Convert unibyte characters to multibyte.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 59 |
2 files changed, 51 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fa1279a226b..6584744b4bd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2001-10-22 Eli Zaretskii <eliz@is.elta.co.il> | 1 | 2001-10-22 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 2 | ||
| 3 | * textmodes/sgml-mode.el (sgml-mode-map): Bind 8-bit codes above | ||
| 4 | 127 to sgml-maybe-name-self. | ||
| 5 | (sgml-name-8bit-mode): Doc fix. | ||
| 6 | (sgml-char-names-table): New variable. | ||
| 7 | (sgml-name-char): Support non-ASCII and mule-unicode-* | ||
| 8 | characters. Doc fix. | ||
| 9 | (sgml-maybe-name-self): Convert unibyte characters to multibyte. | ||
| 10 | |||
| 3 | * tooltip.el (tooltip-x-offset, tooltip-y-offset): Mention in the | 11 | * tooltip.el (tooltip-x-offset, tooltip-y-offset): Mention in the |
| 4 | doc string the effect of `left' and `top' parameters in | 12 | doc string the effect of `left' and `top' parameters in |
| 5 | tooltip-frame-parameters, the default values, and the units. | 13 | tooltip-frame-parameters, the default values, and the units. |
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 612c3f36880..a97f0888b11 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el | |||
| @@ -106,6 +106,10 @@ This takes effect when first loading the sgml-mode library.") | |||
| 106 | (define-key map "'" 'sgml-name-self))) | 106 | (define-key map "'" 'sgml-name-self))) |
| 107 | (define-key map (vector (make-char 'latin-iso8859-1)) | 107 | (define-key map (vector (make-char 'latin-iso8859-1)) |
| 108 | 'sgml-maybe-name-self) | 108 | 'sgml-maybe-name-self) |
| 109 | (let ((c 127) | ||
| 110 | (map (nth 1 map))) | ||
| 111 | (while (< (setq c (1+ c)) 256) | ||
| 112 | (aset map c 'sgml-maybe-name-self))) | ||
| 109 | (define-key map [menu-bar sgml] (cons "SGML" menu-map)) | 113 | (define-key map [menu-bar sgml] (cons "SGML" menu-map)) |
| 110 | (define-key menu-map [sgml-validate] '("Validate" . sgml-validate)) | 114 | (define-key menu-map [sgml-validate] '("Validate" . sgml-validate)) |
| 111 | (define-key menu-map [sgml-name-8bit-mode] | 115 | (define-key menu-map [sgml-name-8bit-mode] |
| @@ -142,7 +146,7 @@ This takes effect when first loading the sgml-mode library.") | |||
| 142 | 146 | ||
| 143 | 147 | ||
| 144 | (defcustom sgml-name-8bit-mode nil | 148 | (defcustom sgml-name-8bit-mode nil |
| 145 | "*When non-nil, insert 8 bit characters with their names." | 149 | "*When non-nil, insert non-ASCII characters as named entities." |
| 146 | :type 'boolean | 150 | :type 'boolean |
| 147 | :group 'sgml) | 151 | :group 'sgml) |
| 148 | 152 | ||
| @@ -181,6 +185,20 @@ This takes effect when first loading the sgml-mode library.") | |||
| 181 | "oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"] | 185 | "oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"] |
| 182 | "Vector of symbolic character names without `&' and `;'.") | 186 | "Vector of symbolic character names without `&' and `;'.") |
| 183 | 187 | ||
| 188 | (put 'sgml-table 'char-table-extra-slots 0) | ||
| 189 | |||
| 190 | (defvar sgml-char-names-table | ||
| 191 | (let ((table (make-char-table 'sgml-table)) | ||
| 192 | (i 32) | ||
| 193 | elt) | ||
| 194 | (while (< i 256) | ||
| 195 | (setq elt (aref sgml-char-names i)) | ||
| 196 | (if elt (aset table (make-char 'latin-iso8859-1 i) elt)) | ||
| 197 | (setq i (1+ i))) | ||
| 198 | table) | ||
| 199 | "A table for mapping non-ASCII characters into SGML entity names. | ||
| 200 | Currently, only Latin-1 characters are supported.") | ||
| 201 | |||
| 184 | 202 | ||
| 185 | ;; nsgmls is a free SGML parser in the SP suite available from | 203 | ;; nsgmls is a free SGML parser in the SP suite available from |
| 186 | ;; ftp.jclark.com and otherwise packaged for GNU systems. | 204 | ;; ftp.jclark.com and otherwise packaged for GNU systems. |
| @@ -448,8 +466,9 @@ start tag, and the second `/' is the corresponding null end tag." | |||
| 448 | 466 | ||
| 449 | (defun sgml-name-char (&optional char) | 467 | (defun sgml-name-char (&optional char) |
| 450 | "Insert a symbolic character name according to `sgml-char-names'. | 468 | "Insert a symbolic character name according to `sgml-char-names'. |
| 451 | 8 bit chars may be inserted with the meta key as in M-SPC for no break space, | 469 | Non-ASCII chars may be inserted either with the meta key, as in M-SPC for |
| 452 | or M-- for a soft hyphen." | 470 | no-break space or M-- for a soft hyphen; or via an input method or |
| 471 | encoded keyboard operation." | ||
| 453 | (interactive "*") | 472 | (interactive "*") |
| 454 | (insert ?&) | 473 | (insert ?&) |
| 455 | (or char | 474 | (or char |
| @@ -458,34 +477,42 @@ or M-- for a soft hyphen." | |||
| 458 | (insert char) | 477 | (insert char) |
| 459 | (undo-boundary) | 478 | (undo-boundary) |
| 460 | (delete-backward-char 1) | 479 | (delete-backward-char 1) |
| 461 | (insert ?& | 480 | (cond |
| 462 | (or (aref sgml-char-names char) | 481 | ((< char 256) |
| 463 | (format "#%d" char)) | 482 | (insert ?& |
| 464 | ?\;)) | 483 | (or (aref sgml-char-names char) |
| 465 | 484 | (format "#%d" char)) | |
| 485 | ?\;)) | ||
| 486 | ((aref sgml-char-names-table char) | ||
| 487 | (insert ?& (aref sgml-char-names-table char) ?\;)) | ||
| 488 | ((memq (char-charset char) '(mule-unicode-0100-24ff | ||
| 489 | mule-unicode-2500-33ff | ||
| 490 | mule-unicode-e000-ffff)) | ||
| 491 | (insert (format "&#%d;" (encode-char char 'ucs)))) | ||
| 492 | (t | ||
| 493 | (insert char)))) | ||
| 466 | 494 | ||
| 467 | (defun sgml-name-self () | 495 | (defun sgml-name-self () |
| 468 | "Insert a symbolic character name according to `sgml-char-names'." | 496 | "Insert a symbolic character name according to `sgml-char-names'." |
| 469 | (interactive "*") | 497 | (interactive "*") |
| 470 | (sgml-name-char last-command-char)) | 498 | (sgml-name-char last-command-char)) |
| 471 | 499 | ||
| 472 | |||
| 473 | (defun sgml-maybe-name-self () | 500 | (defun sgml-maybe-name-self () |
| 474 | "Insert a symbolic character name according to `sgml-char-names'." | 501 | "Insert a symbolic character name according to `sgml-char-names'." |
| 475 | (interactive "*") | 502 | (interactive "*") |
| 476 | (if sgml-name-8bit-mode | 503 | (if sgml-name-8bit-mode |
| 477 | (sgml-name-char | 504 | (let ((mc last-command-char)) |
| 478 | (if (eq (char-charset last-command-char) 'latin-iso8859-1) | 505 | (if (< mc 256) |
| 479 | (+ 128 (- last-command-char (make-char 'latin-iso8859-1))) | 506 | (setq mc (unibyte-char-to-multibyte mc))) |
| 480 | last-command-char)) | 507 | (or mc (setq mc last-command-char)) |
| 508 | (sgml-name-char mc)) | ||
| 481 | (self-insert-command 1))) | 509 | (self-insert-command 1))) |
| 482 | 510 | ||
| 483 | |||
| 484 | (defun sgml-name-8bit-mode () | 511 | (defun sgml-name-8bit-mode () |
| 485 | "Toggle insertion of 8 bit characters." | 512 | "Toggle whether to insert named entities instead of non-ASCII characters." |
| 486 | (interactive) | 513 | (interactive) |
| 487 | (setq sgml-name-8bit-mode (not sgml-name-8bit-mode)) | 514 | (setq sgml-name-8bit-mode (not sgml-name-8bit-mode)) |
| 488 | (message "sgml name 8 bit mode is now %s" | 515 | (message "sgml name entity mode is now %s" |
| 489 | (if sgml-name-8bit-mode "ON" "OFF"))) | 516 | (if sgml-name-8bit-mode "ON" "OFF"))) |
| 490 | 517 | ||
| 491 | 518 | ||