X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/6ddd819467d1d9d0e78f13e5a15c1af9125ae67b..0e963201d03d9229bb8ac4323291d2b0119526ed:/lisp/international/mule-cmds.el diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 61ecc8b702..79e9c7b4ad 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -1,6 +1,6 @@ ;;; mule-cmds.el --- commands for multilingual environment -*- lexical-binding:t -*- -;; Copyright (C) 1997-2014 Free Software Foundation, Inc. +;; Copyright (C) 1997-2016 Free Software Foundation, Inc. ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 ;; National Institute of Advanced Industrial Science and Technology (AIST) @@ -35,8 +35,6 @@ (defvar dos-codepage) (autoload 'widget-value "wid-edit") -(defvar mac-system-coding-system) - ;;; MULE related key bindings and menus. (defvar mule-keymap @@ -159,7 +157,7 @@ ;; very frequently while editing multilingual text. Now we can use ;; only two such keys: "\C-\\" and "\C-^", but the latter is not ;; convenient because it requires shifting on most keyboards. An -;; alternative is "\C-\]" which is now bound to `abort-recursive-edit' +;; alternative is "\C-]" which is now bound to `abort-recursive-edit' ;; but it won't be used that frequently. (define-key global-map "\C-\\" 'toggle-input-method) @@ -177,7 +175,7 @@ "\\(charset\\)" "\\)\\s-+\\)?" ;; Note starting with word-syntax character: - "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'"))) + "['`‘]\\(\\sw\\(\\sw\\|\\s_\\)+\\)['’]"))) (defun coding-system-change-eol-conversion (coding-system eol-type) "Return a coding system which differs from CODING-SYSTEM in EOL conversion. @@ -397,7 +395,7 @@ A coding system that requires automatic detection of text+encoding To prefer, for instance, utf-8, say the following: - \(prefer-coding-system 'utf-8)" + (prefer-coding-system \\='utf-8)" (interactive "zPrefer coding system: ") (if (not (and coding-system (coding-system-p coding-system))) (error "Invalid coding system `%s'" coding-system)) @@ -719,14 +717,14 @@ DEFAULT is the coding system to use by default in the query." (insert "No default coding systems to try for " (if (stringp from) (format "string \"%s\"." from) - (format "buffer `%s'." bufname))) + (format-message "buffer `%s'." bufname))) (insert "These default coding systems were tried to encode" (if (stringp from) (concat " \"" (if (> (length from) 10) (concat (substring from 0 10) "...\"") (concat from "\""))) - (format " text\nin the buffer `%s'" bufname)) + (format-message " text\nin the buffer `%s'" bufname)) ":\n") (let ((pos (point)) (fill-prefix " ")) @@ -744,7 +742,8 @@ e.g., for sending an email message.\n ") (when unsafe (insert (if rejected "The other coding systems" "However, each of them") - " encountered characters it couldn't encode:\n") + (substitute-command-keys + " encountered characters it couldn't encode:\n")) (dolist (coding unsafe) (insert (format " %s cannot encode these:" (car coding))) (let ((i 0) @@ -875,13 +874,13 @@ and TO is ignored." (setq auto-cs (car auto-cs)) (display-warning 'mule - (format "\ + (format-message "\ Invalid coding system `%s' is specified for the current buffer/file by the %s. It is highly recommended to fix it before writing to a file." (car auto-cs) (if (eq (cdr auto-cs) :coding) ":coding tag" - (format "variable `%s'" (cdr auto-cs)))) + (format-message "variable `%s'" (cdr auto-cs)))) :warning) (or (yes-or-no-p "Really proceed with writing? ") (error "Save aborted")) @@ -1271,7 +1270,7 @@ This file contains a list of libraries of Emacs input methods (LEIM) in the format of Lisp expression for registering each input method. Emacs loads this file at startup time.") -(defconst leim-list-header (format +(defconst leim-list-header (format-message ";;; %s -- list of LEIM (Library of Emacs Input Method) -*-coding: utf-8;-*- ;; ;; This file is automatically generated. @@ -1587,7 +1586,7 @@ which marks the variable `default-input-method' as set for Custom buffers." (called-interactively-p 'interactive)) (with-output-to-temp-buffer (help-buffer) (let ((elt (assoc input-method input-method-alist))) - (princ (format + (princ (format-message "Input method: %s (`%s' in mode line) for %s\n %s\n" input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))))) @@ -1698,7 +1697,7 @@ Usually, the input method inserts the intermediate key sequence, or candidate translations corresponding to the sequence, at point in the current buffer. But, if this flag is non-nil, it displays them in echo area instead." - :type 'hook + :type 'boolean :group 'mule) (defvar input-method-exit-on-invalid-key nil @@ -2173,10 +2172,11 @@ See `set-language-info-alist' for use in programs." (search-backward (symbol-name (car l))) (help-xref-button 0 'help-coding-system (car l)) (goto-char (point-max)) - (insert " (`" + (insert (substitute-command-keys " (`") (coding-system-mnemonic (car l)) - "' in mode line):\n\t" - (coding-system-doc-string (car l)) + (substitute-command-keys "' in mode line):\n\t") + (substitute-command-keys + (coding-system-doc-string (car l))) "\n") (let ((aliases (coding-system-aliases (car l)))) (when aliases @@ -2411,12 +2411,12 @@ See `set-language-info-alist' for use in programs." )) "Alist of locale regexps vs the corresponding languages and coding systems. Each element has this form: - \(LOCALE-REGEXP LANG-ENV CODING-SYSTEM) + (LOCALE-REGEXP LANG-ENV CODING-SYSTEM) The first element whose LOCALE-REGEXP matches the start of a downcased locale specifies the LANG-ENV \(language environment) and CODING-SYSTEM corresponding to that locale. If there is no appropriate language environment, the element may have this form: - \(LOCALE-REGEXP . LANG-ENV) + (LOCALE-REGEXP . LANG-ENV) In this case, LANG-ENV is one of generic language environments for an specific encoding such as \"Latin-1\" and \"UTF-8\".") @@ -2518,6 +2518,9 @@ is returned. Thus, for instance, if charset \"ISO8859-2\", ;; too, for setting things such as calendar holidays, ps-print paper ;; size, spelling dictionary. +(declare-function w32-get-console-codepage "w32proc.c" ()) +(declare-function w32-get-console-output-codepage "w32proc.c" ()) + (defun locale-translate (locale) "Expand LOCALE according to `locale-translation-file-name', if possible. For example, translate \"swedish\" into \"sv_SE.ISO8859-1\"." @@ -2599,7 +2602,18 @@ See also `locale-charset-language-names', `locale-language-names', (setq system-time-locale locale)) (if (string-match "^[a-z][a-z]" locale) - (setq current-iso639-language (intern (match-string 0 locale))))) + ;; The value of 'current-iso639-language' is matched against + ;; the ':lang' property of font-spec objects when selecting + ;; and prioritizing available fonts for displaying + ;; characters; see fontset.c. + (setq current-iso639-language + ;; The call to 'downcase' is for w32, where the + ;; MS-Windows locale names are in caps, as in "ENU", + ;; the equivalent of the Posix "en_US". Since the + ;; match mentioned above uses memq, and ':lang' + ;; properties have lower-case values, the letter-case + ;; must match exactly. + (intern (downcase (match-string 0 locale)))))) (setq woman-locale (or system-messages-locale @@ -2687,14 +2701,22 @@ See also `locale-charset-language-names', `locale-language-names', ;; On Windows, override locale-coding-system, ;; default-file-name-coding-system, keyboard-coding-system, - ;; terminal-coding-system with system codepage. + ;; terminal-coding-system with the ANSI or console codepage. (when (and (eq system-type 'windows-nt) (boundp 'w32-ansi-code-page)) - (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page)))) + (let* ((code-page-coding + (intern (format "cp%d" (if noninteractive + (w32-get-console-codepage) + w32-ansi-code-page)))) + (output-coding + (if noninteractive + (intern (format "cp%d" (w32-get-console-output-codepage))) + code-page-coding))) (when (coding-system-p code-page-coding) + (or output-coding (setq output-coding code-page-coding)) (unless frame (setq locale-coding-system code-page-coding)) (set-keyboard-coding-system code-page-coding frame) - (set-terminal-coding-system code-page-coding frame) + (set-terminal-coding-system output-coding frame) (setq default-file-name-coding-system code-page-coding)))) (when (eq system-type 'darwin) @@ -2941,6 +2963,14 @@ on encoding." ;; char with that name. (setq ucs-names `(("BELL (BEL)" . 7) ,@names))))) +(defun mule--ucs-names-annotation (name) + ;; FIXME: It would be much better to add this annotation before rather than + ;; after the char name, so the annotations are aligned. + ;; FIXME: The default behavior of displaying annotations in italics + ;; doesn't work well here. + (let ((char (assoc name ucs-names))) + (when char (format " (%c)" (cdr char))))) + (defun read-char-by-name (prompt) "Read a character by its Unicode name or hex number string. Display PROMPT and read a string that represents a character by its @@ -2964,7 +2994,9 @@ point or a number in hash notation, e.g. #o21430 for octal, prompt (lambda (string pred action) (if (eq action 'metadata) - '(metadata (category . unicode-name)) + '(metadata + (annotation-function . mule--ucs-names-annotation) + (category . unicode-name)) (complete-with-action action (ucs-names) string pred))))) (char (cond