[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r105918: * lisp/progmodes/cfengine.el
From: |
Ted Zlatanov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r105918: * lisp/progmodes/cfengine.el (cfengine-auto-mode): Add convenience function. |
Date: |
Sun, 25 Sep 2011 07:52:53 -0400 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 105918
committer: Ted Zlatanov <address@hidden>
branch nick: quickfixes
timestamp: Sun 2011-09-25 07:52:53 -0400
message:
* lisp/progmodes/cfengine.el (cfengine-auto-mode): Add convenience function.
* lisp/progmodes/cfengine.el (cfengine-auto-mode): Add convenience
function that picks between cfengine 2 and 3 support
automatically. Update docs accordingly.
modified:
lisp/ChangeLog
lisp/progmodes/cfengine.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-09-24 20:58:23 +0000
+++ b/lisp/ChangeLog 2011-09-25 11:52:53 +0000
@@ -1,3 +1,9 @@
+2011-09-25 Teodor Zlatanov <address@hidden>
+
+ * progmodes/cfengine.el (cfengine-auto-mode): Add convenience
+ function that picks between cfengine 2 and 3 support
+ automatically. Update docs accordingly.
+
2011-09-22 Ken Manheimer <address@hidden>
* allout.el (allout-this-command-hid-stuff): Buffer-local variable
=== modified file 'lisp/progmodes/cfengine.el'
--- a/lisp/progmodes/cfengine.el 2011-07-01 10:12:47 +0000
+++ b/lisp/progmodes/cfengine.el 2011-09-25 11:52:53 +0000
@@ -26,16 +26,21 @@
;; Provides support for editing GNU Cfengine files, including
;; font-locking, Imenu and indention, but with no special keybindings.
-;; Possible customization for auto-mode selection:
-;; (push '(("^cfagent.conf\\'" . cfengine-mode)) auto-mode-alist)
-;; (push '(("^cf\\." . cfengine-mode)) auto-mode-alist)
-;; (push '(("\\.cf\\'" . cfengine-mode)) auto-mode-alist)
-
-;; Or, if you want to use the CFEngine 3.x support:
-
-;; (push '(("^cfagent.conf\\'" . cfengine3-mode)) auto-mode-alist)
-;; (push '(("^cf\\." . cfengine3-mode)) auto-mode-alist)
-;; (push '(("\\.cf\\'" . cfengine3-mode)) auto-mode-alist)
+;; The CFEngine 3.x support doesn't have Imenu support but patches are
+;; welcome.
+
+;; You can set it up so either cfengine-mode (2.x and earlier) or
+;; cfengine3-mode (3.x) will be picked, depending on the buffer
+;; contents:
+
+;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode))
+
+;; OR you can choose to always use a specific version, if you prefer
+;; it
+
+;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine3-mode))
+;; (add-to-list 'auto-mode-alist '("^cf\\." . cfengine-mode))
+;; (add-to-list 'auto-mode-alist '("^cfagent.conf\\'" . cfengine-mode))
;; This is not the same as the mode written by Rolf Ebert
;; <address@hidden>, distributed with cfengine-2.0.5. It does
@@ -466,6 +471,18 @@
#'cfengine-beginning-of-defun)
(set (make-local-variable 'end-of-defun-function) #'cfengine-end-of-defun))
+;;;###autoload
+(defun cfengine-auto-mode ()
+ "Choose between `cfengine-mode' and `cfengine3-mode' depending
+on the buffer contents"
+ (let ((v3 nil))
+ (save-restriction
+ (goto-char (point-min))
+ (while (not (or (eobp) v3))
+ (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>")))
+ (forward-line)))
+ (if v3 (cfengine3-mode) (cfengine-mode))))
+
(provide 'cfengine3)
(provide 'cfengine)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r105918: * lisp/progmodes/cfengine.el (cfengine-auto-mode): Add convenience function.,
Ted Zlatanov <=