(defun define-trivial-mode(mode-prefix file-regexp &optional command) (or command (setq command mode-prefix)) (let ((mode-command (intern (concat mode-prefix "-mode")))) (fset mode-command `(lambda () (interactive) (toggle-read-only t) (start-process ,mode-prefix nil ,command (buffer-file-name)))) (add-to-list 'auto-mode-alist (cons file-regexp mode-command))) ) (define-trivial-mode "ghostview" "\\.ps$")