[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C-c C-c for a file extension
From: |
Kevin Rodgers |
Subject: |
Re: C-c C-c for a file extension |
Date: |
Thu, 04 May 2006 17:43:43 -0600 |
User-agent: |
Thunderbird 1.5.0.2 (Windows/20060308) |
Rares Vernica wrote:
How can I define a C-c C-c command for a certain file extension.
Usuallly a file extension is associated with a major mode (via
auto-mode-alist). What does `C-h v major-mode' tell you when visiting
such a file?
For example, I have the gnuplot (.plt) file and I would like to run
"gnuplot %f" (where %f is the file name) when I press C-c C-c on that file.
Hmmm, when I visit a .plt file it's in Fundamental mode. You could
define your own Gnuplot mode (with a local keymap that binds `C-c C-c'
to an Emacs command that runs gnuplot on the visited file) and associate
it with the .plt extension (e.g. with define-generic-mode), but it'd be
a lot easier to use `M-x compile' in conjunction with this:
(defun set-gnuplot-compile-command ()
(set (make-local-variable 'compile-command)
(format "gnuplot %s" (file-name-nondirectory buffer-file-name))))
(add-hook 'find-file-hook 'set-gnuplot-compile-command)
(add-hook 'find-file-not-found-hooks 'set-gnuplot-compile-command)
--
Kevin