aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-07-13 11:32:18 +0300
committerEli Zaretskii2019-07-13 11:32:18 +0300
commitb2783ba6f4c663556709f524a2ff34f18072e9f3 (patch)
treed7bdc97efe5a1be3bb459c6fe630c69622f41c5b
parentbd962f7fd471a07bae1950976e066ad0c3009532 (diff)
downloademacs-b2783ba6f4c663556709f524a2ff34f18072e9f3.tar.gz
emacs-b2783ba6f4c663556709f524a2ff34f18072e9f3.zip
Avoid loading mule-util at startup
* lisp/international/mule-util.el (char-displayable-p): Move from here... * lisp/international/mule.el (char-displayable-p): ...to here. This avoids always loading mule-util at startup due to a call to 'char-displayable-p' in 'startup--setup-quote-display'.
-rw-r--r--lisp/international/mule-util.el56
-rw-r--r--lisp/international/mule.el55
2 files changed, 55 insertions, 56 deletions
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index de5e7d83231..19d6d165cfd 100644
--- a/lisp/international/mule-util.el
+++ b/lisp/international/mule-util.el
@@ -282,62 +282,6 @@ language environment LANG-ENV."
282 282
283(declare-function internal-char-font "font.c" (position &optional ch)) 283(declare-function internal-char-font "font.c" (position &optional ch))
284 284
285;;;###autoload
286(defun char-displayable-p (char)
287 "Return non-nil if we should be able to display CHAR.
288On a multi-font display, the test is only whether there is an
289appropriate font from the selected frame's fontset to display
290CHAR's charset in general. Since fonts may be specified on a
291per-character basis, this may not be accurate."
292 (cond ((< char 128)
293 ;; ASCII characters are always displayable.
294 t)
295 ((not enable-multibyte-characters)
296 ;; Maybe there's a font for it, but we can't put it in the buffer.
297 nil)
298 (t
299 (let ((font-glyph (internal-char-font nil char)))
300 (if font-glyph
301 (if (consp font-glyph)
302 ;; On a window system, a character is displayable
303 ;; if a font for that character is in the default
304 ;; face of the currently selected frame.
305 (car font-glyph)
306 ;; On a text terminal supporting glyph codes, CHAR is
307 ;; displayable if its glyph code is nonnegative.
308 (<= 0 font-glyph))
309 ;; On a text terminal without glyph codes, CHAR is displayable
310 ;; if the coding system for the terminal can encode it.
311 (let ((coding (terminal-coding-system)))
312 (when coding
313 (let ((cs-list (coding-system-get coding :charset-list)))
314 (cond
315 ((listp cs-list)
316 (catch 'tag
317 (mapc #'(lambda (charset)
318 (if (encode-char char charset)
319 (throw 'tag charset)))
320 cs-list)
321 nil))
322 ((eq cs-list 'iso-2022)
323 (catch 'tag2
324 (mapc #'(lambda (charset)
325 (if (and (plist-get (charset-plist charset)
326 :iso-final-char)
327 (encode-char char charset))
328 (throw 'tag2 charset)))
329 charset-list)
330 nil))
331 ((eq cs-list 'emacs-mule)
332 (catch 'tag3
333 (mapc #'(lambda (charset)
334 (if (and (plist-get (charset-plist charset)
335 :emacs-mule-id)
336 (encode-char char charset))
337 (throw 'tag3 charset)))
338 charset-list)
339 nil)))))))))))
340
341(defun filepos-to-bufferpos--dos (byte f) 285(defun filepos-to-bufferpos--dos (byte f)
342 (let ((eol-offset 0) 286 (let ((eol-offset 0)
343 ;; Make sure we terminate, even if BYTE falls right in the middle 287 ;; Make sure we terminate, even if BYTE falls right in the middle
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 21f3118a98e..ec6f6476888 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -481,6 +481,61 @@ Return -1 if charset isn't an ISO 2022 one."
481 (or charset 481 (or charset
482 (error "Invalid Emacs-mule charset ID: %d" charset-id)) 482 (error "Invalid Emacs-mule charset ID: %d" charset-id))
483 (make-char charset code1 code2))) 483 (make-char charset code1 code2)))
484
485(defun char-displayable-p (char)
486 "Return non-nil if we should be able to display CHAR.
487On a multi-font display, the test is only whether there is an
488appropriate font from the selected frame's fontset to display
489CHAR's charset in general. Since fonts may be specified on a
490per-character basis, this may not be accurate."
491 (cond ((< char 128)
492 ;; ASCII characters are always displayable.
493 t)
494 ((not enable-multibyte-characters)
495 ;; Maybe there's a font for it, but we can't put it in the buffer.
496 nil)
497 (t
498 (let ((font-glyph (internal-char-font nil char)))
499 (if font-glyph
500 (if (consp font-glyph)
501 ;; On a window system, a character is displayable
502 ;; if a font for that character is in the default
503 ;; face of the currently selected frame.
504 (car font-glyph)
505 ;; On a text terminal supporting glyph codes, CHAR is
506 ;; displayable if its glyph code is nonnegative.
507 (<= 0 font-glyph))
508 ;; On a text terminal without glyph codes, CHAR is displayable
509 ;; if the coding system for the terminal can encode it.
510 (let ((coding (terminal-coding-system)))
511 (when coding
512 (let ((cs-list (coding-system-get coding :charset-list)))
513 (cond
514 ((listp cs-list)
515 (catch 'tag
516 (mapc #'(lambda (charset)
517 (if (encode-char char charset)
518 (throw 'tag charset)))
519 cs-list)
520 nil))
521 ((eq cs-list 'iso-2022)
522 (catch 'tag2
523 (mapc #'(lambda (charset)
524 (if (and (plist-get (charset-plist charset)
525 :iso-final-char)
526 (encode-char char charset))
527 (throw 'tag2 charset)))
528 charset-list)
529 nil))
530 ((eq cs-list 'emacs-mule)
531 (catch 'tag3
532 (mapc #'(lambda (charset)
533 (if (and (plist-get (charset-plist charset)
534 :emacs-mule-id)
535 (encode-char char charset))
536 (throw 'tag3 charset)))
537 charset-list)
538 nil)))))))))))
484 539
485;; Save the ASCII case table in case we need it later. Some locales 540;; Save the ASCII case table in case we need it later. Some locales
486;; (such as Turkish) modify the case behavior of ASCII characters, 541;; (such as Turkish) modify the case behavior of ASCII characters,