diff options
| -rw-r--r-- | lisp/generic-x.el | 244 |
1 files changed, 220 insertions, 24 deletions
diff --git a/lisp/generic-x.el b/lisp/generic-x.el index 50a852f316d..8eb5aa16ec0 100644 --- a/lisp/generic-x.el +++ b/lisp/generic-x.el | |||
| @@ -140,6 +140,9 @@ you must reload generic-x to enable the specified modes." | |||
| 140 | 'hosts-generic-mode 'fvwm-generic-mode | 140 | 'hosts-generic-mode 'fvwm-generic-mode |
| 141 | 'x-resource-generic-mode | 141 | 'x-resource-generic-mode |
| 142 | 'alias-generic-mode | 142 | 'alias-generic-mode |
| 143 | 'inetd-conf-generic-mode | ||
| 144 | 'etc-services-generic-mode | ||
| 145 | 'etc-passwd-generic-mode | ||
| 143 | ) | 146 | ) |
| 144 | generic-extras-enable-list))) | 147 | generic-extras-enable-list))) |
| 145 | 148 | ||
| @@ -157,7 +160,12 @@ you must reload generic-x to enable the specified modes." | |||
| 157 | '(("^\\(<.*>\\)" 1 'font-lock-reference-face) | 160 | '(("^\\(<.*>\\)" 1 'font-lock-reference-face) |
| 158 | ("^\\(\\sw+\\)\\s-" 1 'font-lock-variable-name-face)) | 161 | ("^\\(\\sw+\\)\\s-" 1 'font-lock-variable-name-face)) |
| 159 | (list "srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'") | 162 | (list "srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'") |
| 160 | nil | 163 | (list |
| 164 | (function | ||
| 165 | (lambda () | ||
| 166 | (setq imenu-generic-expression | ||
| 167 | '((nil "^\\([-A-Za-z0-9_]+\\)" 1))) | ||
| 168 | ))) | ||
| 161 | "Generic mode for Apache or HTTPD configuration files.")) | 169 | "Generic mode for Apache or HTTPD configuration files.")) |
| 162 | 170 | ||
| 163 | ;;; Samba | 171 | ;;; Samba |
| @@ -165,9 +173,14 @@ you must reload generic-x to enable the specified modes." | |||
| 165 | (memq 'samba-generic-mode generic-extras-enable-list) | 173 | (memq 'samba-generic-mode generic-extras-enable-list) |
| 166 | 174 | ||
| 167 | (define-generic-mode 'samba-generic-mode | 175 | (define-generic-mode 'samba-generic-mode |
| 168 | (list ?\;) | 176 | (list ?\; ?#) |
| 169 | nil | 177 | nil |
| 170 | '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face)) | 178 | '( |
| 179 | ("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face) | ||
| 180 | ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)" | ||
| 181 | (1 'font-lock-variable-name-face) | ||
| 182 | (2 'font-lock-type-face)) | ||
| 183 | ) | ||
| 171 | (list "smb\\.conf\\'") | 184 | (list "smb\\.conf\\'") |
| 172 | (list 'generic-bracket-support) | 185 | (list 'generic-bracket-support) |
| 173 | "Generic mode for Samba configuration files.")) | 186 | "Generic mode for Samba configuration files.")) |
| @@ -251,13 +264,13 @@ you must reload generic-x to enable the specified modes." | |||
| 251 | (1 font-lock-function-name-face) | 264 | (1 font-lock-function-name-face) |
| 252 | (2 font-lock-variable-name-face))) | 265 | (2 font-lock-variable-name-face))) |
| 253 | (list "\\.[iI][nN][iI]\\'") | 266 | (list "\\.[iI][nN][iI]\\'") |
| 254 | (list | 267 | (list |
| 255 | (function | 268 | (function |
| 256 | (lambda () | 269 | (lambda () |
| 257 | (setq imenu-generic-expression | 270 | (setq imenu-generic-expression |
| 258 | '((nil "^\\[\\(.*\\)\\]" 1) | 271 | '((nil "^\\[\\(.*\\)\\]" 1) |
| 259 | ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))) | 272 | ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))) |
| 260 | ))) | 273 | ))) |
| 261 | "Generic mode for MS-Windows INI files.")) | 274 | "Generic mode for MS-Windows INI files.")) |
| 262 | 275 | ||
| 263 | ;;; Windows REG files | 276 | ;;; Windows REG files |
| @@ -302,22 +315,32 @@ you must reload generic-x to enable the specified modes." | |||
| 302 | ;; These keywords appear as the first word on a line. (Actually, they | 315 | ;; These keywords appear as the first word on a line. (Actually, they |
| 303 | ;; can also appear after "if ..." or "for ..." clause, but since they | 316 | ;; can also appear after "if ..." or "for ..." clause, but since they |
| 304 | ;; are frequently used in simple text, we punt.) | 317 | ;; are frequently used in simple text, we punt.) |
| 318 | ;; In `generic-bat-mode-setup-function' we make the keywords | ||
| 319 | ;; case-insensitive | ||
| 305 | (generic-make-keywords-list | 320 | (generic-make-keywords-list |
| 306 | (list | 321 | (list |
| 307 | "FOR" "for" "For" | 322 | "call" |
| 308 | "IF" "if" "If" | 323 | "echo" |
| 324 | "for" | ||
| 325 | "if" | ||
| 326 | "path" | ||
| 327 | "pause" | ||
| 328 | "prompt" | ||
| 329 | "set" | ||
| 330 | "start" | ||
| 309 | ) | 331 | ) |
| 310 | 'font-lock-keyword-face "^[@ \t]*") | 332 | 'font-lock-keyword-face "^[@ \t]*") |
| 311 | ;; These keywords can be anywhere on a line | 333 | ;; These keywords can be anywhere on a line |
| 334 | ;; In `generic-bat-mode-setup-function' we make the keywords | ||
| 335 | ;; case-insensitive | ||
| 312 | (generic-make-keywords-list | 336 | (generic-make-keywords-list |
| 313 | (list | 337 | (list |
| 314 | "DO" "do" "Do" | 338 | "exist" |
| 315 | "EXIST" "exist" "Exist" | 339 | "errorlevel" |
| 316 | "ERRORLEVEL" "errorlevel" "ErrorLevel" "Errorlevel" | 340 | "goto" |
| 317 | "GOTO" "goto" "GoTo" "Goto" | 341 | "not" |
| 318 | "NOT" "not" "Not" | 342 | ) 'font-lock-keyword-face) |
| 319 | ) 'font-lock-keyword-face "[ \t|\n]") | 343 | ;; These are built-in commands. Only frequently-used ones are listed. |
| 320 | ; These are built-in commands. Only frequently-used ones are listed. | ||
| 321 | (generic-make-keywords-list | 344 | (generic-make-keywords-list |
| 322 | (list | 345 | (list |
| 323 | "CALL" "call" "Call" | 346 | "CALL" "call" "Call" |
| @@ -380,6 +403,8 @@ you must reload generic-x to enable the specified modes." | |||
| 380 | comment-start-skip "[Rr][Ee][Mm] *" | 403 | comment-start-skip "[Rr][Ee][Mm] *" |
| 381 | ) | 404 | ) |
| 382 | (set-syntax-table bat-generic-mode-syntax-table) | 405 | (set-syntax-table bat-generic-mode-syntax-table) |
| 406 | ;; Make keywords case-insensitive | ||
| 407 | (setq font-lock-defaults (list 'generic-font-lock-defaults nil t)) | ||
| 383 | ) | 408 | ) |
| 384 | ) | 409 | ) |
| 385 | 410 | ||
| @@ -554,13 +579,36 @@ you must reload generic-x to enable the specified modes." | |||
| 554 | 579 | ||
| 555 | ;; Java properties files | 580 | ;; Java properties files |
| 556 | (define-generic-mode 'java-properties-generic-mode | 581 | (define-generic-mode 'java-properties-generic-mode |
| 557 | (list ?#) | 582 | (list ?! ?#) |
| 558 | nil | ||
| 559 | ;; Property and value can be separated with whitespace or an equal sign | ||
| 560 | '(("^\\([\\.A-Za-z0-9_]+\\)\\(\\s-+\\|\\(\\s-*=\\s-*\\)\\)\\([^\r\n]*\\)$" | ||
| 561 | (1 font-lock-reference-face) (4 font-lock-variable-name-face))) | ||
| 562 | nil | 583 | nil |
| 584 | (let ((java-properties-key | ||
| 585 | "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)") | ||
| 586 | (java-properties-value | ||
| 587 | "\\([^\r\n]*\\)") | ||
| 588 | ) | ||
| 589 | ;; Property and value can be separated in a number of different ways: | ||
| 590 | ;; * whitespace | ||
| 591 | ;; * an equal sign | ||
| 592 | ;; * a colon | ||
| 593 | (mapcar | ||
| 594 | (function | ||
| 595 | (lambda (elt) | ||
| 596 | (list | ||
| 597 | (concat "^" java-properties-key elt java-properties-value "$") | ||
| 598 | '(1 font-lock-reference-face) | ||
| 599 | '(4 font-lock-variable-name-face) | ||
| 600 | ))) | ||
| 601 | ;; These are the separators | ||
| 602 | (list ":\\s-+" "\\s-+" "\\s-*=\\s-*") | ||
| 603 | ) | ||
| 604 | ) | ||
| 563 | nil | 605 | nil |
| 606 | (list | ||
| 607 | (function | ||
| 608 | (lambda () | ||
| 609 | (setq imenu-generic-expression | ||
| 610 | '((nil "^\\([^#! \t\n\r=:]+\\)" 1))) | ||
| 611 | ))) | ||
| 564 | "Mode for Java properties files.") | 612 | "Mode for Java properties files.") |
| 565 | 613 | ||
| 566 | ;; C shell alias definitions | 614 | ;; C shell alias definitions |
| @@ -1303,6 +1351,154 @@ you must reload generic-x to enable the specified modes." | |||
| 1303 | nil | 1351 | nil |
| 1304 | "Mode for mailrc files.") | 1352 | "Mode for mailrc files.") |
| 1305 | 1353 | ||
| 1354 | ;; Inetd.conf | ||
| 1355 | (and | ||
| 1356 | (memq 'inetd-conf-generic-mode generic-extras-enable-list) | ||
| 1357 | |||
| 1358 | (define-generic-mode 'inetd-conf-generic-mode | ||
| 1359 | (list ?#) | ||
| 1360 | (list | ||
| 1361 | "stream" | ||
| 1362 | "dgram" | ||
| 1363 | "tcp" | ||
| 1364 | "udp" | ||
| 1365 | "wait" | ||
| 1366 | "nowait" | ||
| 1367 | "internal" | ||
| 1368 | ) | ||
| 1369 | '( | ||
| 1370 | ("^\\([-A-Za-z0-9_]+\\)" | ||
| 1371 | 1 'font-lock-type-face) | ||
| 1372 | ) | ||
| 1373 | '("/etc/inetd.conf\\'") | ||
| 1374 | (list | ||
| 1375 | (function | ||
| 1376 | (lambda () | ||
| 1377 | (setq imenu-generic-expression | ||
| 1378 | '((nil "^\\([-A-Za-z0-9_]+\\)" 1))) | ||
| 1379 | ))) | ||
| 1380 | ) | ||
| 1381 | ) | ||
| 1382 | |||
| 1383 | ;; Services | ||
| 1384 | (and | ||
| 1385 | (memq 'etc-services-generic-mode generic-extras-enable-list) | ||
| 1386 | |||
| 1387 | (define-generic-mode 'etc-services-generic-mode | ||
| 1388 | (list ?#) | ||
| 1389 | (list | ||
| 1390 | "tcp" | ||
| 1391 | "udp" | ||
| 1392 | "ddp" | ||
| 1393 | ) | ||
| 1394 | '( | ||
| 1395 | ("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/" | ||
| 1396 | (1 'font-lock-type-face) | ||
| 1397 | (2 'font-lock-variable-name-face) | ||
| 1398 | ) | ||
| 1399 | ) | ||
| 1400 | '("/etc/services\\'") | ||
| 1401 | (list | ||
| 1402 | (function | ||
| 1403 | (lambda () | ||
| 1404 | (setq imenu-generic-expression | ||
| 1405 | '((nil "^\\([-A-Za-z0-9_]+\\)" 1))) | ||
| 1406 | ))) | ||
| 1407 | ) | ||
| 1408 | ) | ||
| 1409 | |||
| 1410 | ;; Password and Group files | ||
| 1411 | (and | ||
| 1412 | (memq 'etc-passwd-generic-mode generic-extras-enable-list) | ||
| 1413 | |||
| 1414 | (define-generic-mode 'etc-passwd-generic-mode | ||
| 1415 | nil ;; No comment characters | ||
| 1416 | (list "root") ;; Only one keyword | ||
| 1417 | (list | ||
| 1418 | (list | ||
| 1419 | (concat | ||
| 1420 | "^" | ||
| 1421 | ;; User name -- Never blank! | ||
| 1422 | "\\([^:]+\\)" | ||
| 1423 | ":" | ||
| 1424 | ;; Password, UID and GID | ||
| 1425 | (mapconcat | ||
| 1426 | 'identity | ||
| 1427 | (make-list 3 "\\([^:]+\\)") | ||
| 1428 | ":" | ||
| 1429 | ) | ||
| 1430 | ":" | ||
| 1431 | ;; GECOS/Name -- might be blank | ||
| 1432 | "\\([^:]*\\)" | ||
| 1433 | ":" | ||
| 1434 | ;; Home directory and shell | ||
| 1435 | "\\([^:]+\\)" | ||
| 1436 | ":?" | ||
| 1437 | "\\([^:]*\\)" | ||
| 1438 | "$" | ||
| 1439 | ) | ||
| 1440 | '(1 'font-lock-type-face) | ||
| 1441 | '(5 'font-lock-variable-name-face) | ||
| 1442 | '(6 'font-lock-reference-face) | ||
| 1443 | '(7 'font-lock-warning-face) | ||
| 1444 | ) | ||
| 1445 | '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$" | ||
| 1446 | (1 'font-lock-type-face) | ||
| 1447 | (4 'font-lock-variable-name-face) | ||
| 1448 | ) | ||
| 1449 | ) | ||
| 1450 | '("/etc/passwd\\'" "/etc/group\\'") | ||
| 1451 | (list | ||
| 1452 | (function | ||
| 1453 | (lambda () | ||
| 1454 | (setq imenu-generic-expression | ||
| 1455 | '((nil "^\\([-A-Za-z0-9_]+\\):" 1))) | ||
| 1456 | ))) | ||
| 1457 | ) | ||
| 1458 | ) | ||
| 1459 | |||
| 1460 | |||
| 1461 | ;; From Jacques Duthen <jacques.duthen@sncf.fr> | ||
| 1462 | (defvar show-tabs-generic-mode-font-lock-defaults-1 | ||
| 1463 | '( ;; trailing spaces must come before... | ||
| 1464 | ("[ \t]+$" . 'show-tabs-space-face) | ||
| 1465 | ;; ...embedded tabs | ||
| 1466 | ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab-face)))) | ||
| 1467 | |||
| 1468 | (defvar show-tabs-generic-mode-font-lock-defaults-2 | ||
| 1469 | '( ;; trailing spaces must come before... | ||
| 1470 | ("[ \t]+$" . 'show-tabs-space-face) | ||
| 1471 | ;; ...tabs | ||
| 1472 | ("\t+" . 'show-tabs-tab-face))) | ||
| 1473 | |||
| 1474 | (defface show-tabs-tab-face | ||
| 1475 | '((((class grayscale) (background light)) (:foreground "LightGray" :bold t)) | ||
| 1476 | (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | ||
| 1477 | (((class color) (background light)) (:foreground "red")) | ||
| 1478 | (((class color) (background dark)) (:foreground "red")) | ||
| 1479 | (t (:bold t))) | ||
| 1480 | "Font Lock mode face used to highlight TABs." | ||
| 1481 | :group 'show-tabs) | ||
| 1482 | |||
| 1483 | (defface show-tabs-space-face | ||
| 1484 | '((((class grayscale) (background light)) (:foreground "LightGray" :bold t)) | ||
| 1485 | (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | ||
| 1486 | (((class color) (background light)) (:foreground "yellow")) | ||
| 1487 | (((class color) (background dark)) (:foreground "yellow")) | ||
| 1488 | (t (:bold t))) | ||
| 1489 | "Font Lock mode face used to highlight spaces." | ||
| 1490 | :group 'show-tabs) | ||
| 1491 | |||
| 1492 | (define-generic-mode 'show-tabs-generic-mode | ||
| 1493 | () ;; no comment char | ||
| 1494 | () ;; no keywords | ||
| 1495 | show-tabs-generic-mode-font-lock-defaults-1 | ||
| 1496 | () ;; no auto-mode-alist | ||
| 1497 | ;; (list 'show-tabs-generic-mode-hook-fun) | ||
| 1498 | nil | ||
| 1499 | "Generic mode to show tabs and trailing spaces") | ||
| 1500 | |||
| 1306 | (provide 'generic-x) | 1501 | (provide 'generic-x) |
| 1307 | 1502 | ||
| 1308 | ;;; generic-x.el ends here | 1503 | ;;; generic-x.el ends here |
| 1504 | |||