How to let emacs treat .XXX as .c files? [duplicate] - emacs

This question already has an answer here:
Emacs: How to use a major mode for non-standard file extension
(1 answer)
Closed 8 years ago.
I was working with .stp files and .d files, which define kernel probes in c-like syntax. So I would like them to be treated as C source files so I could see the lovely font highlight.

Here are some examples -- just put in whatever mode you need -- e.g., c-mode:
;; associates files with a particular mode.
(add-to-list 'auto-mode-alist '("\\.tex\\'" . lawlist-tex-mode))
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\.todo\\'" . lawlist-org-mode))
(add-to-list 'auto-mode-alist '("\\.done\\'" . lawlist-org-mode))
(add-to-list 'auto-mode-alist '("\\.scratch\\'" . text-mode))
(add-to-list 'auto-mode-alist '("user_prefs\\'" . text-mode))
(add-to-list 'auto-mode-alist '("\\.lisp\\'" . emacs-lisp-mode))

Related

Emacs Lisp expression for matching beginning of filename in `auto-mode-alist`

I'm trying to associate filenames like "Makefile.OSX" with makefile-mode.
I've tried various combinations such as:
(add-to-list 'auto-mode-alist '("\\^Makefile" . makefile-mode))
(add-to-list 'auto-mode-alist '("\\`Makefile" . makefile-mode))
How do I do this?
The regex specified as part of auto-mode-alist matches against the full pathname, so both of your regular expressions will never match against anything.
You probably want to use something like
(add-to-list 'auto-mode-alist '("Makefile.*\\'" . makefile-mode))
or
(add-to-list 'auto-mode-alist '("/Makefile.*\\'" . makefile-mode))

How to get Emacs Live to recognize Hoplon (hl)? [duplicate]

This question already has an answer here:
Emacs: How to use a major mode for non-standard file extension
(1 answer)
Closed 8 years ago.
Does anyone know how I can get Emacs Live to recognize Hoplon (hl)? These hl files should be treated as a clojurescript file.
If you use both HTML and s-expression syntax you may want to use the .cljs.hl and .html.hl extensions to help emacs differentiate between them. So you may want something like:
(add-to-list 'auto-mode-alist '("\\.html\\.hl\\'" . html-mode))
(add-to-list 'auto-mode-alist '("\\.cljs\\.hl\\'" . clojure-mode))
As stated in the comment(s),
(add-to-list 'auto-mode-alist '("\\.hl" . clojurescript-mode))
Should do the trick.

Enable viper-mode when I open a file in Octave mode [emacs] [duplicate]

This question already has answers here:
Viper mode in all modes
(2 answers)
Closed 8 years ago.
I've set up my emacs so that it automatically uses Octave mode when I open a .m file (really I'm working on Matlab files). I like to use viper-mode.
However, when I open a .m file, viper mode gets turned off, and I have to manually
restart it. Is there a way to modify my configuration so that viper mode stays on?
.emacs.d/init.el:
(setq viper-mode t)
(require 'viper)
(require 'vista-c-style)
(add-hook 'c-mode-common-hook 'vista-set-c-style)
(add-to-list 'auto-mode-alist '("\\.h" . c++-mode)) ;; open .h files in c++ mode
;; octave mode
(autoload 'octave-mode "octave-mod" nil t)
(setq auto-mode-alist
(cons '("\\.m$" . octave-mode) auto-mode-alist) )
;; other config (relate to org-mode) and definition of 'vista-c-style are snipped
This
(add-to-list 'viper-vi-state-mode-list 'octave-mode)
adapted from this question worked.

CEDET overriding color theme

In my .emacs file I have:
(add-to-list 'load-path (expand-file-name "emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "emacs/site/cedet/semantic"))
(add-to-list 'load-path (expand-file-name "emacs/site/cedet/speedbar"))
(add-to-list 'load-path (expand-file-name "emacs/site/cedet/eieio"))
(setq jde-check-version-flag nil)
(load-file (expand-file-name "emacs/site/cedet/common/cedet.el"))
(add-to-list 'load-path (expand-file-name "emacs/site/elib"))
(require 'jde)
(add-to-list 'load-path "~/elisp")
(add-to-list 'load-path "~/elisp/color-theme")
(require 'color-theme)
(color-theme-initialize)
(color-theme-clarity)
The top half runs JDEE, and the second half gets me the clarity color theme. My problem is, when I use JDEE, the colors for Java text revert back to what they were before I applied the color theme. This is a problem because the default colors are awful, and I'd like to have my color theme apply no matter what. Is there any way to make the color theme take priority over JDEE?
As I see in JDEE sources, it uses its own faces for Java source text, not standard font-lock faces. You need to customize JDEE faces by using M-x customize-group jde-java-font-lock-faces command... Another way to update them - add code that will assign value of standard font-lock faces to variables like jde-java-font-lock-number-face (full list is at jde-java-font-lock.el file), although JDEE defines more faces than font-lock provides.
P.S. One comment regarding loading of CEDET - if you're using cedet.el to load CEDET, then it will set load-path accordingly, so you don't need to update it manually.

Setting auto-mode-alist in emacs

I notice that the current auto-mode-alist entries all end with a single quote, for example
("\\.java\\'" . java-mode)
What is the purpose of the single quote. I would have expected to see
("\\.java$" . java-mode)
The reason I ask is that I am trying to get files with names matching regexp
^twiki\.corp.*
to open in org-mode. I have tried the following without success:
(add-to-list 'auto-mode-alist '("^twiki\\.corp" . org-mode))
(add-to-list 'auto-mode-alist '("\\'twiki\\.corp" . org-mode))
The following works:
(add-to-list 'auto-mode-alist '("twiki\\.corp" . org-mode))
but is not quite what I want since file names with twiki.corp embedded in them will be opened in org-mode.
\\' matches the empty string at the end of the string/buffer:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Backslash.html e l
$ will match the end of the line: If you have newlines in your filename (very uncommon) $ will match the newline and not the end of the string.
The regex is matched against the whole filename, so you need include "/" to match the directory seperator:
(add-to-list 'auto-mode-alist '("/twiki\\.corp" . org-mode))