annotate lisp/code-cmds.el @ 5882:bbe4146603db

Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp lisp/ChangeLog addition: 2015-04-01 Aidan Kehoe <kehoea@parhasard.net> When calling #'string-match with a REGEXP without regular expression special characters, call #'search, #'mismatch, #'find, etc. instead, making our code less likely to side-effect other functions' match data and a little faster. * apropos.el (apropos-command): * apropos.el (apropos): Call (position ?\n ...) rather than (string-match "\n" ...) here. * buff-menu.el: * buff-menu.el (buffers-menu-omit-invisible-buffers): Don't fire up the regexp engine just to check if a string starts with a space. * buff-menu.el (select-buffers-tab-buffers-by-mode): Don't fire up the regexp engine just to compare mode basenames. * buff-menu.el (format-buffers-tab-line): * buff-menu.el (build-buffers-tab-internal): Moved to being a label within the following. * buff-menu.el (buffers-tab-items): Use the label. * bytecomp.el (byte-compile-log-1): Don't fire up the regexp engine just to look for a newline. * cus-edit.el (get): Ditto. * cus-edit.el (custom-variable-value-create): Ditto, but for a colon. * descr-text.el (describe-text-sexp): Ditto. * descr-text.el (describe-char-unicode-data): Use #'split-string-by-char given that we're just looking for a semicolon. * descr-text.el (describe-char): Don't fire up the regexp engine just to look for a newline. * disass.el (disassemble-internal): Ditto. * files.el (file-name-sans-extension): Implement this using #'position. * files.el (file-name-extension): Correct this function's docstring, implement it in terms of #'position. * files.el (insert-directory): Don't fire up the regexp engine to split a string by space; don't reverse the list of switches, this is actually a longstand bug as far as I can see. * gnuserv.el (gnuserv-process-filter): Use #'position here, instead of consing inside #'split-string needlessly. * gtk-file-dialog.el (gtk-file-dialog-update-dropdown): Use #'split-string-by-char here, don't fire up #'split-string for directory-sep-char. * gtk-font-menu.el (hack-font-truename): Implement this more cheaply in terms of #'find, #'split-string-by-char, #'equal, rather than #'string-match, #'split-string, #'string-equal. * hyper-apropos.el (hyper-apropos-grok-functions): * hyper-apropos.el (hyper-apropos-grok-variables): Look for a newline using #'position rather than #'string-match in these functions. * info.el (Info-insert-dir): * info.el (Info-insert-file-contents): * info.el (Info-follow-reference): * info.el (Info-extract-menu-node-name): * info.el (Info-menu): Look for fixed strings using #'position or #'search as appropriate in this file. * ldap.el (ldap-decode-string): * ldap.el (ldap-encode-string): #'encode-coding-string, #'decode-coding-string are always available, don't check if they're fboundp. * ldap.el (ldap-decode-address): * ldap.el (ldap-encode-address): Use #'split-string-by-char in these functions. * lisp-mnt.el (lm-creation-date): * lisp-mnt.el (lm-last-modified-date): Don't fire up the regexp engine just to look for spaces in this file. * menubar-items.el (default-menubar): Use (not (mismatch ...)) rather than #'string-match here, for simple regexp. Use (search "beta" ...) rather than (string-match "beta" ...) * menubar-items.el (sort-buffers-menu-alphabetically): * menubar-items.el (sort-buffers-menu-by-mode-then-alphabetically): * menubar-items.el (group-buffers-menu-by-mode-then-alphabetically): Don't fire up the regexp engine to check if a string starts with a space or an asterisk. Use the more fine-grained results of #'compare-strings; compare case-insensitively for the buffer menu. * menubar-items.el (list-all-buffers): * menubar-items.el (tutorials-menu-filter): Use #'equal rather than #'string-equal, which, in this context, has the drawback of not having a bytecode, and no redeeming features. * minibuf.el: * minibuf.el (un-substitute-in-file-name): Use #'count, rather than counting the occurences of $ using the regexp engine. * minibuf.el (read-file-name-internal-1): Don't fire up the regexp engine to search for ?=. * mouse.el (mouse-eval-sexp): Check for newline with #'find. * msw-font-menu.el (mswindows-reset-device-font-menus): Split a string by newline with #'split-string-by-char. * mule/japanese.el: * mule/japanese.el ("Japanese"): Use #'search rather than #'string-match; canoncase before comparing; fix a bug I had introduced where I had been making case insensitive comparisons where the case mattered. * mule/korea-util.el (default-korean-keyboard): Look for ?3 using #'find, not #'string-march. * mule/korea-util.el (quail-hangul-switch-hanja): Search for a fixed string using #'search. * mule/mule-cmds.el (set-locale-for-language-environment): #'position, #'substitute rather than #'string-match, #'replace-in-string. * newcomment.el (comment-make-extra-lines): Use #'search rather than #'string-match for a simple string. * package-get.el (package-get-remote-filename): Use #'position when looking for ?@ * process.el (setenv): * process.el (read-envvar-name): Use #'position when looking for ?=. * replace.el (map-query-replace-regexp): Use #'split-string-by-char instead of using an inline implementation of it. * select.el (select-convert-from-cf-text): * select.el (select-convert-from-cf-unicodetext): Use #'position rather than #'string-match in these functions. * setup-paths.el (paths-emacs-data-root-p): Use #'search when looking for simple string. * sound.el (load-sound-file): Use #'split-string-by-char rather than an inline reimplementation of same. * startup.el (splash-screen-window-body): * startup.el (splash-screen-tty-body): Search for simple strings using #'search. * version.el (emacs-version): Ditto. * x-font-menu.el (hack-font-truename): Implement this more cheaply in terms of #'find, #'split-string-by-char, #'equal, rather than #'string-match, #'split-string, #'string-equal. * x-font-menu.el (x-reset-device-font-menus-core): Use #'split-string-by-char here. * x-init.el (x-initialize-keyboard): Search for a simple string using #'search.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 01 Apr 2015 14:28:20 +0100
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
1 ;;; code-cmds.el --- Commands for manipulating coding systems.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
2
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
4 ;; Licensed to the Free Software Foundation.
3416
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
5 ;; Copyright (C) 2000,2006 Free Software Foundation
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
6 ;; Copyright (C) 1997 MORIOKA Tomohiko
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
7 ;; Copyright (C) 2001, 2002 Ben Wing.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
8
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
9
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
11
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
12 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
13 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
14 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
15 ;; option) any later version.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
16
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
19 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
20 ;; for more details.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
21
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 3416
diff changeset
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
24
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
25 ;;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
26 ;; This code defines the keybindings and utility commands for the
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
27 ;; user to manipulate coding systems.
3416
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
28 ;; This code used to be in mule-cmds.el which now contains only the
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
29 ;; additional bindings/commands that are available for full Mule.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
30
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
31
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
32 ;;; Code:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
33
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
34 ;;; Coding related key bindings and menus.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
35
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
36 (defvar coding-keymap (make-sparse-keymap "Coding+Mule")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
37 "Keymap for coding-system-specific and (when available) Mule commands.")
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
38
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
39 ;; Keep "C-x C-m ..." for coding/mule specific commands.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
40 (define-key ctl-x-map "\C-m" coding-keymap)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
41
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
42 (define-key coding-keymap "f" 'set-buffer-file-coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
43 (define-key coding-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
44 (define-key coding-keymap "t" 'set-terminal-coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
45 (define-key coding-keymap "p" 'set-buffer-process-coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
46 (define-key coding-keymap "c" 'universal-coding-system-argument)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
47 ;;(define-key coding-keymap "c" 'list-coding-system-briefly) ; XEmacs
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
48 (when-fboundp 'describe-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
49 (define-key coding-keymap "C" 'describe-coding-system)) ; XEmacs
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
50 (when-fboundp 'set-selection-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
51 (define-key coding-keymap "x" 'set-selection-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
52 (define-key coding-keymap "X" 'set-next-selection-coding-system))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
53
3416
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
54 ;; XEmacs change: make code readable, and sanity-check EOL-TYPE.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
55 (defun coding-system-change-eol-conversion (coding-system eol-type)
3416
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
56 "Return a version of CODING-SYSTEM that provides EOL-TYPE eol conversion.
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
57 EOL-TYPE should be `lf', `crlf', `cr' or nil. nil means the returned coding
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
58 system automatically detects the end-of-line convention while decoding.
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
59 EOL-TYPE may also be one of the symbols `unix', `dos' or `mac', meaning
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
60 `lf', `crlf', and `cr' respectively."
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
61 (setq eol-type (cond ((or (eq eol-type 'unix) (eq eol-type 'lf)) 'eol-lf)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
62 ((or (eq eol-type 'dos) (eq eol-type 'crlf)) 'eol-crlf)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
63 ((or (eq eol-type 'mac) (eq eol-type 'cr)) 'eol-cr)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
64 ((null eol-type) nil)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
65 (t (error 'invalid-constant eol-type))))
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 771
diff changeset
66 (coding-system-name
3416
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
67 (let ((orig-eol-type (cdr (assq (coding-system-eol-type coding-system)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
68 '((lf . eol-lf)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
69 (cr . eol-cr)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
70 (crlf . eol-crlf)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
71 ;; #### also returns nil if not a key
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
72 (nil . nil)))))
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
73 (base (coding-system-base coding-system)))
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
74 (cond ((eq eol-type orig-eol-type) coding-system)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
75 ((null orig-eol-type)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
76 (coding-system-property coding-system eol-type))
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
77 ((null eol-type) base)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
78 ((null (coding-system-eol-type base))
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
79 (coding-system-property base eol-type))
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
80 (t (warn "couldn't change EOL conversion of %s from %s to %s."
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
81 coding-system orig-eol-type eol-type)
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
82 ;; return nil for compatibility with old code
59d576895891 [xemacs-hg @ 2006-05-23 12:56:19 by stephent]
stephent
parents: 1318
diff changeset
83 nil)))))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
84
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
85 ;; (defun coding-system-change-text-conversion (coding-system coding)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
86 ;; "Return a coding system which differs from CODING-SYSTEM in text conversion.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
87 ;; The returned coding system converts text by CODING
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
88 ;; but end-of-line as the same way as CODING-SYSTEM.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
89 ;; If CODING is nil, the returned coding system detects
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
90 ;; how text is formatted automatically while decoding."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
91 ;; (if (not coding)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
92 ;; (coding-system-base coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
93 ;; (let ((eol-type (coding-system-eol-type coding-system)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
94 ;; (coding-system-change-eol-conversion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
95 ;; coding
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
96 ;; (if (numberp eol-type) (aref [unix dos mac] eol-type))))))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
97
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
98 (defun universal-coding-system-argument ()
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
99 "Execute an I/O command using the specified coding system."
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
100 (interactive)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
101 (let* ((default (and buffer-file-coding-system
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
102 (not (eq (coding-system-type buffer-file-coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
103 t))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
104 (coding-system-name buffer-file-coding-system)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
105 (coding-system
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
106 (read-coding-system
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
107 (if default
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
108 (format "Coding system for following command (default, %s): "
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
109 default)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
110 "Coding system for following command: ")
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
111 default))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
112 (keyseq (read-key-sequence
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
113 (format "Command to execute with %s:" coding-system)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
114 (cmd (key-binding keyseq)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
115 (let ((coding-system-for-read coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
116 (coding-system-for-write coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
117 (message "")
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
118 (call-interactively cmd))))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
119
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
120 (defun set-default-output-coding-systems (coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
121 "Set default value for coding system output to CODING-SYSTEM.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
122 This sets the coding system of newly created buffers (the default value of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
123 `buffer-file-coding-system') and the default coding system for output to a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
124 subprocess (the CDR of `default-process-coding-system').
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
125
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
126 Other defaults are not changed; see `prefer-coding-system' for why."
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
127 (check-coding-system coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
128 (set-default-buffer-file-coding-system coding-system)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
129 (setq default-process-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
130 (cons (car default-process-coding-system) coding-system)))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
131
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
132 (defun prefer-coding-system (coding-system)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
133 "Add CODING-SYSTEM at the front of the priority list for automatic detection.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
134 This also sets the coding system of newly created buffers (the default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
135 value of `buffer-file-coding-system') and the default coding system for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
136 output to a subprocess (the CDR of `default-process-coding-system').
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
137
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
138 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
139 systems set by this function will use that type of EOL conversion.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
140
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
141 This does not change the default coding system for converting file names
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
142 because that is dependent on the current locale; it's changed when
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
143 `set-language-environment' is called. It does not change
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
144 `terminal-coding-system' or `keyboard-coding-system'; they should get set
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
145 when the terminal is opened (and are typically an inherent property of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
146 terminal), and don't change afterward. It does not change the default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
147 coding system for reading files or input from a subprocess; they should
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
148 remain as `undecided' so that automatic detection is done."
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
149 (interactive "zPrefer coding system: ")
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
150 (if (not (and coding-system (find-coding-system coding-system)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
151 (error "Invalid coding system `%s'" coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
152 (let ((coding-category (coding-system-category coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
153 (base (coding-system-base coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
154 (eol-type (coding-system-eol-type coding-system)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
155 (if (not coding-category)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
156 ;; CODING-SYSTEM is no-conversion or undecided.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
157 (error "Can't prefer the coding system `%s'" coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
158 (set-coding-category-system coding-category (or base coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
159 ;; (update-coding-systems-internal)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
160 (or (eq coding-category (car (coding-category-list)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
161 ;; We must change the order.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
162 (set-coding-priority-list (list coding-category)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
163 (if (and base (interactive-p))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
164 (message "Highest priority is set to %s (base of %s)"
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
165 base coding-system))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
166 ;; If they asked for specific EOL conversion, honor that.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
167 (if (memq eol-type '(lf crlf cr unix dos mac))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
168 (setq coding-system
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
169 (coding-system-change-eol-conversion base eol-type))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
170 (setq coding-system base))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
171 (set-default-output-coding-systems coding-system)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
172
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
173 ;; (defun find-coding-systems-region-subset-p (list1 list2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
174 ;; "Return non-nil if all elements in LIST1 are included in LIST2.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
175 ;; Comparison done with EQ."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
176 ;; (catch 'tag
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
177 ;; (while list1
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
178 ;; (or (memq (car list1) list2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
179 ;; (throw 'tag nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
180 ;; (setq list1 (cdr list1)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
181 ;; t))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
182
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
183 ;; (defun find-coding-systems-region (from to)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
184 ;; "Return a list of proper coding systems to encode a text between FROM and TO.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
185 ;; All coding systems in the list can safely encode any multibyte characters
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
186 ;; in the text.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
187 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
188 ;; If the text contains no multibyte characters, return a list of a single
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
189 ;; element `undecided'."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
190 ;; (find-coding-systems-for-charsets (find-charset-region from to)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
191
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
192 ;; (defun find-coding-systems-string (string)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
193 ;; "Return a list of proper coding systems to encode STRING.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
194 ;; All coding systems in the list can safely encode any multibyte characters
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
195 ;; in STRING.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
196 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
197 ;; If STRING contains no multibyte characters, return a list of a single
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
198 ;; element `undecided'."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
199 ;; (find-coding-systems-for-charsets (find-charset-string string)))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
200
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
201 ;; (defun find-coding-systems-for-charsets (charsets)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
202 ;; "Return a list of proper coding systems to encode characters of CHARSETS.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
203 ;; CHARSETS is a list of character sets."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
204 ;; (if (or (null charsets)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
205 ;; (and (= (length charsets) 1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
206 ;; (eq 'ascii (car charsets))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
207 ;; '(undecided)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
208 ;; (setq charsets (delq 'composition charsets))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
209 ;; (let ((l (coding-system-list 'base-only))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
210 ;; (charset-preferred-codings
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
211 ;; (mapcar (function
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
212 ;; (lambda (x)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
213 ;; (if (eq x 'unknown)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
214 ;; 'raw-text
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
215 ;; (get-charset-property x 'preferred-coding-system))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
216 ;; charsets))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
217 ;; (priorities (mapcar (function (lambda (x) (symbol-value x)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
218 ;; coding-category-list))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
219 ;; codings coding safe)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
220 ;; (if (memq 'unknown charsets)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
221 ;; ;; The region contains invalid multibyte characters.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
222 ;; (setq l '(raw-text)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
223 ;; (while l
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
224 ;; (setq coding (car l) l (cdr l))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
225 ;; (if (and (setq safe (coding-system-get coding 'safe-charsets))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
226 ;; (or (eq safe t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
227 ;; (find-coding-systems-region-subset-p charsets safe)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
228 ;; ;; We put the higher priority to coding systems included
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
229 ;; ;; in CHARSET-PREFERRED-CODINGS, and within them, put the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
230 ;; ;; higher priority to coding systems which support smaller
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
231 ;; ;; number of charsets.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
232 ;; (let ((priority
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
233 ;; (+ (if (coding-system-get coding 'mime-charset) 4096 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
234 ;; (lsh (length (memq coding priorities)) 7)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
235 ;; (if (memq coding charset-preferred-codings) 64 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
236 ;; (if (> (coding-system-type coding) 0) 32 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
237 ;; (if (consp safe) (- 32 (length safe)) 0))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
238 ;; (setq codings (cons (cons priority coding) codings)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
239 ;; (mapcar 'cdr
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
240 ;; (sort codings (function (lambda (x y) (> (car x) (car y))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
241 ;; )))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
242
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
243 ;; (defun find-multibyte-characters (from to &optional maxcount excludes)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
244 ;; "Find multibyte characters in the region specified by FROM and TO.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
245 ;; If FROM is a string, find multibyte characters in the string.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
246 ;; The return value is an alist of the following format:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
247 ;; ((CHARSET COUNT CHAR ...) ...)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
248 ;; where
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
249 ;; CHARSET is a character set,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
250 ;; COUNT is a number of characters,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
251 ;; CHARs are found characters of the character set.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
252 ;; Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
253 ;; Optional 4th arg EXCLUDE is a list of character sets to be ignored.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
254 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
255 ;; For invalid characters, CHARs are actually strings."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
256 ;; (let ((chars nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
257 ;; charset char)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
258 ;; (if (stringp from)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
259 ;; (let ((idx 0))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
260 ;; (while (setq idx (string-match "[^\000-\177]" from idx))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
261 ;; (setq char (aref from idx)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
262 ;; charset (char-charset char))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
263 ;; (if (eq charset 'unknown)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
264 ;; (setq char (match-string 0)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
265 ;; (if (or (eq charset 'unknown)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
266 ;; (not (or (eq excludes t) (memq charset excludes))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
267 ;; (let ((slot (assq charset chars)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
268 ;; (if slot
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
269 ;; (if (not (memq char (nthcdr 2 slot)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
270 ;; (let ((count (nth 1 slot)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
271 ;; (setcar (cdr slot) (1+ count))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
272 ;; (if (or (not maxcount) (< count maxcount))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
273 ;; (nconc slot (list char)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
274 ;; (setq chars (cons (list charset 1 char) chars)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
275 ;; (setq idx (1+ idx))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
276 ;; (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
277 ;; (goto-char from)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
278 ;; (while (re-search-forward "[^\000-\177]" to t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
279 ;; (setq char (preceding-char)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
280 ;; charset (char-charset char))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
281 ;; (if (eq charset 'unknown)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
282 ;; (setq char (match-string 0)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
283 ;; (if (or (eq charset 'unknown)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
284 ;; (not (or (eq excludes t) (memq charset excludes))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
285 ;; (let ((slot (assq charset chars)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
286 ;; (if slot
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
287 ;; (if (not (member char (nthcdr 2 slot)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
288 ;; (let ((count (nth 1 slot)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
289 ;; (setcar (cdr slot) (1+ count))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
290 ;; (if (or (not maxcount) (< count maxcount))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
291 ;; (nconc slot (list char)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
292 ;; (setq chars (cons (list charset 1 char) chars))))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
293 ;; (nreverse chars)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
294
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
295 ;; (defvar last-coding-system-specified nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
296 ;; "Most recent coding system explicitly specified by the user when asked.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
297 ;; This variable is set whenever Emacs asks the user which coding system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
298 ;; to use in order to write a file. If you set it to nil explicitly,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
299 ;; then call `write-region', then afterward this variable will be non-nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
300 ;; only if the user was explicitly asked and specified a coding system.")
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
301
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
302 ;; (defun select-safe-coding-system (from to &optional default-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
303 ;; "Ask a user to select a safe coding system from candidates.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
304 ;; The candidates of coding systems which can safely encode a text
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
305 ;; between FROM and TO are shown in a popup window.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
306 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
307 ;; Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
308 ;; checked at first. If omitted, buffer-file-coding-system of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
309 ;; current buffer is used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
310 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
311 ;; If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
312 ;; returned without any user interaction.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
313 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
314 ;; Kludgy feature: if FROM is a string, the string is the target text,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
315 ;; and TO is ignored."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
316 ;; (or default-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
317 ;; (setq default-coding-system buffer-file-coding-system))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
318 ;; (let* ((charsets (if (stringp from) (find-charset-string from)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
319 ;; (find-charset-region from to)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
320 ;; (safe-coding-systems (find-coding-systems-for-charsets charsets)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
321 ;; (if (or (not enable-multibyte-characters)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
322 ;; (eq (car safe-coding-systems) 'undecided)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
323 ;; (eq default-coding-system 'no-conversion)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
324 ;; (and default-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
325 ;; (memq (coding-system-base default-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
326 ;; safe-coding-systems)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
327 ;; default-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
328 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
329 ;; ;; At first, change each coding system to the corresponding
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
330 ;; ;; mime-charset name if it is also a coding system.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
331 ;; (let ((l safe-coding-systems)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
332 ;; mime-charset)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
333 ;; (while l
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
334 ;; (setq mime-charset (coding-system-get (car l) 'mime-charset))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
335 ;; (if (and mime-charset (coding-system-p mime-charset))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
336 ;; (setcar l mime-charset))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
337 ;; (setq l (cdr l))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
338 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
339 ;; (let ((non-safe-chars (find-multibyte-characters
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
340 ;; from to 3
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
341 ;; (and default-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
342 ;; (coding-system-get default-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
343 ;; 'safe-charsets))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
344 ;; show-position overlays)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
345 ;; (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
346 ;; ;; Highlight characters that default-coding-system can't encode.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
347 ;; (when (integerp from)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
348 ;; (goto-char from)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
349 ;; (let ((found nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
350 ;; (while (and (not found)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
351 ;; (re-search-forward "[^\000-\177]" to t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
352 ;; (setq found (assq (char-charset (preceding-char))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
353 ;; non-safe-chars))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
354 ;; (forward-line -1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
355 ;; (setq show-position (point))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
356 ;; (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
357 ;; (while (and (< (length overlays) 256)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
358 ;; (re-search-forward "[^\000-\177]" to t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
359 ;; (let* ((char (preceding-char))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
360 ;; (charset (char-charset char)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
361 ;; (when (assq charset non-safe-chars)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
362 ;; (setq overlays (cons (make-overlay (1- (point)) (point))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
363 ;; overlays))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
364 ;; (overlay-put (car overlays) 'face 'highlight))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
365 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
366 ;; ;; At last, ask a user to select a proper coding system.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
367 ;; (unwind-protect
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
368 ;; (save-window-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
369 ;; (when show-position
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
370 ;; ;; At first, be sure to show the current buffer.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
371 ;; (set-window-buffer (selected-window) (current-buffer))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
372 ;; (set-window-start (selected-window) show-position))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
373 ;; ;; Then, show a helpful message.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
374 ;; (with-output-to-temp-buffer "*Warning*"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
375 ;; (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
376 ;; (set-buffer standard-output)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
377 ;; (insert "The target text contains the following non ASCII character(s):\n")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
378 ;; (let ((len (length non-safe-chars))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
379 ;; (shown 0))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
380 ;; (while (and non-safe-chars (< shown 3))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
381 ;; (when (> (length (car non-safe-chars)) 2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
382 ;; (setq shown (1+ shown))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
383 ;; (insert (format "%25s: " (car (car non-safe-chars))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
384 ;; (let ((l (nthcdr 2 (car non-safe-chars))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
385 ;; (while l
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
386 ;; (if (or (stringp (car l)) (char-valid-p (car l)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
387 ;; (insert (car l)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
388 ;; (setq l (cdr l))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
389 ;; (if (> (nth 1 (car non-safe-chars)) 3)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
390 ;; (insert "..."))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
391 ;; (insert "\n"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
392 ;; (setq non-safe-chars (cdr non-safe-chars)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
393 ;; (if (< shown len)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
394 ;; (insert (format "%27s\n" "..."))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
395 ;; (insert (format "\
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
396 ;; These can't be encoded safely by the coding system %s.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
397 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
398 ;; Please select one from the following safe coding systems:\n"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
399 ;; default-coding-system))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
400 ;; (let ((pos (point))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
401 ;; (fill-prefix " "))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
402 ;; (mapcar (function (lambda (x) (princ " ") (princ x)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
403 ;; safe-coding-systems)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
404 ;; (fill-region-as-paragraph pos (point)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
405 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
406 ;; ;; Read a coding system.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
407 ;; (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
408 ;; safe-coding-systems))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
409 ;; (name (completing-read
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
410 ;; (format "Select coding system (default %s): "
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
411 ;; (car safe-coding-systems))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
412 ;; safe-names nil t nil nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
413 ;; (car (car safe-names)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
414 ;; (setq last-coding-system-specified (intern name))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
415 ;; (if (integerp (coding-system-eol-type default-coding-system))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
416 ;; (setq last-coding-system-specified
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
417 ;; (coding-system-change-eol-conversion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
418 ;; last-coding-system-specified
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
419 ;; (coding-system-eol-type default-coding-system))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
420 ;; last-coding-system-specified))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
421 ;; (kill-buffer "*Warning*")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
422 ;; (while overlays
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
423 ;; (delete-overlay (car overlays))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
424 ;; (setq overlays (cdr overlays)))))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
425
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
426 ;; (setq select-safe-coding-system-function 'select-safe-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
427
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
428 ;; (defun select-message-coding-system ()
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
429 ;; "Return a coding system to encode the outgoing message of the current buffer.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
430 ;; It at first tries the first coding system found in these variables
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
431 ;; in this order:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
432 ;; (1) local value of `buffer-file-coding-system'
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
433 ;; (2) value of `sendmail-coding-system'
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
434 ;; (3) value of `default-buffer-file-coding-system'
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
435 ;; (4) value of `default-sendmail-coding-system'
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
436 ;; If the found coding system can't encode the current buffer,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
437 ;; or none of them are bound to a coding system,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
438 ;; it asks the user to select a proper coding system."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
439 ;; (let ((coding (or (and (local-variable-p 'buffer-file-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
440 ;; buffer-file-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
441 ;; sendmail-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
442 ;; default-buffer-file-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
443 ;; default-sendmail-coding-system)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
444 ;; (if (eq coding 'no-conversion)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
445 ;; ;; We should never use no-conversion for outgoing mails.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
446 ;; (setq coding nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
447 ;; (if (fboundp select-safe-coding-system-function)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
448 ;; (funcall select-safe-coding-system-function
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
449 ;; (point-min) (point-max) coding)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
450 ;; coding)))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
451
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
452 (provide 'code-cmds)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
453
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents:
diff changeset
454 ;;; code-cmds.el ends here