mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
(decode-mac-roman, encode-mac-roman, mac-roman): Moved to european.el.
(ccl-encode-mac-roman-font, fontset-mac): Modified for mule-unicode-2500-33ff and mule-unicode-e000-ffff. (mac-roman-kbd-insert, mac-roman-kbd-mode): These functions deleted. (mac-roman-kbd-mode, mac-roman-kbd-mode-map): These variables deleted.
This commit is contained in:
parent
d7a0fd0086
commit
dfc064f2b5
1 changed files with 21 additions and 113 deletions
|
|
@ -170,77 +170,39 @@ Switch to a buffer editing the last file dropped."
|
|||
(defconst kTextEncodingISOLatin1 513 "0x201")
|
||||
(defconst kTextEncodingISOLatin2 514 "0x202")
|
||||
|
||||
;; Definitions for the Mac Roman character sets and coding system.
|
||||
;; The Mac Roman encoding uses all 128 code points in the range 128 to
|
||||
;; 255 for actual characters. Since Emacs cannot handle this many
|
||||
;; code points as one character set, we divide it into two:
|
||||
;; mac-roman-lower for code points 128 to 159 and mac-roman-upper for
|
||||
;; code points 160 to 255.
|
||||
|
||||
;; Since Mac Roman does not follow the ISO 2022 standard and uses code
|
||||
;; points in the range 128-159, it is necessary to define it as a
|
||||
;; type-4 charset, with CCL programs and all.
|
||||
|
||||
(define-ccl-program decode-mac-roman
|
||||
`(2
|
||||
((loop
|
||||
(read r0)
|
||||
(if (r0 < 128) ;; ASCII
|
||||
(if (r0 == ?\r) ;; assume such a file uses Mac EOL's
|
||||
(write-repeat ?\n)
|
||||
(write-repeat r0))
|
||||
(if (r0 < 160) ;; lower
|
||||
((r0 += 32)
|
||||
(r1 = ,(charset-id 'mac-roman-lower))
|
||||
(write-multibyte-character r1 r0)
|
||||
(repeat))
|
||||
((r1 = ,(charset-id 'mac-roman-upper)) ;; upper
|
||||
(write-multibyte-character r1 r0)
|
||||
(repeat)))))))
|
||||
"CCL program to decode Mac Roman")
|
||||
|
||||
(define-ccl-program encode-mac-roman
|
||||
`(1
|
||||
((loop
|
||||
(read-multibyte-character r0 r1)
|
||||
(if (r0 == ,(charset-id 'ascii))
|
||||
(if (r1 == ?\n)
|
||||
(write-repeat ?\r)
|
||||
(write-repeat r1))
|
||||
(if (r0 == ,(charset-id 'mac-roman-lower))
|
||||
((r1 += 96)
|
||||
(write-repeat r1))
|
||||
(if (r0 == ,(charset-id 'mac-roman-upper))
|
||||
((r1 += 128)
|
||||
(write-repeat r1))))))))
|
||||
"CCL program to encode Mac Roman")
|
||||
|
||||
(make-coding-system
|
||||
'mac-roman 4 ?M "Mac Roman Encoding"
|
||||
'(decode-mac-roman . encode-mac-roman)
|
||||
'((safe-charsets ascii mac-roman-lower mac-roman-upper)
|
||||
(valid codes (0 . 255))))
|
||||
|
||||
;; This doesn't seem to do anything for type-4 charsets:
|
||||
;; (put 'mac-roman 'eol-type (make-subsidiary-coding-system 'mac-roman))
|
||||
|
||||
(define-ccl-program ccl-encode-mac-roman-font
|
||||
`(0
|
||||
(if (r0 == ,(charset-id 'mac-roman-lower))
|
||||
(r1 += 96)
|
||||
(r1 += 128))))
|
||||
(if (r0 != ,(charset-id 'ascii))
|
||||
(if (r0 == ,(charset-id 'latin-iso8859-1))
|
||||
(translate-character mac-roman-encoder r0 r1)
|
||||
((r1 <<= 7)
|
||||
(r1 |= r2)
|
||||
(translate-character mac-roman-encoder r0 r1)))))
|
||||
"CCL program for Mac Roman font")
|
||||
|
||||
(setq font-ccl-encoder-alist
|
||||
(cons '("mac-roman" . ccl-encode-mac-roman-font)
|
||||
font-ccl-encoder-alist))
|
||||
|
||||
;; Create a fontset that uses mac-roman font. With this fontset,
|
||||
;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
|
||||
;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
|
||||
|
||||
(if (fboundp 'new-fontset)
|
||||
(progn
|
||||
(create-fontset-from-fontset-spec
|
||||
"-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac,
|
||||
mac-roman-lower:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman,
|
||||
mac-roman-upper:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman"
|
||||
t)))
|
||||
ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
|
||||
(let ((monaco-font '("monaco" . "mac-roman")))
|
||||
(map-char-table
|
||||
(function
|
||||
(lambda (key val)
|
||||
(or (generic-char-p key)
|
||||
(memq (char-charset key)
|
||||
'(ascii eight-bit-control eight-bit-graphic))
|
||||
(set-fontset-font "fontset-mac" key monaco-font))))
|
||||
(get 'mac-roman-encoder 'translation-table)))))
|
||||
|
||||
;; To display filenames in Chinese or Japanese, replace mac-roman with
|
||||
;; big5 or sjis
|
||||
|
|
@ -248,60 +210,6 @@ Switch to a buffer editing the last file dropped."
|
|||
|
||||
;; (prefer-coding-system 'mac-roman)
|
||||
|
||||
(defun mac-roman-kbd-insert ()
|
||||
"Insert a character in Mac Roman encoding at point.\n\
|
||||
Called by keymap of Mac-kbd minor mode."
|
||||
(interactive "*")
|
||||
(let ((ch last-command-char))
|
||||
(if (< ch 160)
|
||||
(insert
|
||||
(make-char 'mac-roman-lower
|
||||
(- last-command-char 96)))
|
||||
(insert
|
||||
(make-char 'mac-roman-upper
|
||||
(- last-command-char 128))))))
|
||||
|
||||
(defvar mac-roman-kbd-mode nil
|
||||
"Non-nil if in Mac-kbd minor mode.")
|
||||
|
||||
(put 'mac-roman-kbd-mode 'permanent-local t)
|
||||
|
||||
(or (assq 'mac-roman-kbd-mode minor-mode-alist)
|
||||
(setq minor-mode-alist
|
||||
(cons '(mac-roman-kbd-mode " Mac-kbd") minor-mode-alist)))
|
||||
|
||||
(defvar mac-roman-kbd-mode-map
|
||||
(let ((map (make-keymap))
|
||||
(i 128))
|
||||
(while (< i 256)
|
||||
(define-key map (vector i) 'mac-roman-kbd-insert)
|
||||
(setq i (1+ i)))
|
||||
map)
|
||||
"Keymap for Mac-kbd minor mode.")
|
||||
|
||||
(or (assq 'mac-roman-kbd-mode minor-mode-map-alist)
|
||||
(setq minor-mode-map-alist
|
||||
(cons (cons 'mac-roman-kbd-mode mac-roman-kbd-mode-map)
|
||||
minor-mode-map-alist)))
|
||||
|
||||
(defun mac-roman-kbd-mode (&optional arg)
|
||||
"Toggle Mac Roman Keyboard (Mac-kbd) minor mode.\n\
|
||||
In this minor mode, characters in the range 128 to 255 generated by\n\
|
||||
the Mac keyboard are inserted as mac-roman-lower or mac-roman-upper\n\
|
||||
characters, in the mac-roman encoding.\n\
|
||||
\n\
|
||||
With an argument, a positive argument enables Mac Roman Keyboard mode,\n\
|
||||
and a negative argument disables it."
|
||||
(interactive "P")
|
||||
(if (if arg
|
||||
;; Negative arg means switch it off.
|
||||
(<= (prefix-numeric-value arg) 0)
|
||||
;; No arg means toggle.
|
||||
mac-roman-kbd-mode)
|
||||
(setq mac-roman-kbd-mode nil)
|
||||
;; Enable mode.
|
||||
(setq mac-roman-kbd-mode t)))
|
||||
|
||||
;;
|
||||
;; Available colors
|
||||
;;
|
||||
|
|
|
|||
Loading…
Reference in a new issue