diff options
| author | Ted Zlatanov | 2013-12-13 13:18:19 -0500 |
|---|---|---|
| committer | Ted Zlatanov | 2013-12-13 13:18:19 -0500 |
| commit | 978a5fdaa35e8945920ab194213715e6f1f0bc20 (patch) | |
| tree | 8ca7a4119d07eef4065ee535cbb192cf5a907514 | |
| parent | 71e6691e5c9347f53fc984ccba83065c5e9fabaf (diff) | |
| download | emacs-978a5fdaa35e8945920ab194213715e6f1f0bc20.tar.gz emacs-978a5fdaa35e8945920ab194213715e6f1f0bc20.zip | |
Improve CFEngine 3 parsing and eldoc support, with syntax fallbacks
* progmodes/cfengine.el (cfengine-cf-promises): Add more default
locations for cf-promises.
(cfengine-mode-syntax-functions-regex): New caching variable.
(cfengine3-fallback-syntax): Fallback syntax for cases where
cf-promises doesn't run.
(cfengine3--current-word): Reimplement using
`cfengine-mode-syntax-functions-regex'.
(cfengine3-completion-function, cfengine3--current-function): Use
`cfengine3-make-syntax-cache' directly.
(cfengine3-clear-syntax-cache): New function.
(cfengine3-make-syntax-cache): Simplify and create
`cfengine-mode-syntax-functions-regex' on demand.
(cfengine3-format-function-docstring): Don't call
`cfengine3-make-syntax-cache' explicitly.
| -rw-r--r-- | lisp/ChangeLog | 17 | ||||
| -rw-r--r-- | lisp/progmodes/cfengine.el | 726 |
2 files changed, 703 insertions, 40 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b48563761c4..8bd026470d1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2013-12-13 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * progmodes/cfengine.el (cfengine-cf-promises): Add more default | ||
| 4 | locations for cf-promises. | ||
| 5 | (cfengine-mode-syntax-functions-regex): New caching variable. | ||
| 6 | (cfengine3-fallback-syntax): Fallback syntax for cases where | ||
| 7 | cf-promises doesn't run. | ||
| 8 | (cfengine3--current-word): Reimplement using | ||
| 9 | `cfengine-mode-syntax-functions-regex'. | ||
| 10 | (cfengine3-completion-function, cfengine3--current-function): Use | ||
| 11 | `cfengine3-make-syntax-cache' directly. | ||
| 12 | (cfengine3-clear-syntax-cache): New function. | ||
| 13 | (cfengine3-make-syntax-cache): Simplify and create | ||
| 14 | `cfengine-mode-syntax-functions-regex' on demand. | ||
| 15 | (cfengine3-format-function-docstring): Don't call | ||
| 16 | `cfengine3-make-syntax-cache' explicitly. | ||
| 17 | |||
| 1 | 2013-12-13 Martin Rudalics <rudalics@gmx.at> | 18 | 2013-12-13 Martin Rudalics <rudalics@gmx.at> |
| 2 | 19 | ||
| 3 | Fix windmove-find-other-window broken after pixelwise resizing | 20 | Fix windmove-find-other-window broken after pixelwise resizing |
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index a5cd863f2e1..83eec8bde62 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el | |||
| @@ -55,6 +55,9 @@ | |||
| 55 | 55 | ||
| 56 | ;;; Code: | 56 | ;;; Code: |
| 57 | 57 | ||
| 58 | (autoload 'json-read "json") | ||
| 59 | (autoload 'regexp-opt "regexp-opt") | ||
| 60 | |||
| 58 | (defgroup cfengine () | 61 | (defgroup cfengine () |
| 59 | "Editing CFEngine files." | 62 | "Editing CFEngine files." |
| 60 | :group 'languages) | 63 | :group 'languages) |
| @@ -68,11 +71,15 @@ | |||
| 68 | (or (executable-find "cf-promises") | 71 | (or (executable-find "cf-promises") |
| 69 | (executable-find "/var/cfengine/bin/cf-promises") | 72 | (executable-find "/var/cfengine/bin/cf-promises") |
| 70 | (executable-find "/usr/bin/cf-promises") | 73 | (executable-find "/usr/bin/cf-promises") |
| 74 | (executable-find "/usr/sbin/cf-promises") | ||
| 71 | (executable-find "/usr/local/bin/cf-promises") | 75 | (executable-find "/usr/local/bin/cf-promises") |
| 72 | (executable-find "~/bin/cf-promises")) | 76 | (executable-find "/usr/local/sbin/cf-promises") |
| 77 | (executable-find "~/bin/cf-promises") | ||
| 78 | (executable-find "~/sbin/cf-promises")) | ||
| 73 | "The location of the cf-promises executable. | 79 | "The location of the cf-promises executable. |
| 74 | Used for syntax discovery and checking. Set to nil to disable | 80 | Used for syntax discovery and checking. Set to nil to disable |
| 75 | the `compile-command' override and the ElDoc support." | 81 | the `compile-command' override. In that case, the ElDoc support |
| 82 | will use a fallback syntax definition." | ||
| 76 | :group 'cfengine | 83 | :group 'cfengine |
| 77 | :type 'file) | 84 | :type 'file) |
| 78 | 85 | ||
| @@ -146,6 +153,640 @@ bundle agent rcfiles | |||
| 146 | (defvar cfengine-mode-syntax-cache nil | 153 | (defvar cfengine-mode-syntax-cache nil |
| 147 | "Cache for `cfengine-mode' syntax trees obtained from 'cf-promises -s json'.") | 154 | "Cache for `cfengine-mode' syntax trees obtained from 'cf-promises -s json'.") |
| 148 | 155 | ||
| 156 | (defvar cfengine-mode-syntax-functions-regex nil) | ||
| 157 | |||
| 158 | (defconst cfengine3-fallback-syntax | ||
| 159 | '((functions | ||
| 160 | (userexists | ||
| 161 | (category . "system") (variadic . :json-false) | ||
| 162 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 163 | (returnType . "context") (status . "normal")) | ||
| 164 | (usemodule | ||
| 165 | (category . "utils") (variadic . :json-false) | ||
| 166 | (parameters . [((range . ".*") (type . "string")) | ||
| 167 | ((range . ".*") (type . "string"))]) | ||
| 168 | (returnType . "context") (status . "normal")) | ||
| 169 | (unique | ||
| 170 | (category . "data") (variadic . :json-false) | ||
| 171 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 172 | (returnType . "slist") (status . "normal")) | ||
| 173 | (translatepath | ||
| 174 | (category . "files") (variadic . :json-false) | ||
| 175 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 176 | (returnType . "string") (status . "normal")) | ||
| 177 | (sum | ||
| 178 | (category . "data") (variadic . :json-false) | ||
| 179 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 180 | (returnType . "real") (status . "normal")) | ||
| 181 | (sublist | ||
| 182 | (category . "data") (variadic . :json-false) | ||
| 183 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 184 | ((range . "head,tail") (type . "option")) | ||
| 185 | ((range . "0,99999999999") (type . "int"))]) | ||
| 186 | (returnType . "slist") (status . "normal")) | ||
| 187 | (strftime | ||
| 188 | (category . "data") (variadic . :json-false) | ||
| 189 | (parameters . [((range . "gmtime,localtime") (type . "option")) | ||
| 190 | ((range . ".*") (type . "string")) | ||
| 191 | ((range . "0,99999999999") (type . "int"))]) | ||
| 192 | (returnType . "string") (status . "normal")) | ||
| 193 | (strcmp | ||
| 194 | (category . "data") (variadic . :json-false) | ||
| 195 | (parameters . [((range . ".*") (type . "string")) | ||
| 196 | ((range . ".*") (type . "string"))]) | ||
| 197 | (returnType . "context") (status . "normal")) | ||
| 198 | (splitstring | ||
| 199 | (category . "data") (variadic . :json-false) | ||
| 200 | (parameters . [((range . ".*") (type . "string")) | ||
| 201 | ((range . ".*") (type . "string")) | ||
| 202 | ((range . "0,99999999999") (type . "int"))]) | ||
| 203 | (returnType . "slist") (status . "normal")) | ||
| 204 | (splayclass | ||
| 205 | (category . "utils") (variadic . :json-false) | ||
| 206 | (parameters . [((range . ".*") (type . "string")) | ||
| 207 | ((range . "daily,hourly") (type . "option"))]) | ||
| 208 | (returnType . "context") (status . "normal")) | ||
| 209 | (sort | ||
| 210 | (category . "data") (variadic . :json-false) | ||
| 211 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 212 | ((range . "lex") (type . "string"))]) | ||
| 213 | (returnType . "slist") (status . "normal")) | ||
| 214 | (some | ||
| 215 | (category . "data") (variadic . :json-false) | ||
| 216 | (parameters . [((range . ".*") (type . "string")) | ||
| 217 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 218 | (returnType . "context") (status . "normal")) | ||
| 219 | (shuffle | ||
| 220 | (category . "data") (variadic . :json-false) | ||
| 221 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 222 | ((range . ".*") (type . "string"))]) | ||
| 223 | (returnType . "slist") (status . "normal")) | ||
| 224 | (selectservers | ||
| 225 | (category . "communication") (variadic . :json-false) | ||
| 226 | (parameters . [((range . "@[(][a-zA-Z0-9]+[)]") (type . "string")) | ||
| 227 | ((range . "0,99999999999") (type . "int")) | ||
| 228 | ((range . ".*") (type . "string")) | ||
| 229 | ((range . ".*") (type . "string")) | ||
| 230 | ((range . "0,99999999999") (type . "int")) | ||
| 231 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 232 | (returnType . "int") (status . "normal")) | ||
| 233 | (reverse | ||
| 234 | (category . "data") (variadic . :json-false) | ||
| 235 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 236 | (returnType . "slist") (status . "normal")) | ||
| 237 | (rrange | ||
| 238 | (category . "data") (variadic . :json-false) | ||
| 239 | (parameters . [((range . "-9.99999E100,9.99999E100") (type . "real")) | ||
| 240 | ((range . "-9.99999E100,9.99999E100") (type . "real"))]) | ||
| 241 | (returnType . "rrange") (status . "normal")) | ||
| 242 | (returnszero | ||
| 243 | (category . "utils") (variadic . :json-false) | ||
| 244 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 245 | ((range . "useshell,noshell,powershell") (type . "option"))]) | ||
| 246 | (returnType . "context") (status . "normal")) | ||
| 247 | (remoteclassesmatching | ||
| 248 | (category . "communication") (variadic . :json-false) | ||
| 249 | (parameters . [((range . ".*") (type . "string")) | ||
| 250 | ((range . ".*") (type . "string")) | ||
| 251 | ((range . "true,false,yes,no,on,off") (type . "option")) | ||
| 252 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 253 | (returnType . "context") (status . "normal")) | ||
| 254 | (remotescalar | ||
| 255 | (category . "communication") (variadic . :json-false) | ||
| 256 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 257 | ((range . ".*") (type . "string")) | ||
| 258 | ((range . "true,false,yes,no,on,off") (type . "option"))]) | ||
| 259 | (returnType . "string") (status . "normal")) | ||
| 260 | (regldap | ||
| 261 | (category . "communication") (variadic . :json-false) | ||
| 262 | (parameters . [((range . ".*") (type . "string")) | ||
| 263 | ((range . ".*") (type . "string")) | ||
| 264 | ((range . ".*") (type . "string")) | ||
| 265 | ((range . ".*") (type . "string")) | ||
| 266 | ((range . "subtree,onelevel,base") (type . "option")) | ||
| 267 | ((range . ".*") (type . "string")) | ||
| 268 | ((range . "none,ssl,sasl") (type . "option"))]) | ||
| 269 | (returnType . "context") (status . "normal")) | ||
| 270 | (reglist | ||
| 271 | (category . "data") (variadic . :json-false) | ||
| 272 | (parameters . [((range . "@[(][a-zA-Z0-9]+[)]") (type . "string")) | ||
| 273 | ((range . ".*") (type . "string"))]) | ||
| 274 | (returnType . "context") (status . "normal")) | ||
| 275 | (regline | ||
| 276 | (category . "io") (variadic . :json-false) | ||
| 277 | (parameters . [((range . ".*") (type . "string")) | ||
| 278 | ((range . ".*") (type . "string"))]) | ||
| 279 | (returnType . "context") (status . "normal")) | ||
| 280 | (registryvalue | ||
| 281 | (category . "system") (variadic . :json-false) | ||
| 282 | (parameters . [((range . ".*") (type . "string")) | ||
| 283 | ((range . ".*") (type . "string"))]) | ||
| 284 | (returnType . "string") (status . "normal")) | ||
| 285 | (regextract | ||
| 286 | (category . "data") (variadic . :json-false) | ||
| 287 | (parameters . [((range . ".*") (type . "string")) | ||
| 288 | ((range . ".*") (type . "string")) | ||
| 289 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 290 | (returnType . "context") (status . "normal")) | ||
| 291 | (regcmp | ||
| 292 | (category . "data") (variadic . :json-false) | ||
| 293 | (parameters . [((range . ".*") (type . "string")) | ||
| 294 | ((range . ".*") (type . "string"))]) | ||
| 295 | (returnType . "context") (status . "normal")) | ||
| 296 | (regarray | ||
| 297 | (category . "data") (variadic . :json-false) | ||
| 298 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 299 | ((range . ".*") (type . "string"))]) | ||
| 300 | (returnType . "context") (status . "normal")) | ||
| 301 | (readtcp | ||
| 302 | (category . "communication") (variadic . :json-false) | ||
| 303 | (parameters . [((range . ".*") (type . "string")) | ||
| 304 | ((range . "0,99999999999") (type . "int")) | ||
| 305 | ((range . ".*") (type . "string")) | ||
| 306 | ((range . "0,99999999999") (type . "int"))]) | ||
| 307 | (returnType . "string") (status . "normal")) | ||
| 308 | (readstringlist | ||
| 309 | (category . "io") (variadic . :json-false) | ||
| 310 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 311 | ((range . ".*") (type . "string")) | ||
| 312 | ((range . ".*") (type . "string")) | ||
| 313 | ((range . "0,99999999999") (type . "int")) | ||
| 314 | ((range . "0,99999999999") (type . "int"))]) | ||
| 315 | (returnType . "slist") (status . "normal")) | ||
| 316 | (readstringarrayidx | ||
| 317 | (category . "io") (variadic . :json-false) | ||
| 318 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 319 | ((range . "\"?(/.*)") (type . "string")) | ||
| 320 | ((range . ".*") (type . "string")) | ||
| 321 | ((range . ".*") (type . "string")) | ||
| 322 | ((range . "0,99999999999") (type . "int")) | ||
| 323 | ((range . "0,99999999999") (type . "int"))]) | ||
| 324 | (returnType . "int") (status . "normal")) | ||
| 325 | (readstringarray | ||
| 326 | (category . "io") (variadic . :json-false) | ||
| 327 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 328 | ((range . "\"?(/.*)") (type . "string")) | ||
| 329 | ((range . ".*") (type . "string")) | ||
| 330 | ((range . ".*") (type . "string")) | ||
| 331 | ((range . "0,99999999999") (type . "int")) | ||
| 332 | ((range . "0,99999999999") (type . "int"))]) | ||
| 333 | (returnType . "int") (status . "normal")) | ||
| 334 | (readreallist | ||
| 335 | (category . "io") (variadic . :json-false) | ||
| 336 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 337 | ((range . ".*") (type . "string")) | ||
| 338 | ((range . ".*") (type . "string")) | ||
| 339 | ((range . "0,99999999999") (type . "int")) | ||
| 340 | ((range . "0,99999999999") (type . "int"))]) | ||
| 341 | (returnType . "rlist") (status . "normal")) | ||
| 342 | (readrealarray | ||
| 343 | (category . "io") (variadic . :json-false) | ||
| 344 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 345 | ((range . "\"?(/.*)") (type . "string")) | ||
| 346 | ((range . ".*") (type . "string")) | ||
| 347 | ((range . ".*") (type . "string")) | ||
| 348 | ((range . "0,99999999999") (type . "int")) | ||
| 349 | ((range . "0,99999999999") (type . "int"))]) | ||
| 350 | (returnType . "int") (status . "normal")) | ||
| 351 | (readintlist | ||
| 352 | (category . "io") (variadic . :json-false) | ||
| 353 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 354 | ((range . ".*") (type . "string")) | ||
| 355 | ((range . ".*") (type . "string")) | ||
| 356 | ((range . "0,99999999999") (type . "int")) | ||
| 357 | ((range . "0,99999999999") (type . "int"))]) | ||
| 358 | (returnType . "ilist") (status . "normal")) | ||
| 359 | (readintarray | ||
| 360 | (category . "io") (variadic . :json-false) | ||
| 361 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 362 | ((range . "\"?(/.*)") (type . "string")) | ||
| 363 | ((range . ".*") (type . "string")) | ||
| 364 | ((range . ".*") (type . "string")) | ||
| 365 | ((range . "0,99999999999") (type . "int")) | ||
| 366 | ((range . "0,99999999999") (type . "int"))]) | ||
| 367 | (returnType . "int") (status . "normal")) | ||
| 368 | (readfile | ||
| 369 | (category . "io") (variadic . :json-false) | ||
| 370 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 371 | ((range . "0,99999999999") (type . "int"))]) | ||
| 372 | (returnType . "string") (status . "normal")) | ||
| 373 | (randomint | ||
| 374 | (category . "data") (variadic . :json-false) | ||
| 375 | (parameters . [((range . "-99999999999,9999999999") (type . "int")) | ||
| 376 | ((range . "-99999999999,9999999999") (type . "int"))]) | ||
| 377 | (returnType . "int") (status . "normal")) | ||
| 378 | (product | ||
| 379 | (category . "data") (variadic . :json-false) | ||
| 380 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 381 | (returnType . "real") (status . "normal")) | ||
| 382 | (peerleaders | ||
| 383 | (category . "communication") (variadic . :json-false) | ||
| 384 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 385 | ((range . ".*") (type . "string")) | ||
| 386 | ((range . "0,99999999999") (type . "int"))]) | ||
| 387 | (returnType . "slist") (status . "normal")) | ||
| 388 | (peerleader | ||
| 389 | (category . "communication") (variadic . :json-false) | ||
| 390 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 391 | ((range . ".*") (type . "string")) | ||
| 392 | ((range . "0,99999999999") (type . "int"))]) | ||
| 393 | (returnType . "string") (status . "normal")) | ||
| 394 | (peers | ||
| 395 | (category . "communication") (variadic . :json-false) | ||
| 396 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 397 | ((range . ".*") (type . "string")) | ||
| 398 | ((range . "0,99999999999") (type . "int"))]) | ||
| 399 | (returnType . "slist") (status . "normal")) | ||
| 400 | (parsestringarrayidx | ||
| 401 | (category . "io") (variadic . :json-false) | ||
| 402 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 403 | ((range . "\"?(/.*)") (type . "string")) | ||
| 404 | ((range . ".*") (type . "string")) | ||
| 405 | ((range . ".*") (type . "string")) | ||
| 406 | ((range . "0,99999999999") (type . "int")) | ||
| 407 | ((range . "0,99999999999") (type . "int"))]) | ||
| 408 | (returnType . "int") (status . "normal")) | ||
| 409 | (parsestringarray | ||
| 410 | (category . "io") (variadic . :json-false) | ||
| 411 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 412 | ((range . "\"?(/.*)") (type . "string")) | ||
| 413 | ((range . ".*") (type . "string")) | ||
| 414 | ((range . ".*") (type . "string")) | ||
| 415 | ((range . "0,99999999999") (type . "int")) | ||
| 416 | ((range . "0,99999999999") (type . "int"))]) | ||
| 417 | (returnType . "int") (status . "normal")) | ||
| 418 | (parserealarray | ||
| 419 | (category . "io") (variadic . :json-false) | ||
| 420 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 421 | ((range . "\"?(/.*)") (type . "string")) | ||
| 422 | ((range . ".*") (type . "string")) | ||
| 423 | ((range . ".*") (type . "string")) | ||
| 424 | ((range . "0,99999999999") (type . "int")) | ||
| 425 | ((range . "0,99999999999") (type . "int"))]) | ||
| 426 | (returnType . "int") (status . "normal")) | ||
| 427 | (parseintarray | ||
| 428 | (category . "io") (variadic . :json-false) | ||
| 429 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 430 | ((range . "\"?(/.*)") (type . "string")) | ||
| 431 | ((range . ".*") (type . "string")) | ||
| 432 | ((range . ".*") (type . "string")) | ||
| 433 | ((range . "0,99999999999") (type . "int")) | ||
| 434 | ((range . "0,99999999999") (type . "int"))]) | ||
| 435 | (returnType . "int") (status . "normal")) | ||
| 436 | (or | ||
| 437 | (category . "data") (variadic . t) | ||
| 438 | (parameters . []) | ||
| 439 | (returnType . "string") (status . "normal")) | ||
| 440 | (on | ||
| 441 | (category . "data") (variadic . :json-false) | ||
| 442 | (parameters . [((range . "1970,3000") (type . "int")) | ||
| 443 | ((range . "1,12") (type . "int")) | ||
| 444 | ((range . "1,31") (type . "int")) | ||
| 445 | ((range . "0,23") (type . "int")) | ||
| 446 | ((range . "0,59") (type . "int")) | ||
| 447 | ((range . "0,59") (type . "int"))]) | ||
| 448 | (returnType . "int") (status . "normal")) | ||
| 449 | (nth | ||
| 450 | (category . "data") (variadic . :json-false) | ||
| 451 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 452 | ((range . "0,99999999999") (type . "int"))]) | ||
| 453 | (returnType . "string") (status . "normal")) | ||
| 454 | (now | ||
| 455 | (category . "system") (variadic . :json-false) | ||
| 456 | (parameters . []) | ||
| 457 | (returnType . "int") (status . "normal")) | ||
| 458 | (not | ||
| 459 | (category . "data") (variadic . :json-false) | ||
| 460 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 461 | (returnType . "string") (status . "normal")) | ||
| 462 | (none | ||
| 463 | (category . "data") (variadic . :json-false) | ||
| 464 | (parameters . [((range . ".*") (type . "string")) | ||
| 465 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 466 | (returnType . "context") (status . "normal")) | ||
| 467 | (maplist | ||
| 468 | (category . "data") (variadic . :json-false) | ||
| 469 | (parameters . [((range . ".*") (type . "string")) | ||
| 470 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 471 | (returnType . "slist") (status . "normal")) | ||
| 472 | (maparray | ||
| 473 | (category . "data") (variadic . :json-false) | ||
| 474 | (parameters . [((range . ".*") (type . "string")) | ||
| 475 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 476 | (returnType . "slist") (status . "normal")) | ||
| 477 | (lsdir | ||
| 478 | (category . "files") (variadic . :json-false) | ||
| 479 | (parameters . [((range . ".+") (type . "string")) | ||
| 480 | ((range . ".*") (type . "string")) | ||
| 481 | ((range . "true,false,yes,no,on,off") (type . "option"))]) | ||
| 482 | (returnType . "slist") (status . "normal")) | ||
| 483 | (length | ||
| 484 | (category . "data") (variadic . :json-false) | ||
| 485 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 486 | (returnType . "int") (status . "normal")) | ||
| 487 | (ldapvalue | ||
| 488 | (category . "communication") (variadic . :json-false) | ||
| 489 | (parameters . [((range . ".*") (type . "string")) | ||
| 490 | ((range . ".*") (type . "string")) | ||
| 491 | ((range . ".*") (type . "string")) | ||
| 492 | ((range . ".*") (type . "string")) | ||
| 493 | ((range . "subtree,onelevel,base") (type . "option")) | ||
| 494 | ((range . "none,ssl,sasl") (type . "option"))]) | ||
| 495 | (returnType . "string") (status . "normal")) | ||
| 496 | (ldaplist | ||
| 497 | (category . "communication") (variadic . :json-false) | ||
| 498 | (parameters . [((range . ".*") (type . "string")) | ||
| 499 | ((range . ".*") (type . "string")) | ||
| 500 | ((range . ".*") (type . "string")) | ||
| 501 | ((range . ".*") (type . "string")) | ||
| 502 | ((range . "subtree,onelevel,base") (type . "option")) | ||
| 503 | ((range . "none,ssl,sasl") (type . "option"))]) | ||
| 504 | (returnType . "slist") (status . "normal")) | ||
| 505 | (ldaparray | ||
| 506 | (category . "communication") (variadic . :json-false) | ||
| 507 | (parameters . [((range . ".*") (type . "string")) | ||
| 508 | ((range . ".*") (type . "string")) | ||
| 509 | ((range . ".*") (type . "string")) | ||
| 510 | ((range . ".*") (type . "string")) | ||
| 511 | ((range . "subtree,onelevel,base") (type . "option")) | ||
| 512 | ((range . "none,ssl,sasl") (type . "option"))]) | ||
| 513 | (returnType . "context") (status . "normal")) | ||
| 514 | (laterthan | ||
| 515 | (category . "files") (variadic . :json-false) | ||
| 516 | (parameters . [((range . "0,1000") (type . "int")) | ||
| 517 | ((range . "0,1000") (type . "int")) | ||
| 518 | ((range . "0,1000") (type . "int")) | ||
| 519 | ((range . "0,1000") (type . "int")) | ||
| 520 | ((range . "0,1000") (type . "int")) | ||
| 521 | ((range . "0,40000") (type . "int"))]) | ||
| 522 | (returnType . "context") (status . "normal")) | ||
| 523 | (lastnode | ||
| 524 | (category . "data") (variadic . :json-false) | ||
| 525 | (parameters . [((range . ".*") (type . "string")) | ||
| 526 | ((range . ".*") (type . "string"))]) | ||
| 527 | (returnType . "string") (status . "normal")) | ||
| 528 | (join | ||
| 529 | (category . "data") (variadic . :json-false) | ||
| 530 | (parameters . [((range . ".*") (type . "string")) | ||
| 531 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 532 | (returnType . "string") (status . "normal")) | ||
| 533 | (isvariable | ||
| 534 | (category . "utils") (variadic . :json-false) | ||
| 535 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 536 | (returnType . "context") (status . "normal")) | ||
| 537 | (isplain | ||
| 538 | (category . "files") (variadic . :json-false) | ||
| 539 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 540 | (returnType . "context") (status . "normal")) | ||
| 541 | (isnewerthan | ||
| 542 | (category . "files") (variadic . :json-false) | ||
| 543 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 544 | ((range . "\"?(/.*)") (type . "string"))]) | ||
| 545 | (returnType . "context") (status . "normal")) | ||
| 546 | (islink | ||
| 547 | (category . "files") (variadic . :json-false) | ||
| 548 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 549 | (returnType . "context") (status . "normal")) | ||
| 550 | (islessthan | ||
| 551 | (category . "data") (variadic . :json-false) | ||
| 552 | (parameters . [((range . ".*") (type . "string")) | ||
| 553 | ((range . ".*") (type . "string"))]) | ||
| 554 | (returnType . "context") (status . "normal")) | ||
| 555 | (isgreaterthan | ||
| 556 | (category . "data") (variadic . :json-false) | ||
| 557 | (parameters . [((range . ".*") (type . "string")) | ||
| 558 | ((range . ".*") (type . "string"))]) | ||
| 559 | (returnType . "context") (status . "normal")) | ||
| 560 | (isexecutable | ||
| 561 | (category . "files") (variadic . :json-false) | ||
| 562 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 563 | (returnType . "context") (status . "normal")) | ||
| 564 | (isdir | ||
| 565 | (category . "files") (variadic . :json-false) | ||
| 566 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 567 | (returnType . "context") (status . "normal")) | ||
| 568 | (irange | ||
| 569 | (category . "data") (variadic . :json-false) | ||
| 570 | (parameters . [((range . "-99999999999,9999999999") (type . "int")) | ||
| 571 | ((range . "-99999999999,9999999999") (type . "int"))]) | ||
| 572 | (returnType . "irange") (status . "normal")) | ||
| 573 | (iprange | ||
| 574 | (category . "communication") (variadic . :json-false) | ||
| 575 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 576 | (returnType . "context") (status . "normal")) | ||
| 577 | (intersection | ||
| 578 | (category . "data") (variadic . :json-false) | ||
| 579 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 580 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 581 | (returnType . "slist") (status . "normal")) | ||
| 582 | (ifelse | ||
| 583 | (category . "data") (variadic . t) | ||
| 584 | (parameters . []) | ||
| 585 | (returnType . "string") (status . "normal")) | ||
| 586 | (hubknowledge | ||
| 587 | (category . "communication") (variadic . :json-false) | ||
| 588 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 589 | (returnType . "string") (status . "normal")) | ||
| 590 | (hostswithclass | ||
| 591 | (category . "communication") (variadic . :json-false) | ||
| 592 | (parameters . [((range . "[a-zA-Z0-9_]+") (type . "string")) | ||
| 593 | ((range . "name,address") (type . "option"))]) | ||
| 594 | (returnType . "slist") (status . "normal")) | ||
| 595 | (hostsseen | ||
| 596 | (category . "communication") (variadic . :json-false) | ||
| 597 | (parameters . [((range . "0,99999999999") (type . "int")) | ||
| 598 | ((range . "lastseen,notseen") (type . "option")) | ||
| 599 | ((range . "name,address") (type . "option"))]) | ||
| 600 | (returnType . "slist") (status . "normal")) | ||
| 601 | (hostrange | ||
| 602 | (category . "communication") (variadic . :json-false) | ||
| 603 | (parameters . [((range . ".*") (type . "string")) | ||
| 604 | ((range . ".*") (type . "string"))]) | ||
| 605 | (returnType . "context") (status . "normal")) | ||
| 606 | (hostinnetgroup | ||
| 607 | (category . "system") (variadic . :json-false) | ||
| 608 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 609 | (returnType . "context") (status . "normal")) | ||
| 610 | (ip2host | ||
| 611 | (category . "communication") (variadic . :json-false) | ||
| 612 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 613 | (returnType . "string") (status . "normal")) | ||
| 614 | (host2ip | ||
| 615 | (category . "communication") (variadic . :json-false) | ||
| 616 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 617 | (returnType . "string") (status . "normal")) | ||
| 618 | (hashmatch | ||
| 619 | (category . "data") (variadic . :json-false) | ||
| 620 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 621 | ((range . "md5,sha1,crypt,cf_sha224,cf_sha256,cf_sha384,cf_sha512") (type . "option")) | ||
| 622 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 623 | (returnType . "context") (status . "normal")) | ||
| 624 | (hash | ||
| 625 | (category . "data") (variadic . :json-false) | ||
| 626 | (parameters . [((range . ".*") (type . "string")) | ||
| 627 | ((range . "md5,sha1,sha256,sha512,sha384,crypt") (type . "option"))]) | ||
| 628 | (returnType . "string") (status . "normal")) | ||
| 629 | (groupexists | ||
| 630 | (category . "system") (variadic . :json-false) | ||
| 631 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 632 | (returnType . "context") (status . "normal")) | ||
| 633 | (grep | ||
| 634 | (category . "data") (variadic . :json-false) | ||
| 635 | (parameters . [((range . ".*") (type . "string")) | ||
| 636 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 637 | (returnType . "slist") (status . "normal")) | ||
| 638 | (getvalues | ||
| 639 | (category . "data") (variadic . :json-false) | ||
| 640 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 641 | (returnType . "slist") (status . "normal")) | ||
| 642 | (getusers | ||
| 643 | (category . "system") (variadic . :json-false) | ||
| 644 | (parameters . [((range . ".*") (type . "string")) | ||
| 645 | ((range . ".*") (type . "string"))]) | ||
| 646 | (returnType . "slist") (status . "normal")) | ||
| 647 | (getuid | ||
| 648 | (category . "system") (variadic . :json-false) | ||
| 649 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 650 | (returnType . "int") (status . "normal")) | ||
| 651 | (getindices | ||
| 652 | (category . "data") (variadic . :json-false) | ||
| 653 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 654 | (returnType . "slist") (status . "normal")) | ||
| 655 | (getgid | ||
| 656 | (category . "data") (variadic . :json-false) | ||
| 657 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 658 | (returnType . "int") (status . "normal")) | ||
| 659 | (getfields | ||
| 660 | (category . "data") (variadic . :json-false) | ||
| 661 | (parameters . [((range . ".*") (type . "string")) | ||
| 662 | ((range . "\"?(/.*)") (type . "string")) | ||
| 663 | ((range . ".*") (type . "string")) | ||
| 664 | ((range . ".*") (type . "string"))]) | ||
| 665 | (returnType . "int") (status . "normal")) | ||
| 666 | (getenv | ||
| 667 | (category . "system") (variadic . :json-false) | ||
| 668 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 669 | ((range . "0,99999999999") (type . "int"))]) | ||
| 670 | (returnType . "string") (status . "normal")) | ||
| 671 | (format | ||
| 672 | (category . "data") (variadic . t) | ||
| 673 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 674 | (returnType . "string") (status . "normal")) | ||
| 675 | (filter | ||
| 676 | (category . "data") (variadic . :json-false) | ||
| 677 | (parameters . [((range . ".*") (type . "string")) | ||
| 678 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 679 | ((range . "true,false,yes,no,on,off") (type . "option")) | ||
| 680 | ((range . "true,false,yes,no,on,off") (type . "option")) | ||
| 681 | ((range . "0,99999999999") (type . "int"))]) | ||
| 682 | (returnType . "slist") (status . "normal")) | ||
| 683 | (filestat | ||
| 684 | (category . "files") (variadic . :json-false) | ||
| 685 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 686 | ((range . "size,gid,uid,ino,nlink,ctime,atime,mtime,mode,modeoct,permstr,permoct,type,devno,dev_minor,dev_major,basename,dirname") (type . "option"))]) | ||
| 687 | (returnType . "string") (status . "normal")) | ||
| 688 | (filesize | ||
| 689 | (category . "files") (variadic . :json-false) | ||
| 690 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 691 | (returnType . "int") (status . "normal")) | ||
| 692 | (filesexist | ||
| 693 | (category . "files") (variadic . :json-false) | ||
| 694 | (parameters . [((range . "@[(][a-zA-Z0-9]+[)]") (type . "string"))]) | ||
| 695 | (returnType . "context") (status . "normal")) | ||
| 696 | (fileexists | ||
| 697 | (category . "files") (variadic . :json-false) | ||
| 698 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 699 | (returnType . "context") (status . "normal")) | ||
| 700 | (execresult | ||
| 701 | (category . "utils") (variadic . :json-false) | ||
| 702 | (parameters . [((range . ".+") (type . "string")) | ||
| 703 | ((range . "useshell,noshell,powershell") (type . "option"))]) | ||
| 704 | (returnType . "string") (status . "normal")) | ||
| 705 | (every | ||
| 706 | (category . "data") (variadic . :json-false) | ||
| 707 | (parameters . [((range . ".*") (type . "string")) | ||
| 708 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 709 | (returnType . "context") (status . "normal")) | ||
| 710 | (escape | ||
| 711 | (category . "data") (variadic . :json-false) | ||
| 712 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 713 | (returnType . "string") (status . "normal")) | ||
| 714 | (diskfree | ||
| 715 | (category . "files") (variadic . :json-false) | ||
| 716 | (parameters . [((range . "\"?(/.*)") (type . "string"))]) | ||
| 717 | (returnType . "int") (status . "normal")) | ||
| 718 | (dirname | ||
| 719 | (category . "files") (variadic . :json-false) | ||
| 720 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 721 | (returnType . "string") (status . "normal")) | ||
| 722 | (difference | ||
| 723 | (category . "data") (variadic . :json-false) | ||
| 724 | (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string")) | ||
| 725 | ((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))]) | ||
| 726 | (returnType . "slist") (status . "normal")) | ||
| 727 | (countlinesmatching | ||
| 728 | (category . "io") (variadic . :json-false) | ||
| 729 | (parameters . [((range . ".*") (type . "string")) | ||
| 730 | ((range . "\"?(/.*)") (type . "string"))]) | ||
| 731 | (returnType . "int") (status . "normal")) | ||
| 732 | (countclassesmatching | ||
| 733 | (category . "utils") (variadic . :json-false) | ||
| 734 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 735 | (returnType . "int") (status . "normal")) | ||
| 736 | (classesmatching | ||
| 737 | (category . "utils") (variadic . :json-false) | ||
| 738 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 739 | (returnType . "slist") (status . "normal")) | ||
| 740 | (classmatch | ||
| 741 | (category . "utils") (variadic . :json-false) | ||
| 742 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 743 | (returnType . "context") (status . "normal")) | ||
| 744 | (classify | ||
| 745 | (category . "data") (variadic . :json-false) | ||
| 746 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 747 | (returnType . "context") (status . "normal")) | ||
| 748 | (changedbefore | ||
| 749 | (category . "files") (variadic . :json-false) | ||
| 750 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 751 | ((range . "\"?(/.*)") (type . "string"))]) | ||
| 752 | (returnType . "context") (status . "normal")) | ||
| 753 | (concat | ||
| 754 | (category . "data") (variadic . t) | ||
| 755 | (parameters . []) | ||
| 756 | (returnType . "string") (status . "normal")) | ||
| 757 | (canonify | ||
| 758 | (category . "data") (variadic . :json-false) | ||
| 759 | (parameters . [((range . ".*") (type . "string"))]) | ||
| 760 | (returnType . "string") (status . "normal")) | ||
| 761 | (and | ||
| 762 | (category . "data") (variadic . t) | ||
| 763 | (parameters . []) | ||
| 764 | (returnType . "string") (status . "normal")) | ||
| 765 | (ago | ||
| 766 | (category . "data") (variadic . :json-false) | ||
| 767 | (parameters . [((range . "0,1000") (type . "int")) | ||
| 768 | ((range . "0,1000") (type . "int")) | ||
| 769 | ((range . "0,1000") (type . "int")) | ||
| 770 | ((range . "0,1000") (type . "int")) | ||
| 771 | ((range . "0,1000") (type . "int")) | ||
| 772 | ((range . "0,40000") (type . "int"))]) | ||
| 773 | (returnType . "int") (status . "normal")) | ||
| 774 | (accumulated | ||
| 775 | (category . "data") (variadic . :json-false) | ||
| 776 | (parameters . [((range . "0,1000") (type . "int")) | ||
| 777 | ((range . "0,1000") (type . "int")) | ||
| 778 | ((range . "0,1000") (type . "int")) | ||
| 779 | ((range . "0,1000") (type . "int")) | ||
| 780 | ((range . "0,1000") (type . "int")) | ||
| 781 | ((range . "0,40000") (type . "int"))]) | ||
| 782 | (returnType . "int") (status . "normal")) | ||
| 783 | (accessedbefore | ||
| 784 | (category . "files") (variadic . :json-false) | ||
| 785 | (parameters . [((range . "\"?(/.*)") (type . "string")) | ||
| 786 | ((range . "\"?(/.*)") (type . "string"))]) | ||
| 787 | (returnType . "context") (status . "normal")))) | ||
| 788 | "Fallback CFEngine syntax, containing just function definitions.") | ||
| 789 | |||
| 149 | (defcustom cfengine-mode-abbrevs nil | 790 | (defcustom cfengine-mode-abbrevs nil |
| 150 | "Abbrevs for CFEngine2 mode." | 791 | "Abbrevs for CFEngine2 mode." |
| 151 | :group 'cfengine | 792 | :group 'cfengine |
| @@ -520,31 +1161,24 @@ Intended as the value of `indent-line-function'." | |||
| 520 | ;; CLASS: [.|&!()a-zA-Z0-9_\200-\377]+:: | 1161 | ;; CLASS: [.|&!()a-zA-Z0-9_\200-\377]+:: |
| 521 | ;; CATEGORY: [a-zA-Z_]+: | 1162 | ;; CATEGORY: [a-zA-Z_]+: |
| 522 | 1163 | ||
| 523 | (defun cfengine3--current-word (&optional bounds) | 1164 | (defun cfengine3--current-word (flist &optional bounds) |
| 524 | "Propose a word around point in the current CFEngine 3 buffer." | 1165 | "Propose a word around point in the current CFEngine 3 buffer." |
| 525 | (let ((c (char-after (point))) | 1166 | (save-excursion |
| 526 | (s (syntax-ppss))) | 1167 | (skip-syntax-forward "w_") |
| 527 | (when (not (nth 3 s)) ; not inside a string | 1168 | (when (search-backward-regexp |
| 1169 | cfengine-mode-syntax-functions-regex | ||
| 1170 | (point-at-bol) | ||
| 1171 | t) | ||
| 528 | (if bounds | 1172 | (if bounds |
| 529 | (save-excursion | 1173 | (list (point) (match-end 1)) |
| 530 | (let ((oldpoint (point)) | 1174 | (match-string 1))))) |
| 531 | start end) | ||
| 532 | (skip-syntax-backward "w_") (setq start (point)) | ||
| 533 | (goto-char oldpoint) | ||
| 534 | (skip-syntax-forward "w_") (setq end (point)) | ||
| 535 | (when (not (and (eq start oldpoint) | ||
| 536 | (eq end oldpoint))) | ||
| 537 | (list start (point))))) | ||
| 538 | (and c | ||
| 539 | (memq (char-syntax c) '(?_ ?w)) | ||
| 540 | (current-word)))))) | ||
| 541 | 1175 | ||
| 542 | (defun cfengine3--current-function () | 1176 | (defun cfengine3--current-function () |
| 543 | "Look up current CFEngine 3 function" | 1177 | "Look up current CFEngine 3 function" |
| 544 | (let* ((syntax (assoc cfengine-cf-promises cfengine-mode-syntax-cache)) | 1178 | (let* ((syntax (cfengine3-make-syntax-cache)) |
| 545 | (flist (assoc 'functions syntax))) | 1179 | (flist (assoc 'functions syntax))) |
| 546 | (when flist | 1180 | (when flist |
| 547 | (let ((w (cfengine3--current-word))) | 1181 | (let ((w (cfengine3--current-word flist))) |
| 548 | (and w (assq (intern w) flist)))))) | 1182 | (and w (assq (intern w) flist)))))) |
| 549 | 1183 | ||
| 550 | ;; format from "cf-promises -s json", e.g. "sort" function: | 1184 | ;; format from "cf-promises -s json", e.g. "sort" function: |
| @@ -590,33 +1224,45 @@ Intended as the value of `indent-line-function'." | |||
| 590 | (if has-some-parameters ", ..." "...") | 1224 | (if has-some-parameters ", ..." "...") |
| 591 | "")))) | 1225 | "")))) |
| 592 | 1226 | ||
| 1227 | (defun cfengine3-clear-syntax-cache () | ||
| 1228 | (interactive) | ||
| 1229 | (setq cfengine-mode-syntax-functions-regex nil) | ||
| 1230 | (setq cfengine-mode-syntax-cache nil)) | ||
| 1231 | |||
| 593 | (defun cfengine3-make-syntax-cache () | 1232 | (defun cfengine3-make-syntax-cache () |
| 594 | "Build the CFEngine 3 syntax cache. | 1233 | "Build the CFEngine 3 syntax cache. |
| 595 | Calls `cfengine-cf-promises' with \"-s json\"" | 1234 | Calls `cfengine-cf-promises' with \"-s json\"" |
| 596 | (when cfengine-cf-promises | 1235 | (let ((ret (if cfengine-cf-promises |
| 597 | (let ((loaded-json-lib (require 'json nil t)) | 1236 | (let ((loaded-json-lib (require 'json nil t)) |
| 598 | (syntax (assoc cfengine-cf-promises cfengine-mode-syntax-cache))) | 1237 | (syntax (cfengine3-make-syntax-cache))) |
| 599 | (if (not loaded-json-lib) | 1238 | (if (not loaded-json-lib) |
| 600 | (message "JSON library could not be loaded!") | 1239 | (message "JSON library could not be loaded!") |
| 601 | (unless syntax | 1240 | (unless syntax |
| 602 | (with-demoted-errors | 1241 | (with-demoted-errors |
| 603 | (with-temp-buffer | 1242 | (with-temp-buffer |
| 604 | (call-process-shell-command cfengine-cf-promises | 1243 | (call-process-shell-command cfengine-cf-promises |
| 605 | nil ; no input | 1244 | nil ; no input |
| 606 | t ; current buffer | 1245 | t ; current buffer |
| 607 | nil ; no redisplay | 1246 | nil ; no redisplay |
| 608 | "-s" "json") | 1247 | "-s" "json") |
| 609 | (goto-char (point-min)) | 1248 | (goto-char (point-min)) |
| 610 | (setq syntax (json-read)) | 1249 | (setq syntax (json-read)) |
| 611 | (setq cfengine-mode-syntax-cache | 1250 | (setq cfengine-mode-syntax-cache |
| 612 | (cons (cons cfengine-cf-promises syntax) | 1251 | (cons (cons cfengine-cf-promises syntax) |
| 613 | cfengine-mode-syntax-cache))))))))) | 1252 | cfengine-mode-syntax-cache))))))) |
| 1253 | cfengine3-fallback-syntax))) | ||
| 1254 | (unless cfengine-mode-syntax-functions-regex | ||
| 1255 | (setq cfengine-mode-syntax-functions-regex | ||
| 1256 | (regexp-opt (mapcar (lambda (def) | ||
| 1257 | (format "%s" (car def))) | ||
| 1258 | (cdr (assoc 'functions ret))) | ||
| 1259 | 'symbols))) | ||
| 1260 | ret)) | ||
| 614 | 1261 | ||
| 615 | (defun cfengine3-documentation-function () | 1262 | (defun cfengine3-documentation-function () |
| 616 | "Document CFengine 3 functions around point. | 1263 | "Document CFengine 3 functions around point. |
| 617 | Intended as the value of `eldoc-documentation-function', which | 1264 | Intended as the value of `eldoc-documentation-function', which |
| 618 | see. Use it by executing `turn-on-eldoc-mode'." | 1265 | see. Use it by executing `turn-on-eldoc-mode'." |
| 619 | (cfengine3-make-syntax-cache) | ||
| 620 | (let ((fdef (cfengine3--current-function))) | 1266 | (let ((fdef (cfengine3--current-function))) |
| 621 | (when fdef | 1267 | (when fdef |
| 622 | (cfengine3-format-function-docstring fdef)))) | 1268 | (cfengine3-format-function-docstring fdef)))) |
| @@ -625,7 +1271,7 @@ see. Use it by executing `turn-on-eldoc-mode'." | |||
| 625 | "Return completions for function name around or before point." | 1271 | "Return completions for function name around or before point." |
| 626 | (cfengine3-make-syntax-cache) | 1272 | (cfengine3-make-syntax-cache) |
| 627 | (let* ((bounds (cfengine3--current-word t)) | 1273 | (let* ((bounds (cfengine3--current-word t)) |
| 628 | (syntax (assoc cfengine-cf-promises cfengine-mode-syntax-cache)) | 1274 | (syntax (cfengine3-make-syntax-cache)) |
| 629 | (flist (assoc 'functions syntax))) | 1275 | (flist (assoc 'functions syntax))) |
| 630 | (when bounds | 1276 | (when bounds |
| 631 | (append bounds (list (cdr flist)))))) | 1277 | (append bounds (list (cdr flist)))))) |