Mercurial > hg > xemacs-beta
comparison lisp/code-cmds.el @ 3416:59d576895891
[xemacs-hg @ 2006-05-23 12:56:19 by stephent]
Fix up coding-system-change-eol-conversion. <87bqtozzub.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Tue, 23 May 2006 12:56:20 +0000 |
parents | b531bf8658e9 |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
3415:168e8d8a55be | 3416:59d576895891 |
---|---|
1 ;;; code-cmds.el --- Commands for manipulating coding systems. | 1 ;;; code-cmds.el --- Commands for manipulating coding systems. |
2 | 2 |
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN. | 3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN. |
4 ;; Licensed to the Free Software Foundation. | 4 ;; Licensed to the Free Software Foundation. |
5 ;; Copyright (C) 2000 Free Software Foundation | 5 ;; Copyright (C) 2000,2006 Free Software Foundation |
6 ;; Copyright (C) 1997 MORIOKA Tomohiko | 6 ;; Copyright (C) 1997 MORIOKA Tomohiko |
7 ;; Copyright (C) 2001, 2002 Ben Wing. | 7 ;; Copyright (C) 2001, 2002 Ben Wing. |
8 | 8 |
9 | 9 |
10 ;; This file is part of XEmacs. | 10 ;; This file is part of XEmacs. |
25 ;; 02111-1307, USA. | 25 ;; 02111-1307, USA. |
26 | 26 |
27 ;; | 27 ;; |
28 ;; This code defines the keybindings and utility commands for the | 28 ;; This code defines the keybindings and utility commands for the |
29 ;; user to manipulate coding systems. | 29 ;; user to manipulate coding systems. |
30 ;; This code used to be in mule-cmds.el which now only needs the | 30 ;; This code used to be in mule-cmds.el which now contains only the |
31 ;; additional bindings/commands that are avaible on the real mule. | 31 ;; additional bindings/commands that are available for full Mule. |
32 | 32 |
33 | 33 |
34 ;;; Code: | 34 ;;; Code: |
35 | 35 |
36 ;;; Coding related key bindings and menus. | 36 ;;; Coding related key bindings and menus. |
51 (define-key coding-keymap "C" 'describe-coding-system)) ; XEmacs | 51 (define-key coding-keymap "C" 'describe-coding-system)) ; XEmacs |
52 (when-fboundp 'set-selection-coding-system | 52 (when-fboundp 'set-selection-coding-system |
53 (define-key coding-keymap "x" 'set-selection-coding-system) | 53 (define-key coding-keymap "x" 'set-selection-coding-system) |
54 (define-key coding-keymap "X" 'set-next-selection-coding-system)) | 54 (define-key coding-keymap "X" 'set-next-selection-coding-system)) |
55 | 55 |
56 ;; XEmacs change: make code readable, and sanity-check EOL-TYPE. | |
56 (defun coding-system-change-eol-conversion (coding-system eol-type) | 57 (defun coding-system-change-eol-conversion (coding-system eol-type) |
57 "Return a coding system which differs from CODING-SYSTEM in eol conversion. | 58 "Return a version of CODING-SYSTEM that provides EOL-TYPE eol conversion. |
58 The returned coding system converts end-of-line by EOL-TYPE | 59 EOL-TYPE should be `lf', `crlf', `cr' or nil. nil means the returned coding |
59 but text as the same way as CODING-SYSTEM. | 60 system automatically detects the end-of-line convention while decoding. |
60 EOL-TYPE should be `lf', `crlf', `cr' or nil. | 61 EOL-TYPE may also be one of the symbols `unix', `dos' or `mac', meaning |
61 If EOL-TYPE is nil, the returned coding system detects | 62 `lf', `crlf', and `cr' respectively." |
62 how end-of-line is formatted automatically while decoding. | 63 (setq eol-type (cond ((or (eq eol-type 'unix) (eq eol-type 'lf)) 'eol-lf) |
63 | 64 ((or (eq eol-type 'dos) (eq eol-type 'crlf)) 'eol-crlf) |
64 EOL-TYPE can be specified by an symbol `unix', `dos' or `mac'. | 65 ((or (eq eol-type 'mac) (eq eol-type 'cr)) 'eol-cr) |
65 They means `lf', `crlf', and `cr' respectively." | 66 ((null eol-type) nil) |
66 (if (symbolp eol-type) | 67 (t (error 'invalid-constant eol-type)))) |
67 (setq eol-type (cond ((or (eq eol-type 'unix) | |
68 (eq eol-type 'lf)) | |
69 'eol-lf) | |
70 ((or (eq eol-type 'dos) | |
71 (eq eol-type 'crlf)) | |
72 'eol-crlf) | |
73 ((or (eq eol-type 'mac) | |
74 (eq eol-type 'cr)) | |
75 'eol-cr) | |
76 (t eol-type)))) | |
77 (coding-system-name | 68 (coding-system-name |
78 (let ((orig-eol-type (coding-system-eol-type coding-system))) | 69 (let ((orig-eol-type (cdr (assq (coding-system-eol-type coding-system) |
79 (if (null orig-eol-type) | 70 '((lf . eol-lf) |
80 (if (not eol-type) | 71 (cr . eol-cr) |
81 coding-system | 72 (crlf . eol-crlf) |
82 (coding-system-property coding-system eol-type)) | 73 ;; #### also returns nil if not a key |
83 (let ((base (coding-system-base coding-system))) | 74 (nil . nil))))) |
84 (if (not eol-type) | 75 (base (coding-system-base coding-system))) |
85 base | 76 (cond ((eq eol-type orig-eol-type) coding-system) |
86 (if (eq eol-type orig-eol-type) | 77 ((null orig-eol-type) |
87 coding-system | 78 (coding-system-property coding-system eol-type)) |
88 (setq orig-eol-type (coding-system-eol-type base)) | 79 ((null eol-type) base) |
89 (if (null orig-eol-type) | 80 ((null (coding-system-eol-type base)) |
90 (coding-system-property base eol-type))))))))) | 81 (coding-system-property base eol-type)) |
82 (t (warn "couldn't change EOL conversion of %s from %s to %s." | |
83 coding-system orig-eol-type eol-type) | |
84 ;; return nil for compatibility with old code | |
85 nil))))) | |
91 | 86 |
92 ;; (defun coding-system-change-text-conversion (coding-system coding) | 87 ;; (defun coding-system-change-text-conversion (coding-system coding) |
93 ;; "Return a coding system which differs from CODING-SYSTEM in text conversion. | 88 ;; "Return a coding system which differs from CODING-SYSTEM in text conversion. |
94 ;; The returned coding system converts text by CODING | 89 ;; The returned coding system converts text by CODING |
95 ;; but end-of-line as the same way as CODING-SYSTEM. | 90 ;; but end-of-line as the same way as CODING-SYSTEM. |