diff options
| author | Karoly Lorentey | 2006-05-20 15:28:05 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2006-05-20 15:28:05 +0000 |
| commit | b34c34dae08d94ca9ab0cd50cb53f0ab0cd21491 (patch) | |
| tree | 9c3fba4677f3dc7b1261a9d34868834e395b5f02 | |
| parent | a98f16179037d21357c817701c5181ac37fec0a2 (diff) | |
| download | emacs-b34c34dae08d94ca9ab0cd50cb53f0ab0cd21491.tar.gz emacs-b34c34dae08d94ca9ab0cd50cb53f0ab0cd21491.zip | |
Don't load terminit files repeatedly. Also, don't call terminit functions more than once per terminal.
* lisp/faces.el (tty-find-type): New function.
(tty-run-terminal-initialization): Load files just once per Emacs
session, and call terminit functions just once per terminal.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-563
| -rw-r--r-- | lisp/faces.el | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/lisp/faces.el b/lisp/faces.el index ddce4c72e76..b428db0ebf0 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -1840,34 +1840,49 @@ created." | |||
| 1840 | (delete-frame frame))) | 1840 | (delete-frame frame))) |
| 1841 | frame)) | 1841 | frame)) |
| 1842 | 1842 | ||
| 1843 | (defun tty-find-type (pred type) | ||
| 1844 | "Return the longest prefix of TYPE to which PRED returns non-nil. | ||
| 1845 | TYPE should be a tty type name such as \"xterm-16color\". | ||
| 1846 | |||
| 1847 | The function tries only those prefixes that are followed by a | ||
| 1848 | dash or underscore in the original type name, like \"xterm\" in | ||
| 1849 | the above example." | ||
| 1850 | (let (hyphend) | ||
| 1851 | (while (and type | ||
| 1852 | (not (funcall pred type))) | ||
| 1853 | ;; Strip off last hyphen and what follows, then try again | ||
| 1854 | (setq type | ||
| 1855 | (if (setq hyphend (string-match "[-_][^-_]+$" type)) | ||
| 1856 | (substring type 0 hyphend) | ||
| 1857 | nil)))) | ||
| 1858 | type) | ||
| 1859 | |||
| 1843 | (defun tty-run-terminal-initialization (frame) | 1860 | (defun tty-run-terminal-initialization (frame) |
| 1844 | "Run the special initialization code for the terminal type of FRAME." | 1861 | "Run the special initialization code for the terminal type of FRAME." |
| 1845 | ;; Load library for our terminal type. | 1862 | ;; Load library for our terminal type. |
| 1846 | ;; User init file can set term-file-prefix to nil to prevent this. | 1863 | ;; User init file can set term-file-prefix to nil to prevent this. |
| 1847 | (with-selected-frame frame | 1864 | (with-selected-frame frame |
| 1848 | (unless (null term-file-prefix) | 1865 | (unless (or (null term-file-prefix) |
| 1849 | (let* ((term (frame-parameter frame 'tty-type)) | 1866 | ;; Don't reinitialize the terminal each time a new |
| 1850 | (term2 term) | 1867 | ;; frame is opened on it. |
| 1851 | hyphend term-init-func) | 1868 | (terminal-parameter frame 'terminal-initted)) |
| 1852 | (while (and term | 1869 | (let* (term-init-func) |
| 1853 | (not (load (concat term-file-prefix term) t t))) | 1870 | ;; First, load the terminal initialization file, if it is |
| 1854 | ;; Strip off last hyphen and what follows, then try again | 1871 | ;; available and it hasn't been loaded already. |
| 1855 | (setq term | 1872 | (tty-find-type #'(lambda (type) |
| 1856 | (if (setq hyphend (string-match "[-_][^-_]+$" term)) | 1873 | (let ((file (locate-library (concat term-file-prefix type)))) |
| 1857 | (substring term 0 hyphend) | 1874 | (and file |
| 1858 | nil))) | 1875 | (or (assoc file load-history) |
| 1859 | ;; The terminal file has been loaded, now find and call the | 1876 | (load file t t))))) |
| 1860 | ;; terminal specific initialization function. | 1877 | (tty-type frame)) |
| 1861 | (while (and term2 | 1878 | ;; Next, try to find a matching initialization function, and call it. |
| 1862 | (not (fboundp | 1879 | (tty-find-type #'(lambda (type) |
| 1863 | (setq term-init-func (intern (concat "terminal-init-" term2)))))) | 1880 | (fboundp (setq term-init-func |
| 1864 | ;; Strip off last hyphen and what follows, then try again | 1881 | (intern (concat "terminal-init-" type))))) |
| 1865 | (setq term2 | 1882 | (tty-type frame)) |
| 1866 | (if (setq hyphend (string-match "[-_][^-_]+$" term2)) | ||
| 1867 | (substring term2 0 hyphend) | ||
| 1868 | nil))) | ||
| 1869 | (when (fboundp term-init-func) | 1883 | (when (fboundp term-init-func) |
| 1870 | (funcall term-init-func)))))) | 1884 | (funcall term-init-func)) |
| 1885 | (set-terminal-parameter frame 'terminal-initted term-init-func))))) | ||
| 1871 | 1886 | ||
| 1872 | ;; Called from C function init_display to initialize faces of the | 1887 | ;; Called from C function init_display to initialize faces of the |
| 1873 | ;; dumped terminal frame on startup. | 1888 | ;; dumped terminal frame on startup. |