aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Lorentey2005-05-03 03:01:09 +0000
committerKaroly Lorentey2005-05-03 03:01:09 +0000
commit97c57fb2b8d271b2beba317c6213ab34190bfac7 (patch)
treec91313543365d663d8cf3ee6905043380514dcd4
parent2f420fa825c961636dd4d0cf183b919bc4fe457a (diff)
downloademacs-97c57fb2b8d271b2beba317c6213ab34190bfac7.tar.gz
emacs-97c57fb2b8d271b2beba317c6213ab34190bfac7.zip
Support for ttys with different character locale settings.
* lisp/server.el (server-process-filter): Set locale environment variables from client while creating tty frames. * lisp/faces.el (tty-create-frame-with-faces): Call set-locale-environment. * lisp/international/mule-cmds.el (set-display-table-and-terminal-coding-system): Add DISPLAY parameter. Pass it to set-terminal-coding-system. (set-locale-environment): Add DISPLAY parameter. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-340
-rw-r--r--README.multi-tty170
-rw-r--r--lisp/faces.el1
-rw-r--r--lisp/international/mule-cmds.el85
-rw-r--r--lisp/server.el10
4 files changed, 140 insertions, 126 deletions
diff --git a/README.multi-tty b/README.multi-tty
index c5230c0ca54..4ad9f990a82 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -257,69 +257,72 @@ extremely unstable X server for some time while I was developing these
257patches, and running Emacs this way has saved me a number of M-x 257patches, and running Emacs this way has saved me a number of M-x
258recover-session invocations.) 258recover-session invocations.)
259 259
260I use the following two bash functions to handle my Emacs sessions: 260I use the following two bash scripts to handle my Emacs sessions:
261 261
262,----[ ~/.bash_profile 262-------------------------------------------------------connect-emacs--
263| # Usage: preload_emacs <name> [<waitp>] 263#!/bin/bash
264| # 264# Usage: connect-emacs <name> <args>...
265| # Preloads the Emacs instance called NAME in a detached screen 265#
266| # session. Does nothing if the instance is already running. If WAITP 266# Connects to the Emacs instance called NAME. Starts up the instance
267| # is non-empty, the function waits until the server starts up and 267# if it is not already running. The rest of the arguments are passed
268| # creates its socket; otherwise it returns immediately. 268# to emacsclient.
269| function preload_emacs { 269
270| local name="$1" 270name="$1"
271| local waitp="$2" 271shift
272| local screendir="/var/run/screen/S-$USER" 272
273| local serverdir="/tmp/emacs$UID" 273if [ -z "$name" ]; then
274| local emacs=emacs # Or wherever you installed your multi-tty Emacs 274 echo "Usage: connect_emacs <name> <args>..." >&2
275| 275 exit 1
276| if [ -z "$name" ]; then 276fi
277| echo "Usage: preload_emacs <name> [<waitp>]" >&2 277preload-emacs "$name" wait
278| return 1 278/usr/bin/emacsclient.emacs-multi-tty -s "$name" "$@"
279| fi 279----------------------------------------------------------------------
280| 280
281| if [ ! -e "$screendir"/*."$name" ]; then 281-------------------------------------------------------preload-emacs--
282| if [ -e "$serverdir/$name" ]; then 282#!/bin/bash
283| # Delete leftover socket (for the wait option) 283# Usage: preload-emacs <name> [<waitp>]
284| rm "$serverdir/$name" 284#
285| fi 285# Preloads the Emacs instance called NAME in a detached screen
286| screen -dmS "$name" "$emacs" -nw --eval "(setq server-name \"$name\")" -f server-start 286# session. Does nothing if the instance is already running. If WAITP
287| fi 287# is non-empty, the function waits until the server starts up and
288| if [ ! -z "$waitp" ]; then 288# creates its socket; otherwise it returns immediately.
289| while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done 289
290| fi 290name="$1"
291| return 0 291waitp="$2"
292| } 292screendir="/var/run/screen/S-$USER"
293| 293serverdir="/tmp/emacs$UID"
294| # Usage: connect_emacs <name> <args>... 294emacs=/usr/bin/emacs-multi-tty # Or wherever you installed your multi-tty Emacs
295| # 295
296| # Connects to the Emacs instance called NAME. Starts up the instance 296if [ -z "$name" ]; then
297| # if it is not already running. The rest of the arguments are passed 297 echo "Usage: preload_emacs <name> [<waitp>]" >&2
298| # to emacsclient. 298 exit 1
299| function connect_emacs { 299fi
300| local name="$1" 300
301| shift 301if [ ! -e "$screendir"/*."$name" ]; then
302| 302 if [ -e "$serverdir/$name" ]; then
303| if [ -z "$name" ]; then 303 # Delete leftover socket (for the wait option)
304| echo "Usage: connect_emacs <name> <args>..." >&2 304 rm "$serverdir/$name"
305| fi 305 fi
306| preload_emacs "$name" wait 306 screen -dmS "$name" "$emacs" -nw --eval "(setq server-name \"$name\")" -f server-start
307| emacsclient -s "$name" "$@" 307fi
308| } 308if [ ! -z "$waitp" ]; then
309| 309 while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done
310| export -f preload_emacs connect_emacs 310fi
311| 311----------------------------------------------------------------------
312| # Preload editor and gnus sessions for speedy initial connects. 312
313| preload_emacs editor 313I have the following in my profile to have two instances automatically
314| preload_emacs gnus 314preloaded for editing and email:
315`---- 315
316 316 preload-emacs editor
317,----[ ~/.bashrc 317 preload-emacs gnus
318| alias gnus="connect_emacs gnus" 318
319| alias edit="connect_emacs editor" 319It is useful to set up short aliases for connect-emacs. I use the
320| alias et="connect_emacs editor -t" 320following:
321| alias e=edit 321
322`---- 322 alias edit="connect-emacs editor"
323 alias e=edit
324 alias et="connect-emacs editor -t"
325 alias gnus="connect-emacs gnus"
323 326
324 327
325NEWS 328NEWS
@@ -406,21 +409,23 @@ THINGS TO DO
406** rif->flush_display_optional (NULL) calls should be replaced by a 409** rif->flush_display_optional (NULL) calls should be replaced by a
407 new global function. 410 new global function.
408 411
409** Support multiple character locales. 412** The set-locale-environment hack (adding the DISPLAY option) should
413 be replaced with a clean design.
410 414
411 (1) A version of `set-locale-environment' needs to be written 415** standard-display-table should be display-local.
412 for setting up display-local settings on ttys. I think 416 standard-display-european should be display-local.
413 calling set-display-table-and-terminal-coding-system and
414 set-keyboard-coding-system would be enough. The language
415 environment itself should remain a global setting.
416 417
417 (2) Have a look at Vlocale_coding_system. Seems like it would 418** Fix set-input-mode for multi-tty. It's a truly horrible interface;
418 be a tedious job to localize it, although most references 419 what if we'd blow it up into several separate functions (with a
419 use it for interfacing with libc and are therefore OK with 420 compatibility definition)?
420 the global definition.
421 421
422 Exceptions found so far: x-select-text and 422** Have a look at Vlocale_coding_system. Seems like it would be a
423 x-cut-buffer-or-selection-value. 423 tedious job to localize it, although most references use it for
424 interfacing with libc and are therefore OK with the global
425 definition.
426
427 Exceptions found so far: x-select-text and
428 x-cut-buffer-or-selection-value.
424 429
425** Have a look at fatal_error_hook. 430** Have a look at fatal_error_hook.
426 431
@@ -440,10 +445,6 @@ THINGS TO DO
440 445
441 (This is likely an error in the CVS trunk.) 446 (This is likely an error in the CVS trunk.)
442 447
443** Fix set-input-mode for multi-tty. It's a truly horrible interface;
444 what if we'd blow it up into several separate functions (with a
445 compatibility definition)?
446
447** The terminal customization files in term/*.el tend to change global 448** The terminal customization files in term/*.el tend to change global
448 parameters, which may confuse Emacs with multiple displays. Change 449 parameters, which may confuse Emacs with multiple displays. Change
449 them to tweak only frame-local settings, if possible. (They tend 450 them to tweak only frame-local settings, if possible. (They tend
@@ -497,8 +498,6 @@ THINGS TO DO
497 that's why raw terminal support is broken again. I really do need 498 that's why raw terminal support is broken again. I really do need
498 to understand input.) 499 to understand input.)
499 500
500** Maybe standard-display-table should be display-local.
501
502DIARY OF CHANGES 501DIARY OF CHANGES
503---------------- 502----------------
504 503
@@ -1042,4 +1041,13 @@ DIARY OF CHANGES
1042 1041
1043 (Nothing to do. It doesn't seem ugly any more. It's rather clever.) 1042 (Nothing to do. It doesn't seem ugly any more. It's rather clever.)
1044 1043
1044-- Support multiple character locales. A version of
1045 `set-locale-environment' needs to be written for setting up
1046 display-local settings on ttys. I think calling
1047 set-display-table-and-terminal-coding-system and
1048 set-keyboard-coding-system would be enough. The language
1049 environment itself should remain a global setting.
1050
1051 (Done, by an ugly hack.)
1052
1045;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d 1053;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
diff --git a/lisp/faces.el b/lisp/faces.el
index e7940e209b9..03b3a769955 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1782,6 +1782,7 @@ created."
1782 ;; Make sure the kill and yank functions do not touch the X clipboard. 1782 ;; Make sure the kill and yank functions do not touch the X clipboard.
1783 (modify-frame-parameters frame '((interprogram-cut-function . nil))) 1783 (modify-frame-parameters frame '((interprogram-cut-function . nil)))
1784 (modify-frame-parameters frame '((interprogram-paste-function . nil))) 1784 (modify-frame-parameters frame '((interprogram-paste-function . nil)))
1785 (set-locale-environment nil frame)
1785 (setq success t)) 1786 (setq success t))
1786 (unless success 1787 (unless success
1787 (delete-frame frame))) 1788 (delete-frame frame)))
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 8af768f91cc..b0340c60794 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -1741,7 +1741,7 @@ The default status is as follows:
1741 1741
1742(reset-language-environment) 1742(reset-language-environment)
1743 1743
1744(defun set-display-table-and-terminal-coding-system (language-name &optional coding-system) 1744(defun set-display-table-and-terminal-coding-system (language-name &optional coding-system display)
1745 "Set up the display table and terminal coding system for LANGUAGE-NAME." 1745 "Set up the display table and terminal coding system for LANGUAGE-NAME."
1746 (let ((coding (get-language-info language-name 'unibyte-display))) 1746 (let ((coding (get-language-info language-name 'unibyte-display)))
1747 (if coding 1747 (if coding
@@ -1755,7 +1755,7 @@ The default status is as follows:
1755 (dotimes (i 128) 1755 (dotimes (i 128)
1756 (aset standard-display-table (+ i 128) nil)))) 1756 (aset standard-display-table (+ i 128) nil))))
1757 (or (eq window-system 'pc) 1757 (or (eq window-system 'pc)
1758 (set-terminal-coding-system (or coding-system coding))))) 1758 (set-terminal-coding-system (or coding-system coding) display))))
1759 1759
1760(defun set-language-environment (language-name) 1760(defun set-language-environment (language-name)
1761 "Set up multi-lingual environment for using LANGUAGE-NAME. 1761 "Set up multi-lingual environment for using LANGUAGE-NAME.
@@ -2349,7 +2349,7 @@ is returned. Thus, for instance, if charset \"ISO8859-2\",
2349;; too, for setting things such as calendar holidays, ps-print paper 2349;; too, for setting things such as calendar holidays, ps-print paper
2350;; size, spelling dictionary. 2350;; size, spelling dictionary.
2351 2351
2352(defun set-locale-environment (&optional locale-name) 2352(defun set-locale-environment (&optional locale-name display)
2353 "Set up multi-lingual environment for using LOCALE-NAME. 2353 "Set up multi-lingual environment for using LOCALE-NAME.
2354This sets the language environment, the coding system priority, 2354This sets the language environment, the coding system priority,
2355the default input method and sometimes other things. 2355the default input method and sometimes other things.
@@ -2370,6 +2370,11 @@ directory named `/usr/share/locale' or `/usr/lib/locale'. LOCALE-NAME
2370will be translated according to the table specified by 2370will be translated according to the table specified by
2371`locale-translation-file-name'. 2371`locale-translation-file-name'.
2372 2372
2373If DISPLAY is non-nil, only set the keyboard coding system and
2374the terminal coding system for the given display, and don't touch
2375session-global parameters like the language environment. DISPLAY
2376may be a display id or a frame.
2377
2373See also `locale-charset-language-names', `locale-language-names', 2378See also `locale-charset-language-names', `locale-language-names',
2374`locale-preferred-coding-systems' and `locale-coding-system'." 2379`locale-preferred-coding-systems' and `locale-coding-system'."
2375 (interactive "sSet environment for locale: ") 2380 (interactive "sSet environment for locale: ")
@@ -2458,14 +2463,15 @@ See also `locale-charset-language-names', `locale-language-names',
2458 2463
2459 ;; Set up for this character set. This is now the right way 2464 ;; Set up for this character set. This is now the right way
2460 ;; to do it for both unibyte and multibyte modes. 2465 ;; to do it for both unibyte and multibyte modes.
2461 (set-language-environment language-name) 2466 (unless display
2467 (set-language-environment language-name))
2462 2468
2463 ;; If default-enable-multibyte-characters is nil, 2469 ;; If default-enable-multibyte-characters is nil,
2464 ;; we are using single-byte characters, 2470 ;; we are using single-byte characters,
2465 ;; so the display table and terminal coding system are irrelevant. 2471 ;; so the display table and terminal coding system are irrelevant.
2466 (when default-enable-multibyte-characters 2472 (when default-enable-multibyte-characters
2467 (set-display-table-and-terminal-coding-system 2473 (set-display-table-and-terminal-coding-system
2468 language-name coding-system)) 2474 language-name coding-system display))
2469 2475
2470 ;; Set the `keyboard-coding-system' if appropriate (tty 2476 ;; Set the `keyboard-coding-system' if appropriate (tty
2471 ;; only). At least X and MS Windows can generate 2477 ;; only). At least X and MS Windows can generate
@@ -2477,12 +2483,14 @@ See also `locale-charset-language-names', `locale-language-names',
2477 (let ((kcs (or coding-system 2483 (let ((kcs (or coding-system
2478 (car (get-language-info language-name 2484 (car (get-language-info language-name
2479 'coding-system))))) 2485 'coding-system)))))
2480 (if kcs (set-keyboard-coding-system kcs))) 2486 (if kcs (set-keyboard-coding-system kcs display)))
2481 2487
2482 (setq locale-coding-system 2488 (unless display
2483 (car (get-language-info language-name 'coding-priority)))) 2489 (setq locale-coding-system
2490 (car (get-language-info language-name 'coding-priority)))))
2484 2491
2485 (when (and coding-system 2492 (when (and (not display)
2493 coding-system
2486 (not (coding-system-equal coding-system 2494 (not (coding-system-equal coding-system
2487 locale-coding-system))) 2495 locale-coding-system)))
2488 (prefer-coding-system coding-system) 2496 (prefer-coding-system coding-system)
@@ -2494,9 +2502,9 @@ See also `locale-charset-language-names', `locale-language-names',
2494 (when (boundp 'w32-ansi-code-page) 2502 (when (boundp 'w32-ansi-code-page)
2495 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page)))) 2503 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page))))
2496 (when (coding-system-p code-page-coding) 2504 (when (coding-system-p code-page-coding)
2497 (setq locale-coding-system code-page-coding) 2505 (unless display (setq locale-coding-system code-page-coding))
2498 (set-keyboard-coding-system code-page-coding) 2506 (set-keyboard-coding-system code-page-coding display)
2499 (set-terminal-coding-system code-page-coding)))) 2507 (set-terminal-coding-system code-page-coding display))))
2500 2508
2501 (when (eq system-type 'darwin) 2509 (when (eq system-type 'darwin)
2502 ;; On Darwin, file names are always encoded in utf-8, no matter 2510 ;; On Darwin, file names are always encoded in utf-8, no matter
@@ -2511,32 +2519,33 @@ See also `locale-charset-language-names', `locale-language-names',
2511 2519
2512 ;; Default to A4 paper if we're not in a C, POSIX or US locale. 2520 ;; Default to A4 paper if we're not in a C, POSIX or US locale.
2513 ;; (See comments in Flocale_info.) 2521 ;; (See comments in Flocale_info.)
2514 (let ((locale locale) 2522 (unless display
2515 (paper (locale-info 'paper))) 2523 (let ((locale locale)
2516 (if paper 2524 (paper (locale-info 'paper)))
2517 ;; This will always be null at the time of writing. 2525 (if paper
2518 (cond 2526 ;; This will always be null at the time of writing.
2519 ((equal paper '(216 279)) 2527 (cond
2520 (setq ps-paper-type 'letter)) 2528 ((equal paper '(216 279))
2521 ((equal paper '(210 297)) 2529 (setq ps-paper-type 'letter))
2522 (setq ps-paper-type 'a4))) 2530 ((equal paper '(210 297))
2523 (let ((vars '("LC_ALL" "LC_PAPER" "LANG"))) 2531 (setq ps-paper-type 'a4)))
2524 (while (and vars (= 0 (length locale))) 2532 (let ((vars '("LC_ALL" "LC_PAPER" "LANG")))
2525 (setq locale (getenv (pop vars))))) 2533 (while (and vars (= 0 (length locale)))
2526 (when locale 2534 (setq locale (getenv (pop vars)))))
2527 ;; As of glibc 2.2.5, these are the only US Letter locales, 2535 (when locale
2528 ;; and the rest are A4. 2536 ;; As of glibc 2.2.5, these are the only US Letter locales,
2529 (setq ps-paper-type 2537 ;; and the rest are A4.
2530 (or (locale-name-match locale '(("c$" . letter) 2538 (setq ps-paper-type
2531 ("posix$" . letter) 2539 (or (locale-name-match locale '(("c$" . letter)
2532 (".._us" . letter) 2540 ("posix$" . letter)
2533 (".._pr" . letter) 2541 (".._us" . letter)
2534 (".._ca" . letter) 2542 (".._pr" . letter)
2535 ("enu$" . letter) ; Windows 2543 (".._ca" . letter)
2536 ("esu$" . letter) 2544 ("enu$" . letter) ; Windows
2537 ("enc$" . letter) 2545 ("esu$" . letter)
2538 ("frc$" . letter))) 2546 ("enc$" . letter)
2539 'a4)))))) 2547 ("frc$" . letter)))
2548 'a4)))))))
2540 nil) 2549 nil)
2541 2550
2542;;; Charset property 2551;;; Charset property
diff --git a/lisp/server.el b/lisp/server.el
index b822eff0ae6..ef58306a9a5 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -651,10 +651,10 @@ The following commands are accepted by the client:
651 (setq request (substring request (match-end 0))) 651 (setq request (substring request (match-end 0)))
652 (unless (server-client-get client 'version) 652 (unless (server-client-get client 'version)
653 (error "Protocol error; make sure you use the correct version of emacsclient")) 653 (error "Protocol error; make sure you use the correct version of emacsclient"))
654 ;; Set up client's environment for tgetent(3)
655 ;; according to ncurses(3).
656 (server-with-client-environment proc 654 (server-with-client-environment proc
657 ("BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" 655 ("LANG" "LC_CTYPE" "LC_ALL"
656 ;; For tgetent(3); list according to ncurses(3).
657 "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES"
658 "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" 658 "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING"
659 "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" 659 "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO"
660 "TERMINFO_DIRS" "TERMPATH") 660 "TERMINFO_DIRS" "TERMPATH")
@@ -665,10 +665,6 @@ The following commands are accepted by the client:
665 (server-client-set client 'tty (display-name frame)) 665 (server-client-set client 'tty (display-name frame))
666 (server-client-set client 'display (frame-display frame)) 666 (server-client-set client 'display (frame-display frame))
667 667
668 ;; Set up display for the remote locale.
669 ;; XXX This function has been removed from mule-cmds.el, we need to find another way.
670 ;; (configure-display-for-locale)
671
672 ;; Reply with our pid. 668 ;; Reply with our pid.
673 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n")) 669 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n"))
674 (setq dontkill t))) 670 (setq dontkill t)))