diff options
author | Aaron LI <aaronly.me@outlook.com> | 2016-12-08 08:45:48 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2016-12-08 08:45:48 +0800 |
commit | b8eab647d84666930695f41a9ffa8025d6181a83 (patch) | |
tree | d5a67cabdf6731dcd23446d4615f4dbd86dd8700 /_zsh | |
parent | 81e893dad2f220372544e25db0c207ccff8d95f9 (diff) | |
download | dotfiles-b8eab647d84666930695f41a9ffa8025d6181a83.tar.bz2 |
_zsh: emacs: Force LC_CTYPE=zh_CN.UTF-8
The environment variable "LC_CTYPE=zh_CN.UTF-8" is required to be able to use
Fcitx inside Emacs (GUI).
Diffstat (limited to '_zsh')
-rw-r--r-- | _zsh/80-emacs.zsh | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/_zsh/80-emacs.zsh b/_zsh/80-emacs.zsh index 27966b9..5114cc8 100644 --- a/_zsh/80-emacs.zsh +++ b/_zsh/80-emacs.zsh @@ -8,34 +8,35 @@ # if exists emacsclient; then + function eserver() { + # NOTE: + # Force "LC_CTYPE=zh_CN.UTF-8", otherwise, the Chinese input methods + # (e.g., Fcitx) cannot be activated within Emacs (GUI) in non-Chinese + # locale (e.g., "LANG=en_US.UTF-8" while "LC_CTYPE" unset) + command env LC_CTYPE=zh_CN.UTF-8 emacs --daemon + } + function _emacsclient() { # Get list of available X windows. - X=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` + local X=$(emacsclient --alternate-editor '' \ + --eval '(x-display-list)' 2>/dev/null) if [ -z "$X" ] || [ "$X" = "nil" ]; then # Create one if there is no X window yet. - command emacsclient --alternate-editor "" --create-frame "$@" + local create_frame="--create-frame" else - # Prevent creating another X frame if there is at least one present. - command emacsclient --alternate-editor "" "$@" + local create_frame="" fi - } - # Write to stdout the path to the file opened in the current buffer - function efile() { - local cmd="(buffer-file-name (window-buffer))" - _emacsclient --eval "$cmd" | tr -d '"' + command env LC_CTYPE=zh_CN.UTF-8 emacsclient --alternate-editor "" $create_frame "$@" } + alias emacs='_emacsclient -t' # Same as 'M-x eval' but outside of Emacs alias eeval='_emacsclient --eval' # Create a new X frame alias eframe='_emacsclient --create-frame --no-wait' - - alias emacs='_emacsclient -t' - alias e=emacs - alias ef=eframe -fi # end "exists emacsclient" +fi # END: exists emacsclient # vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: # |