aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2005-12-19 08:29:06 +0000
committerYAMAMOTO Mitsuharu2005-12-19 08:29:06 +0000
commit62ffc2321357ca710ed7993f4252988541d17592 (patch)
tree411260f2047c243989771d03c075e07775e1da46
parent814b36fe093cf5d3c2a348822db57b9ba7cb0764 (diff)
downloademacs-62ffc2321357ca710ed7993f4252988541d17592.tar.gz
emacs-62ffc2321357ca710ed7993f4252988541d17592.zip
(mac-handle-language-change)
(mac-ae-open-documents, mac-ae-get-url, mac-services-open-file) (mac-services-open-selection, mac-services-mail-selection) (mac-services-mail-to, mac-services-insert-text) (mac-dispatch-apple-event): Add docstrings. (x-get-selection, mac-select-convert-to-string): Select coding system from `utf-16be' and `utf-16le' using `byteorder'.
-rw-r--r--lisp/term/mac-win.el63
1 files changed, 29 insertions, 34 deletions
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el
index d6c6f9b8489..159a9da2cc3 100644
--- a/lisp/term/mac-win.el
+++ b/lisp/term/mac-win.el
@@ -1140,6 +1140,7 @@ correspoinding TextEncodingBase value."
1140 1140
1141;;;; Keyboard layout/language change events 1141;;;; Keyboard layout/language change events
1142(defun mac-handle-language-change (event) 1142(defun mac-handle-language-change (event)
1143 "Set keyboard coding system to what is specified in EVENT."
1143 (interactive "e") 1144 (interactive "e")
1144 (let ((coding-system 1145 (let ((coding-system
1145 (cdr (assq (car (cadr event)) mac-script-code-coding-systems)))) 1146 (cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
@@ -1201,21 +1202,14 @@ in `selection-converter-alist', which see."
1201 (when (and (stringp data) 1202 (when (and (stringp data)
1202 (setq data-type (get-text-property 0 'foreign-selection data))) 1203 (setq data-type (get-text-property 0 'foreign-selection data)))
1203 (cond ((eq data-type 'public.utf16-plain-text) 1204 (cond ((eq data-type 'public.utf16-plain-text)
1204 (if (fboundp 'mac-code-convert-string) 1205 (let ((encoded (and (fboundp 'mac-code-convert-string)
1205 (let ((s (mac-code-convert-string data nil coding))) 1206 (mac-code-convert-string data nil coding))))
1206 (if s 1207 (if encoded
1207 (setq data (decode-coding-string s coding)) 1208 (setq data (decode-coding-string encoded coding))
1208 (setq data 1209 (setq data
1209 ;; (decode-coding-string data 'utf-16) is 1210 (decode-coding-string data
1210 ;; not correct because 1211 (if (eq (byteorder) ?B)
1211 ;; public.utf16-plain-text is defined as 1212 'utf-16be 'utf-16le))))))
1212 ;; native byte order, no BOM.
1213 (decode-coding-string
1214 (mac-code-convert-string data nil 'utf-8)
1215 'utf-8))))
1216 ;; No `mac-code-convert-string' means non-Carbon, which
1217 ;; implies big endian.
1218 (setq data (decode-coding-string data 'utf-16be))))
1219 ((eq data-type 'com.apple.traditional-mac-plain-text) 1213 ((eq data-type 'com.apple.traditional-mac-plain-text)
1220 (setq data (decode-coding-string data coding))) 1214 (setq data (decode-coding-string data coding)))
1221 ((eq data-type 'public.file-url) 1215 ((eq data-type 'public.file-url)
@@ -1332,25 +1326,17 @@ in `selection-converter-alist', which see."
1332 (remove-text-properties 0 (length str) '(composition nil) str) 1326 (remove-text-properties 0 (length str) '(composition nil) str)
1333 (cond 1327 (cond
1334 ((eq type 'public.utf16-plain-text) 1328 ((eq type 'public.utf16-plain-text)
1335 (if (fboundp 'mac-code-convert-string) 1329 (let (s)
1336 (let (s) 1330 (when (and (fboundp 'mac-code-convert-string)
1337 (when (memq coding (find-coding-systems-string str)) 1331 (memq coding (find-coding-systems-string str)))
1338 (setq coding 1332 (setq coding (coding-system-change-eol-conversion coding 'mac))
1339 (coding-system-change-eol-conversion coding 'mac)) 1333 (setq s (mac-code-convert-string
1340 (setq s (mac-code-convert-string 1334 (encode-coding-string str coding)
1341 (encode-coding-string str coding) 1335 coding nil)))
1342 coding nil))) 1336 (setq str (or s
1343 (setq str (or s 1337 (encode-coding-string str
1344 ;; (encode-coding-string str 1338 (if (eq (byteorder) ?B)
1345 ;; 'utf-16-mac) is not correct because 1339 'utf-16be 'utf-16le))))))
1346 ;; public.utf16-plain-text is defined
1347 ;; as native byte order, no BOM.
1348 (mac-code-convert-string
1349 (encode-coding-string str 'utf-8-mac)
1350 'utf-8 nil))))
1351 ;; No `mac-code-convert-string' means non-Carbon, which
1352 ;; implies big endian.
1353 (setq str (encode-coding-string str 'utf-16be-mac))))
1354 ((eq type 'com.apple.traditional-mac-plain-text) 1340 ((eq type 'com.apple.traditional-mac-plain-text)
1355 (let ((encodables (find-coding-systems-string str)) 1341 (let ((encodables (find-coding-systems-string str))
1356 (rest mac-script-code-coding-systems)) 1342 (rest mac-script-code-coding-systems))
@@ -1484,6 +1470,7 @@ in `selection-converter-alist', which see."
1484 (decode-coding-string utf8-text 'utf-8)))) 1470 (decode-coding-string utf8-text 'utf-8))))
1485 1471
1486(defun mac-ae-open-documents (event) 1472(defun mac-ae-open-documents (event)
1473 "Open the documents specified by the Apple event EVENT."
1487 (interactive "e") 1474 (interactive "e")
1488 (let ((ae (mac-event-ae event))) 1475 (let ((ae (mac-event-ae event)))
1489 (dolist (file-name (mac-ae-list ae nil 'undecoded-file-name)) 1476 (dolist (file-name (mac-ae-list ae nil 'undecoded-file-name))
@@ -1511,6 +1498,8 @@ in `selection-converter-alist', which see."
1511 (error "No text in Apple event."))) 1498 (error "No text in Apple event.")))
1512 1499
1513(defun mac-ae-get-url (event) 1500(defun mac-ae-get-url (event)
1501 "Open the URL specified by the Apple event EVENT.
1502Currently the `mailto' scheme is supported."
1514 (interactive "e") 1503 (interactive "e")
1515 (let* ((ae (mac-event-ae event)) 1504 (let* ((ae (mac-event-ae event))
1516 (parsed-url (url-generic-parse-url (mac-ae-text ae)))) 1505 (parsed-url (url-generic-parse-url (mac-ae-text ae))))
@@ -1541,10 +1530,12 @@ in `selection-converter-alist', which see."
1541(define-key mac-apple-event-map [hicommand about] 'display-splash-screen) 1530(define-key mac-apple-event-map [hicommand about] 'display-splash-screen)
1542 1531
1543(defun mac-services-open-file () 1532(defun mac-services-open-file ()
1533 "Open the file specified by the selection value for Services."
1544 (interactive) 1534 (interactive)
1545 (find-file-existing (x-selection-value mac-services-selection))) 1535 (find-file-existing (x-selection-value mac-services-selection)))
1546 1536
1547(defun mac-services-open-selection () 1537(defun mac-services-open-selection ()
1538 "Create a new buffer containing the selection value for Services."
1548 (interactive) 1539 (interactive)
1549 (switch-to-buffer (generate-new-buffer "*untitled*")) 1540 (switch-to-buffer (generate-new-buffer "*untitled*"))
1550 (insert (x-selection-value mac-services-selection)) 1541 (insert (x-selection-value mac-services-selection))
@@ -1553,6 +1544,7 @@ in `selection-converter-alist', which see."
1553 ) 1544 )
1554 1545
1555(defun mac-services-mail-selection () 1546(defun mac-services-mail-selection ()
1547 "Prepare a mail buffer containing the selection value for Services."
1556 (interactive) 1548 (interactive)
1557 (compose-mail) 1549 (compose-mail)
1558 (rfc822-goto-eoh) 1550 (rfc822-goto-eoh)
@@ -1560,10 +1552,12 @@ in `selection-converter-alist', which see."
1560 (insert (x-selection-value mac-services-selection) "\n")) 1552 (insert (x-selection-value mac-services-selection) "\n"))
1561 1553
1562(defun mac-services-mail-to () 1554(defun mac-services-mail-to ()
1555 "Prepare a mail buffer to be sent to the selection value for Services."
1563 (interactive) 1556 (interactive)
1564 (compose-mail (x-selection-value mac-services-selection))) 1557 (compose-mail (x-selection-value mac-services-selection)))
1565 1558
1566(defun mac-services-insert-text () 1559(defun mac-services-insert-text ()
1560 "Insert the selection value for Services."
1567 (interactive) 1561 (interactive)
1568 (let ((text (x-selection-value mac-services-selection))) 1562 (let ((text (x-selection-value mac-services-selection)))
1569 (if (not buffer-read-only) 1563 (if (not buffer-read-only)
@@ -1584,6 +1578,7 @@ in `selection-converter-alist', which see."
1584 'mac-services-mail-to) 1578 'mac-services-mail-to)
1585 1579
1586(defun mac-dispatch-apple-event (event) 1580(defun mac-dispatch-apple-event (event)
1581 "Dispatch EVENT according to the keymap `mac-apple-event-map'."
1587 (interactive "e") 1582 (interactive "e")
1588 (let* ((binding (lookup-key mac-apple-event-map (mac-event-spec event))) 1583 (let* ((binding (lookup-key mac-apple-event-map (mac-event-spec event)))
1589 (service-message 1584 (service-message