From 82098c569cfc1362238a2d1e5322886ba765766a Mon Sep 17 00:00:00 2001 From: Vasily Korytov Date: Tue, 14 Oct 2014 21:56:56 +0300 Subject: auto-mode-alist now works :-) --- README.md | 15 ++++++++++++--- nginx-mode.el | 8 +++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d38f7c9..068cf1c 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,21 @@ anything else around that did quite this much. Many thanks to the authors of puppet-mode.el, from where I found a useful indentation function that I've modified to suit this situation. -Put this file into your load-path and the following into your ~/.emacs: +Put this file into your load-path and the following into your `~/.emacs`: ```lisp (require 'nginx-mode) ``` -The mode should automatically activate for files called `nginx.conf` and files under `/etc/nginx` - if not, you can add something like this to your init file: +The mode should automatically activate for files: + +1. Called `nginx.conf` +2. Files ending in `.conf` under `nginx` directory +3. All files in `nginx/sites-available` and `nginx/sites-enabled` + +If this does not work (e.g. shadowed by other packages autoload entries), this also goes to `~/.emacs`: + ```lisp -(add-to-list 'auto-mode-alist '("/etc/nginx/sites-available/.*" . nginx-mode)) +(add-to-list 'auto-mode-alist '("nginx\\.conf\\'" . nginx-mode)) +(add-to-list 'auto-mode-alist '("/nginx/.*\\.conf\\'" . nginx-mode)) +(add-to-list 'auto-mode-alist '("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode)) ``` diff --git a/nginx-mode.el b/nginx-mode.el index 8195a00..0f7cf8c 100644 --- a/nginx-mode.el +++ b/nginx-mode.el @@ -185,9 +185,11 @@ The variable nginx-indent-level controls the amount of indentation. (run-hooks 'nginx-mode-hook)) ;;;###autoload -(add-to-list 'auto-mode-alist - '("nginx\.conf$" . nginx-mode) - '("/etc/nginx/.*" . nginx-mode)) +(add-to-list 'auto-mode-alist '("nginx\\.conf\\'" . nginx-mode)) +;;;###autoload +(add-to-list 'auto-mode-alist '("/nginx/.*\\.conf\\'" . nginx-mode)) +;;;###autoload +(add-to-list 'auto-mode-alist '("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode)) (provide 'nginx-mode) -- cgit v1.2.3-54-g00ecf