Let emacs choose mode conditionally when opening files
I use the php debugger geben and nxhtml-mode -- my standard mode for editing php files. Unfortunately, these two mode开发者_如何学Cs don't mix well. Is it possible to configure emacs such a way that it enables nxhtml only conditionaly, when I open php files manually, but enables php-mode instead when the buffer is opened by geben?
Okay, I seem to have fixed it. Warning! I really don't know what I'm doing -- these are my first steps in lisp and I found it by trial and error. I've added this to the end of my .emacs file:
(require 'geben)
(defun geben-enter-php-mode ()
(let* ((local-path (buffer-file-name))
(session (and local-path (geben-source-find-session local-path))))
(if session
(let ((session nil))
(php-mode)))))
(add-hook 'find-file-hook #'geben-enter-php-mode)
精彩评论