Skip to content

Two mode

klacke edited this page Sep 13, 2010 · 1 revision

two-mode-mode.el is an Emacs Lisp mode by David Welton which makes emacs sensitive to what sort of content you are editing while editing a .yaws file. I’m using the xml-lite mode to edit HTML content and of course the erlang-mode to edit erlang. The two-mode-mode.el file is shipped with yaws. You’ll find it in the toplevel directory in the source code of yaws.

A .yaws file usually contains both. Thus to get two-mode working I have the relevant emacs file in the emacs search path:
Thus two-mode-mode.el, erlang.el and xml-lite.el or nxml-mode must be in the emacs search path. I have all these three files in $HOME/emacs Thus:

(setq load-path (append ' ("~klacke/emacs") load-path ))

And I also have

(require 'nxml-mode)

(require 'two-mode-mode)

(or (assoc "\\.yaws$" auto-mode-alist)
    (setq auto-mode-alist (cons '("\\.yaws$" . two-mode-mode)

;;; Set up for automatic mode selection
(let ((a '("\\.erl$" . erlang-mode))

      (b '("\\.hrl$" . erlang-mode)))
  (or (assoc (car a) auto-mode-alist)
      (setq auto-mode-alist (cons a auto-mode-alist)))

  (or (assoc (car c) auto-mode-alist)
      (setq auto-mode-alist (cons c auto-mode-alist)))

  (or (assoc (car b) auto-mode-alist)
      (setq auto-mode-alist (cons b auto-mode-alist))))

;;; Autoload the Erlang mode when needed.
(autoload 'erlang-mode "erlang" "Major mode for editing Erlang code." t)
(autoload 'run-erlang "erlang" "Run an inferior Erlang shell." t)

;;; Files usually not interesting to view in Emacs.
(setq completion-ignored-extensions
      (append '(".jam" ".vee" ".beam") completion-ignored-extensions))

					; Fontify my Erlang buffers
;;(setq font-lock-maximum-decoration t)
(add-hook 'erlang-mode-hook 'turn-on-font-lock)

;;; This is how I want my new Erlang files to look:
(add-hook 'erlang-new-file-hook
	  (lambda () 
	    ;; work-around for Distel, erlang-mode calls this hook in
	    ;; attach buffers when it sees that they are empty. remove
	    ;; this after a proper fix in distel or erlang.el
	    (when buffer-file-name

(setq erlang-skel-mail-address "")

;; End erlang configuration

(setq erlang-electric-semicolon-criteria nil)

You can’t perform that action at this time.