Q&A
前提・実現したいこと
こんにちわ,emacs初心者です.
先日,web-modeを導入したのですが,web-mode起動中は日本語入力ができなくなってしまうので,これを直したいです.
日本語入力用の設定は .emacs.d/init.el に記述してあり,web-modeでなければ問題なく動きます.
私は日本語入力切替を[変換][無変換]キーで設定しているのですが,web-mode起動中は
" is undefined"
と表示され,使えなくなってしまいます.
以下をinit.elに追記してみた結果,一応入力はできるのですが,web-modeを起動していないときの挙動と違ってしまいます(F7キーでカタカナ変換ができなかったり).
(global-set-key [henkan] #'toggle-input-method)
(global-set-key [muhenkan] #'toggle-input-method)
環境は,ubuntu18.04LTSで,emacs25を使用しています.
どこを直せばいいのか,ご教授いただきたいです.よろしくお願い致します.
発生している問題・エラーメッセージ
<henkan> is undefined <muhenkan> is undefined
該当のソースコード
[init.el の内容] ;; パッケージ機能の有効化 (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) ; MELPAリポジトリを追加する (package-initialize) ; インストールされているパッケージを初期化する ;; 環境を日本語をUTF-8にする ;; Added by Package.el. This must come before configurations of ;; installed packages. Don't delete this line. If you don't want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments. (set-locale-environment nil) (set-language-environment "Japanese") (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-buffer-file-coding-system 'utf-8) (setq default-buffer-file-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (prefer-coding-system 'utf-8) ;; ------------ web-modeの設定 ------------------------ (require 'web-mode) (add-to-list 'auto-mode-alist '(".jsp\'" . web-mode)) (add-to-list 'auto-mode-alist '(".php\'" . web-mode)) (add-to-list 'auto-mode-alist '(".ctp\'" . web-mode)) (add-to-list 'auto-mode-alist '(".html?\'" . web-mode)) (defun web-mode-hook () (setq web-mode-markup-indent-offset 2) (setq web-mode-css-indent-offset 2) (setq web-mode-code-indent-offset 2) (setq web-mode-engines-alist '(("php" . ".ctp\'")) ) ) (add-hook 'web-mode-hook 'web-mode-hook) ;; 色の設定 (custom-set-faces '(web-mode-doctype-face ((t (:foreground "#82AE46")))) '(web-mode-html-tag-face ((t (:foreground "#E6B422" :weight bold)))) '(web-mode-html-attr-name-face ((t (:foreground "#C97586")))) '(web-mode-html-attr-value-face ((t (:foreground "#82AE46")))) '(web-mode-comment-face ((t (:foreground "#D9333F")))) '(web-mode-server-comment-face ((t (:foreground "#D9333F")))) '(web-mode-css-rule-face ((t (:foreground "#A0D8EF")))) '(web-mode-css-pseudo-class-face ((t (:foreground "#FF7F00")))) '(web-mode-css-at-rule-face ((t (:foreground "#FF7F00")))) ) ;; -------------------------------------------------- ;; スタートアップメッセージを表示させない (setq inhibit-startup-message t) ;; バックアップファイルを作成させない (setq make-backup-files nil) ;; 終了時にオートセーブファイルを削除する (setq delete-auto-save-files t) ;; ウィンドウを透明にする ;; アクティブウィンドウ/非アクティブウィンドウ(alphaの値で透明度を指定) (add-to-list 'default-frame-alist '(alpha . (0.85 0.85))) ;; メニューバーを消す (menu-bar-mode -1) ;; ツールバーを消す (tool-bar-mode -1) ;; 列数を表示する (column-number-mode t) ;; 行数を表示する (global-linum-mode t) ;; カーソル行をハイライトする (global-hl-line-mode t) ;; 対応する括弧を光らせる (show-paren-mode 1) ;; ウィンドウ内に収まらないときだけ、カッコ内も光らせる (setq show-paren-style 'mixed) (set-face-background 'show-paren-match-face "grey") (set-face-foreground 'show-paren-match-face "black") ;; 文字を白に (set-foreground-color "white") ;; 背景を黒に (set-background-color "black") ;; シフト+矢印で範囲選択 (setq pc-select-selection-keys-only t) ;; "yes or no" の選択を "y or n" にする (fset 'yes-or-no-p 'y-or-n-p) ;; beep音を消す (defun my-bell-function () (unless (memq this-command '(isearch-abort abort-recursive-edit exit-minibuffer keyboard-quit mwheel-scroll down up next-line previous-line backward-char forward-char)) (ding))) (setq ring-bell-function 'my-bell-function) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages (quote (web-mode)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. )
試したこと
以下のURLの「日本語インライン入力ができるようにする」の箇所.
試した後,init.elの記述部分は消しました.
http://fanblogs.jp/iorisprogramming/archive/18/0
また,以下の設定を,init.elの「web-modeの設定」の(add-hook 'web-mode-hook 'web-mode-hook)直前に追加した結果,一応入力できるようになったのですが,
web-modeを起動していないときと挙動が違う(F7キーでカタカナ変換できないなど)ので,これも取り消しました
(global-set-key [henkan] #'toggle-input-method)
(global-set-key [muhenkan] #'toggle-input-method)
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。