aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Zlatanov2013-03-22 15:06:53 -0400
committerTed Zlatanov2013-03-22 15:06:53 -0400
commit9bb0d8227e104a549232b78197e0e8ca2d20371c (patch)
tree9f9b7a52310b5a9a96bdc5de1f853177f06e1f2c
parenta3454eedcd2ac3e0465b4a9da322e105174659ec (diff)
downloademacs-9bb0d8227e104a549232b78197e0e8ca2d20371c.tar.gz
emacs-9bb0d8227e104a549232b78197e0e8ca2d20371c.zip
* progmodes/cfengine.el: Use symbol motion commands instead of extending the word syntax.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/cfengine.el31
2 files changed, 22 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f3a37e307bc..ef14fd4a077 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-03-22 Teodor Zlatanov <tzz@lifelogs.com>
2
3 * progmodes/cfengine.el: Update docs to mention
4 `cfengine-auto-mode'. Use \_> and \_< instead of \> and \< for
5 symbol motion. Remove "_" from the word syntax.
6
12013-03-21 Teodor Zlatanov <tzz@lifelogs.com> 72013-03-21 Teodor Zlatanov <tzz@lifelogs.com>
2 8
3 * progmodes/cfengine.el (cfengine-common-syntax): Add "_" to word 9 * progmodes/cfengine.el (cfengine-common-syntax): Add "_" to word
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index 6b438fb06af..11eb0eeaf49 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -30,11 +30,13 @@
30;; The CFEngine 3.x support doesn't have Imenu support but patches are 30;; The CFEngine 3.x support doesn't have Imenu support but patches are
31;; welcome. 31;; welcome.
32 32
33;; By default, CFEngine 3.x syntax is used.
34
33;; You can set it up so either `cfengine2-mode' (2.x and earlier) or 35;; You can set it up so either `cfengine2-mode' (2.x and earlier) or
34;; `cfengine3-mode' (3.x) will be picked, depending on the buffer 36;; `cfengine3-mode' (3.x) will be picked, depending on the buffer
35;; contents: 37;; contents:
36 38
37;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-mode)) 39;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode))
38 40
39;; OR you can choose to always use a specific version, if you prefer 41;; OR you can choose to always use a specific version, if you prefer
40;; it: 42;; it:
@@ -181,7 +183,7 @@ This includes those for cfservd as well as cfagent.")
181 ("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face) 183 ("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
182 ("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face) 184 ("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
183 ;; Variable definitions. 185 ;; Variable definitions.
184 ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) 186 ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
185 ;; File, acl &c in group: { token ... } 187 ;; File, acl &c in group: { token ... }
186 ("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face))) 188 ("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face)))
187 189
@@ -189,9 +191,9 @@ This includes those for cfservd as well as cfagent.")
189 `( 191 `(
190 ;; Defuns. This happens early so they don't get caught by looser 192 ;; Defuns. This happens early so they don't get caught by looser
191 ;; patterns. 193 ;; patterns.
192 (,(concat "\\<" cfengine3-defuns-regex "\\>" 194 (,(concat "\\_<" cfengine3-defuns-regex "\\_>"
193 "[ \t]+\\<\\([[:alnum:]_.:]+\\)\\>" 195 "[ \t]+\\_<\\([[:alnum:]_.:]+\\)\\_>"
194 "[ \t]+\\<\\([[:alnum:]_.:]+\\)" 196 "[ \t]+\\_<\\([[:alnum:]_.:]+\\)"
195 ;; Optional parentheses with variable names inside. 197 ;; Optional parentheses with variable names inside.
196 "\\(?:(\\([^)]*\\))\\)?") 198 "\\(?:(\\([^)]*\\))\\)?")
197 (1 font-lock-builtin-face) 199 (1 font-lock-builtin-face)
@@ -212,10 +214,10 @@ This includes those for cfservd as well as cfagent.")
212 ("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face) 214 ("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face)
213 215
214 ;; Variable definitions. 216 ;; Variable definitions.
215 ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) 217 ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
216 218
217 ;; Variable types. 219 ;; Variable types.
218 (,(concat "\\<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\>") 220 (,(concat "\\_<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\_>")
219 1 font-lock-type-face))) 221 1 font-lock-type-face)))
220 222
221(defvar cfengine2-imenu-expression 223(defvar cfengine2-imenu-expression
@@ -223,9 +225,9 @@ This includes those for cfservd as well as cfagent.")
223 (regexp-opt cfengine2-actions t)) 225 (regexp-opt cfengine2-actions t))
224 ":[^:]") 226 ":[^:]")
225 1) 227 1)
226 ("Variables/classes" "\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1) 228 ("Variables/classes" "\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1)
227 ("Variables/classes" "\\<define=\\([[:alnum:]_]+\\)" 1) 229 ("Variables/classes" "\\_<define=\\([[:alnum:]_]+\\)" 1)
228 ("Variables/classes" "\\<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1)) 230 ("Variables/classes" "\\_<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1))
229 "`imenu-generic-expression' for CFEngine mode.") 231 "`imenu-generic-expression' for CFEngine mode.")
230 232
231(defun cfengine2-outline-level () 233(defun cfengine2-outline-level ()
@@ -338,7 +340,7 @@ Intended as the value of `indent-line-function'."
338Treats body/bundle blocks as defuns." 340Treats body/bundle blocks as defuns."
339 (unless (<= (current-column) (current-indentation)) 341 (unless (<= (current-column) (current-indentation))
340 (end-of-line)) 342 (end-of-line))
341 (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t) 343 (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t)
342 (beginning-of-line) 344 (beginning-of-line)
343 (goto-char (point-min))) 345 (goto-char (point-min)))
344 t) 346 t)
@@ -347,7 +349,7 @@ Treats body/bundle blocks as defuns."
347 "`end-of-defun' function for Cfengine 3 mode. 349 "`end-of-defun' function for Cfengine 3 mode.
348Treats body/bundle blocks as defuns." 350Treats body/bundle blocks as defuns."
349 (end-of-line) 351 (end-of-line)
350 (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t) 352 (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t)
351 (beginning-of-line) 353 (beginning-of-line)
352 (goto-char (point-max))) 354 (goto-char (point-max)))
353 t) 355 t)
@@ -366,7 +368,7 @@ Intended as the value of `indent-line-function'."
366 368
367 (cond 369 (cond
368 ;; Body/bundle blocks start at 0. 370 ;; Body/bundle blocks start at 0.
369 ((looking-at (concat cfengine3-defuns-regex "\\>")) 371 ((looking-at (concat cfengine3-defuns-regex "\\_>"))
370 (indent-line-to 0)) 372 (indent-line-to 0))
371 ;; Categories are indented one step. 373 ;; Categories are indented one step.
372 ((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$")) 374 ((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$"))
@@ -516,7 +518,6 @@ Intended as the value of `indent-line-function'."
516 518
517(defun cfengine-common-syntax (table) 519(defun cfengine-common-syntax (table)
518 ;; The syntax defaults seem OK to give reasonable word movement. 520 ;; The syntax defaults seem OK to give reasonable word movement.
519 (modify-syntax-entry ?w "_" table)
520 (modify-syntax-entry ?# "<" table) 521 (modify-syntax-entry ?# "<" table)
521 (modify-syntax-entry ?\n ">#" table) 522 (modify-syntax-entry ?\n ">#" table)
522 (modify-syntax-entry ?\" "\"" table) ; "string" 523 (modify-syntax-entry ?\" "\"" table) ; "string"
@@ -584,7 +585,7 @@ on the buffer contents"
584 (save-restriction 585 (save-restriction
585 (goto-char (point-min)) 586 (goto-char (point-min))
586 (while (not (or (eobp) v3)) 587 (while (not (or (eobp) v3))
587 (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>"))) 588 (setq v3 (looking-at (concat cfengine3-defuns-regex "\\_>")))
588 (forward-line))) 589 (forward-line)))
589 (if v3 (cfengine3-mode) (cfengine2-mode)))) 590 (if v3 (cfengine3-mode) (cfengine2-mode))))
590 591