Replace (default-value 'enable-multibyte-characters) with t

Since Emacs-24, (default-value 'enable-multibyte-characters) can't be
changed any more, so we can remove all code which checks this value.

* lisp/x-dnd.el (x-dnd-handle-file-name):
* lisp/w32-fns.el (w32-set-default-process-coding-system):
* lisp/textmodes/ispell.el (ispell-send-string):
* lisp/term/internal.el (dos-codepage-setup):
* lisp/tar-mode.el (tar-header-block-tokenize, tar--extract):
* lisp/startup.el (command-line):
* lisp/server.el (server-process-filter):
* lisp/net/browse-url.el (browse-url-file-url):
* lisp/menu-bar.el (menu-bar-options-menu, menu-bar-describe-menu):
* lisp/mail/sendmail.el (mail-setup):
* lisp/mail/rmail.el (rmail-mode, rmail-get-new-mail):
* lisp/mail/rfc2047.el (rfc2047-encode-message-header):
* lisp/mail/emacsbug.el (report-emacs-bug):
* lisp/international/mule-diag.el (mule-diag):
* lisp/files.el (find-file-noselect-1):
* lisp/dos-fns.el (dos-set-default-process-coding-system):
* lisp/arc-mode.el (archive-mode):
* lisp/international/mule-cmds.el (mule-menu-keymap)
(set-default-coding-systems, set-language-info)
(set-language-environment, standard-display-european-internal)
(set-locale-environment): Simplify code.
This commit is contained in:
Stefan Monnier 2018-01-25 13:35:13 -05:00
parent f44b50ffc9
commit 9107cf30c0
20 changed files with 65 additions and 141 deletions

View file

@ -2712,8 +2712,7 @@ Initialize the process filter to @var{filter}.
@item :filter-multibyte @var{multibyte}
If @var{multibyte} is non-@code{nil}, strings given to the process
filter are multibyte, otherwise they are unibyte. The default is the
default value of @code{enable-multibyte-characters}.
filter are multibyte, otherwise they are unibyte. The default is @code{t}.
@item :sentinel @var{sentinel}
Initialize the process sentinel to @var{sentinel}.

View file

@ -748,8 +748,7 @@ archive.
(or file-name-coding-system
default-file-name-coding-system
locale-coding-system))
(if (default-value 'enable-multibyte-characters)
(set-buffer-multibyte 'to))
(set-buffer-multibyte 'to)
(archive-summarize nil)
(setq buffer-read-only t)
(when (and archive-visit-single-files

View file

@ -212,9 +212,7 @@ returned unaltered."
;; Override settings chosen at startup.
(defun dos-set-default-process-coding-system ()
(setq default-process-coding-system
(if (default-value 'enable-multibyte-characters)
'(undecided-dos . undecided-dos)
'(raw-text-dos . raw-text-dos))))
'(undecided-dos . undecided-dos)))
(add-hook 'before-init-hook 'dos-set-default-process-coding-system)

View file

@ -2232,8 +2232,7 @@ Do you want to revisit the file normally now? ")
(kill-local-variable 'cursor-type)
(let ((inhibit-read-only t))
(erase-buffer))
(and (default-value 'enable-multibyte-characters)
(not rawfile)
(and (not rawfile)
(set-buffer-multibyte t))
(if rawfile
(condition-case ()

View file

@ -136,8 +136,7 @@
(expand-file-name "HELLO" data-directory))
:help "Demonstrate various character sets"))
(bindings--define-key map [set-various-coding-system]
`(menu-item "Set Coding Systems" ,set-coding-system-map
:enable (default-value 'enable-multibyte-characters)))
`(menu-item "Set Coding Systems" ,set-coding-system-map))
(bindings--define-key map [separator-input-method] menu-bar-separator)
(bindings--define-key map [describe-input-method]
@ -355,8 +354,7 @@ This also sets the following values:
(if (eq system-type 'darwin)
;; The file-name coding system on Darwin systems is always utf-8.
(setq default-file-name-coding-system 'utf-8-unix)
(if (and (default-value 'enable-multibyte-characters)
(or (not coding-system)
(if (and (or (not coding-system)
(coding-system-get coding-system 'ascii-compatible-p)))
(setq default-file-name-coding-system
(coding-system-change-eol-conversion coding-system 'unix))))
@ -1158,10 +1156,7 @@ see `language-info-alist'."
((eq key 'nonascii-translation)
(set-language-environment-nonascii-translation lang-env))
((eq key 'charset)
(set-language-environment-charset lang-env))
((and (not (default-value 'enable-multibyte-characters))
(or (eq key 'unibyte-syntax) (eq key 'unibyte-display)))
(set-language-environment-unibyte lang-env)))))
(set-language-environment-charset lang-env)))))
(defun set-language-info-internal (lang-env key info)
"Internal use only.
@ -1897,9 +1892,6 @@ the new language environment, it runs `set-language-environment-hook'."
(set-language-environment-input-method language-name)
(set-language-environment-nonascii-translation language-name)
(set-language-environment-charset language-name)
;; Unibyte setups if necessary.
(unless (default-value 'enable-multibyte-characters)
(set-language-environment-unibyte language-name))
(let ((func (get-language-info language-name 'setup-function)))
(if (functionp func)
@ -1978,28 +1970,22 @@ See `set-language-info-alist' for use in programs."
(defun standard-display-european-internal ()
;; Actually set up direct output of non-ASCII characters.
(standard-display-8bit (if (eq window-system 'pc) 128 160) 255)
;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with
;; the native font, and codes 160 and 146 stand for something very
;; different there.
(or (and (eq window-system 'pc) (not (default-value
'enable-multibyte-characters)))
(progn
;; Most X fonts used to do the wrong thing for latin-1 code 160.
(unless (and (eq window-system 'x)
;; XFree86 4 has fixed the fonts.
(string= "The XFree86 Project, Inc" (x-server-vendor))
(> (aref (number-to-string (nth 2 (x-server-version))) 0)
?3))
;; Make non-line-break space display as a plain space.
(aset standard-display-table (unibyte-char-to-multibyte 160) [32]))
;; Most Windows programs send out apostrophes as \222. Most X fonts
;; don't contain a character at that position. Map it to the ASCII
;; apostrophe. [This is actually RIGHT SINGLE QUOTATION MARK,
;; U+2019, normally from the windows-1252 character set. XFree 4
;; fonts probably have the appropriate glyph at this position,
;; so they could use standard-display-8bit. It's better to use a
;; proper windows-1252 coding system. --fx]
(aset standard-display-table (unibyte-char-to-multibyte 146) [39]))))
;; Most X fonts used to do the wrong thing for latin-1 code 160.
(unless (and (eq window-system 'x)
;; XFree86 4 has fixed the fonts.
(string= "The XFree86 Project, Inc" (x-server-vendor))
(> (aref (number-to-string (nth 2 (x-server-version))) 0)
?3))
;; Make non-line-break space display as a plain space.
(aset standard-display-table (unibyte-char-to-multibyte 160) [32]))
;; Most Windows programs send out apostrophes as \222. Most X fonts
;; don't contain a character at that position. Map it to the ASCII
;; apostrophe. [This is actually RIGHT SINGLE QUOTATION MARK,
;; U+2019, normally from the windows-1252 character set. XFree 4
;; fonts probably have the appropriate glyph at this position,
;; so they could use standard-display-8bit. It's better to use a
;; proper windows-1252 coding system. --fx]
(aset standard-display-table (unibyte-char-to-multibyte 146) [39]))
(defun set-language-environment-coding-systems (language-name)
"Do various coding system setups for language environment LANGUAGE-NAME."
@ -2665,12 +2651,8 @@ See also `locale-charset-language-names', `locale-language-names',
(unless frame
(set-language-environment language-name))
;; If the default enable-multibyte-characters is nil,
;; we are using single-byte characters,
;; so the display table and terminal coding system are irrelevant.
(when (default-value 'enable-multibyte-characters)
(set-display-table-and-terminal-coding-system
language-name coding-system frame))
(set-display-table-and-terminal-coding-system
language-name coding-system frame)
;; Set the `keyboard-coding-system' if appropriate (tty
;; only). At least X and MS Windows can generate

View file

@ -1103,8 +1103,6 @@ system which uses fontsets)."
(insert "Version of this emacs:\n " (emacs-version) "\n\n")
(insert "Configuration options:\n " system-configuration-options "\n\n")
(insert "Multibyte characters awareness:\n"
(format " default: %S\n" (default-value
'enable-multibyte-characters))
(format " current-buffer: %S\n\n" enable-multibyte-characters))
(insert "Current language environment: " current-language-environment
"\n\n")

View file

@ -286,11 +286,6 @@ usually do not have translators for other languages.\n\n")))
"LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES"
"LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG" "XMODIFIERS"))
(insert (format " locale-coding-system: %s\n" locale-coding-system))
;; Only ~ 0.2% of people from a sample of 3200 changed this from
;; the default, t.
(or (default-value 'enable-multibyte-characters)
(insert (format " default enable-multibyte-characters: %s\n"
(default-value 'enable-multibyte-characters))))
(insert "\n")
(insert (format "Major mode: %s\n"
(format-mode-line

View file

@ -290,8 +290,7 @@ Should be called narrowed to the head of the message."
(let ((rfc2047-encoding-type 'mime))
(rfc2047-encode-region (point) (point-max))))
((eq method 'default)
(if (and (default-value 'enable-multibyte-characters)
mail-parse-charset)
(if mail-parse-charset
(encode-coding-region (point) (point-max)
mail-parse-charset)))
;; We get this when CC'ing messages to newsgroups with
@ -305,18 +304,17 @@ Should be called narrowed to the head of the message."
;; in accordance with changes elsewhere.
((null method)
(rfc2047-encode-region (point) (point-max)))
;;; ((null method)
;;; (if (or (message-options-get
;;; 'rfc2047-encode-message-header-encode-any)
;;; (message-options-set
;;; 'rfc2047-encode-message-header-encode-any
;;; (y-or-n-p
;;; "Some texts are not encoded. Encode anyway?")))
;;; (rfc2047-encode-region (point-min) (point-max))
;;; (error "Cannot send unencoded text")))
;; ((null method)
;; (if (or (message-options-get
;; 'rfc2047-encode-message-header-encode-any)
;; (message-options-set
;; 'rfc2047-encode-message-header-encode-any
;; (y-or-n-p
;; "Some texts are not encoded. Encode anyway?")))
;; (rfc2047-encode-region (point-min) (point-max))
;; (error "Cannot send unencoded text")))
((mm-coding-system-p method)
(when (default-value 'enable-multibyte-characters)
(encode-coding-region (point) (point-max) method)))
(encode-coding-region (point) (point-max) method))
;; Hm.
(t)))
(goto-char (point-max))))))))

View file

@ -1331,8 +1331,7 @@ Instead, these commands are available:
(let ((finding-rmail-file (not (eq major-mode 'rmail-mode))))
(rmail-mode-2)
(when (and finding-rmail-file
(null coding-system-for-read)
(default-value 'enable-multibyte-characters))
(null coding-system-for-read))
(let ((rmail-enable-multibyte t))
(rmail-require-mime-maybe)
(rmail-convert-file-maybe)
@ -1759,7 +1758,7 @@ not be a new one). It returns non-nil if it got any new messages."
(or (eq buffer-undo-list t)
(setq buffer-undo-list nil))
(let ((all-files (if file-name (list file-name) rmail-inbox-list))
(rmail-enable-multibyte (default-value 'enable-multibyte-characters))
(rmail-enable-multibyte t)
found)
(unwind-protect
(progn

View file

@ -607,7 +607,7 @@ This also saves the value of `send-mail-function' via Customize."
(kill-local-variable 'buffer-file-coding-system)
;; This doesn't work for enable-multibyte-characters.
;; (kill-local-variable 'enable-multibyte-characters)
(set-buffer-multibyte (default-value 'enable-multibyte-characters))
(set-buffer-multibyte t)
(if current-input-method
(deactivate-input-method))

View file

@ -1379,11 +1379,7 @@ mail status in mode line"))
;; It is better not to use backquote here,
;; because that makes a bootstrapping problem
;; if you need to recompile all the Lisp files using interpreted code.
`(menu-item "Multilingual Environment" ,mule-menu-keymap
;; Most of the MULE menu actually does make sense in
;; unibyte mode, e.g. language selection.
;; :visible '(default-value 'enable-multibyte-characters)
))
`(menu-item "Multilingual Environment" ,mule-menu-keymap))
;;(setq menu-bar-final-items (cons 'mule menu-bar-final-items))
;;(bindings--define-key menu [preferences]
;; `(menu-item "Preferences" ,menu-bar-preferences-menu
@ -1697,18 +1693,14 @@ mail status in mode line"))
(bindings--define-key menu [mule-diag]
'(menu-item "Show All of Mule Status" mule-diag
:visible (default-value 'enable-multibyte-characters)
:help "Display multilingual environment settings"))
(bindings--define-key menu [describe-coding-system-briefly]
'(menu-item "Describe Coding System (Briefly)"
describe-current-coding-system-briefly
:visible (default-value 'enable-multibyte-characters)))
describe-current-coding-system-briefly))
(bindings--define-key menu [describe-coding-system]
'(menu-item "Describe Coding System..." describe-coding-system
:visible (default-value 'enable-multibyte-characters)))
'(menu-item "Describe Coding System..." describe-coding-system))
(bindings--define-key menu [describe-input-method]
'(menu-item "Describe Input Method..." describe-input-method
:visible (default-value 'enable-multibyte-characters)
:help "Keyboard layout for specific input method"))
(bindings--define-key menu [describe-language-environment]
`(menu-item "Describe Language Environment"

View file

@ -713,8 +713,7 @@ Use variable `browse-url-filename-alist' to map filenames to URLs."
(let ((coding (if (equal system-type 'windows-nt)
;; W32 pretends that file names are UTF-8 encoded.
'utf-8
(and (default-value 'enable-multibyte-characters)
(or file-name-coding-system
(and (or file-name-coding-system
default-file-name-coding-system)))))
(if coding (setq file (encode-coding-string file coding))))
(setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]"))

View file

@ -1061,9 +1061,8 @@ The following commands are accepted by the client:
;; supported any more.
(cl-assert (eq (match-end 0) (length string)))
(let ((request (substring string 0 (match-beginning 0)))
(coding-system (and (default-value 'enable-multibyte-characters)
(or file-name-coding-system
default-file-name-coding-system)))
(coding-system (or file-name-coding-system
default-file-name-coding-system))
nowait ; t if emacsclient does not want to wait for us.
frame ; Frame opened for the client (if any).
display ; Open frame on this display.

View file

@ -1159,8 +1159,7 @@ please check its value")
(let (debug-on-error-from-init-file
debug-on-error-should-be-set
(debug-on-error-initial
(if (eq init-file-debug t) 'startup init-file-debug))
(orig-enable-multibyte (default-value 'enable-multibyte-characters)))
(if (eq init-file-debug t) 'startup init-file-debug)))
(let ((debug-on-error debug-on-error-initial)
;; This function actually reads the init files.
(inner
@ -1275,23 +1274,7 @@ the `--debug-init' option to view a complete error backtrace."
(setq debug-on-error-should-be-set t
debug-on-error-from-init-file debug-on-error)))
(if debug-on-error-should-be-set
(setq debug-on-error debug-on-error-from-init-file))
(unless (or (default-value 'enable-multibyte-characters)
(eq orig-enable-multibyte (default-value
'enable-multibyte-characters)))
;; Init file changed to unibyte. Reset existing multibyte
;; buffers (probably *scratch*, *Messages*, *Minibuf-0*).
;; Arguably this should only be done if they're free of
;; multibyte characters.
(mapc (lambda (buffer)
(with-current-buffer buffer
(if enable-multibyte-characters
(set-buffer-multibyte nil))))
(buffer-list))
;; Also re-set the language environment in case it was
;; originally done before unibyte was set and is sensitive to
;; unibyte (display table, terminal coding system &c).
(set-language-environment current-language-environment)))
(setq debug-on-error debug-on-error-from-init-file)))
;; Do this here in case the init file sets mail-host-address.
(and mail-host-address

View file

@ -265,11 +265,10 @@ write-date, checksum, link-type, and link-name."
(setq name (concat (substring string tar-prefix-offset
(1- (match-end 0)))
"/" name)))
(if (default-value 'enable-multibyte-characters)
(setq name
(decode-coding-string name coding)
linkname
(decode-coding-string linkname coding)))
(setq name
(decode-coding-string name coding)
linkname
(decode-coding-string linkname coding))
(if (and (null link-p) (string-match "/\\'" name))
(setq link-p 5)) ; directory
@ -907,8 +906,7 @@ tar-file's buffer."
(if (or (not coding)
(eq (coding-system-type coding) 'undecided))
(setq coding (detect-coding-region start end t)))
(if (and (default-value 'enable-multibyte-characters)
(coding-system-get coding :for-unibyte))
(if (coding-system-get coding :for-unibyte)
(with-current-buffer buffer
(set-buffer-multibyte nil)))
(widen)

View file

@ -595,8 +595,7 @@ list. You can (and should) also run it if and when the value of
(set-selection-coding-system coding-dos)
(IT-setup-unicode-display coding-unix)
(prefer-coding-system coding-dos)
(and (default-value 'enable-multibyte-characters)
(setq unibyte-display-via-language-environment t))
(setq unibyte-display-via-language-environment t)
;; Some codepages have sporadic support for Latin-1, Greek, and
;; symbol glyphs, which don't belong to their native character
;; set. It's a nuisance to have all those glyphs here, for all

View file

@ -1818,11 +1818,9 @@ Only works for Aspell and Enchant."
(setq default-directory defdir)
(insert string)
(if (not (memq cmd cmds-to-defer))
(let (coding-system-for-read coding-system-for-write status)
(if (and (boundp 'enable-multibyte-characters)
enable-multibyte-characters)
(setq coding-system-for-read (ispell-get-coding-system)
coding-system-for-write (ispell-get-coding-system)))
(let* ((coding-system-for-read (ispell-get-coding-system))
(coding-system-for-write coding-system-for-read)
status)
(set-buffer output-buf)
(erase-buffer)
(set-buffer session-buf)

View file

@ -126,22 +126,16 @@ You should set this to t when using a non-system shell.\n\n"))))
;; (and some programs ported from Unix require it) but most will
;; produce DOS line endings on output.
(setq default-process-coding-system
(if (default-value 'enable-multibyte-characters)
'(undecided-dos . undecided-unix)
'(raw-text-dos . raw-text-unix)))
'(undecided-dos . undecided-unix))
;; Make cmdproxy default to using DOS line endings for input,
;; because some Windows programs (including command.com) require it.
(add-to-list 'process-coding-system-alist
`("[cC][mM][dD][pP][rR][oO][xX][yY]"
. ,(if (default-value 'enable-multibyte-characters)
'(undecided-dos . undecided-dos)
'(raw-text-dos . raw-text-dos))))
'("[cC][mM][dD][pP][rR][oO][xX][yY]"
. (undecided-dos . undecided-dos)))
;; plink needs DOS input when entering the password.
(add-to-list 'process-coding-system-alist
`("[pP][lL][iI][nN][kK]"
. ,(if (default-value 'enable-multibyte-characters)
'(undecided-dos . undecided-dos)
'(raw-text-dos . raw-text-dos)))))
'("[pP][lL][iI][nN][kK]"
. (undecided-dos . undecided-dos))))
(define-obsolete-function-alias 'set-default-process-coding-system
#'w32-set-default-process-coding-system "26.1")
(add-hook 'before-init-hook #'w32-set-default-process-coding-system)

View file

@ -264,9 +264,8 @@ STRING is the uri-list as a string. The URIs are separated by \\r\\n."
WINDOW is the window where the drop happened.
STRING is the file names as a string, separated by nulls."
(let ((uri-list (split-string string "[\0\r\n]" t))
(coding (and (default-value 'enable-multibyte-characters)
(or file-name-coding-system
default-file-name-coding-system)))
(coding (or file-name-coding-system
default-file-name-coding-system))
retval)
(dolist (bf uri-list)
;; If one URL is handled, treat as if the whole drop succeeded.

View file

@ -1248,10 +1248,7 @@ passed to the filter.
The filter gets two arguments: the process and the string of output.
The string argument is normally a multibyte string, except:
- if the process's input coding system is no-conversion or raw-text,
it is a unibyte string (the non-converted input), or else
- if `default-enable-multibyte-characters' is nil, it is a unibyte
string (the result of converting the decoded input multibyte
string to unibyte with `string-make-unibyte'). */)
it is a unibyte string (the non-converted input). */)
(Lisp_Object process, Lisp_Object filter)
{
CHECK_PROCESS (process);
@ -3761,8 +3758,7 @@ The stopped state is cleared by `continue-process' and set by
:filter-multibyte BOOL -- If BOOL is non-nil, strings given to the
process filter are multibyte, otherwise they are unibyte.
If this keyword is not specified, the strings are multibyte if
the default value of `enable-multibyte-characters' is non-nil.
If this keyword is not specified, the strings are multibyte.
:sentinel SENTINEL -- Install SENTINEL as the process sentinel.