~ubuntu-branches/debian/sid/emacs24/sid

« back to all changes in this revision

Viewing changes to lisp/generic-x.el

  • Committer: Package Import Robot
  • Author(s): Rob Browning
  • Date: 2014-10-25 14:37:43 UTC
  • mfrom: (13.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20141025143743-m9q5reoyyyjq3p2h
Tags: 24.4+1-4
Update emacsen-common dependency as per policy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; generic-x.el --- A collection of generic modes
2
2
 
3
 
;; Copyright (C) 1997-1998, 2001-2013 Free Software Foundation, Inc.
 
3
;; Copyright (C) 1997-1998, 2001-2014 Free Software Foundation, Inc.
4
4
 
5
5
;; Author:  Peter Breton <pbreton@cs.umb.edu>
6
6
;; Created: Tue Oct 08 1996
460
460
 
461
461
;;; DOS/Windows BAT files
462
462
(when (memq 'bat-generic-mode generic-extras-enable-list)
463
 
 
464
 
(define-generic-mode bat-generic-mode
465
 
  nil
466
 
  nil
467
 
  (eval-when-compile
468
 
    (list
469
 
     ;; Make this one first in the list, otherwise comments will
470
 
     ;; be over-written by other variables
471
 
     '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t)
472
 
     '("^[ \t]*\\(::.*\\)"                  1 font-lock-comment-face t)
473
 
     '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
474
 
       (1 font-lock-builtin-face)
475
 
       (2 font-lock-constant-face t t))
476
 
     ;; Any text (except ON/OFF) following ECHO is a string.
477
 
     '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
478
 
       (1 font-lock-builtin-face)
479
 
       (3 font-lock-constant-face t t)
480
 
       (5 font-lock-string-face t t))
481
 
     ;; These keywords appear as the first word on a line.  (Actually, they
482
 
     ;; can also appear after "if ..." or "for ..." clause, but since they
483
 
     ;; are frequently used in simple text, we punt.)
484
 
     ;; In `generic-bat-mode-setup-function' we make the keywords
485
 
     ;; case-insensitive
486
 
     (generic-make-keywords-list
487
 
      '("for"
488
 
        "if")
489
 
      font-lock-keyword-face "^[@ \t]*")
490
 
     ;; These keywords can be anywhere on a line
491
 
     ;; In `generic-bat-mode-setup-function' we make the keywords
492
 
     ;; case-insensitive
493
 
     (generic-make-keywords-list
494
 
      '("do"
495
 
        "exist"
496
 
        "errorlevel"
497
 
        "goto"
498
 
        "not")
499
 
      font-lock-keyword-face)
500
 
     ;; These are built-in commands.  Only frequently-used ones are listed.
501
 
     (generic-make-keywords-list
502
 
      '("CALL"      "call"       "Call"
503
 
        "CD"        "cd"         "Cd"
504
 
        "CLS"       "cls"        "Cls"
505
 
        "COPY"      "copy"       "Copy"
506
 
        "DEL"       "del"        "Del"
507
 
        "ECHO"      "echo"       "Echo"
508
 
        "MD"        "md"         "Md"
509
 
        "PATH"      "path"       "Path"
510
 
        "PAUSE"     "pause"      "Pause"
511
 
        "PROMPT"    "prompt"     "Prompt"
512
 
        "RD"        "rd"         "Rd"
513
 
        "REN"       "ren"        "Ren"
514
 
        "SET"       "set"        "Set"
515
 
        "START"     "start"      "Start"
516
 
        "SHIFT"     "shift"      "Shift")
517
 
      font-lock-builtin-face "[ \t|\n]")
518
 
     '("^[ \t]*\\(:\\sw+\\)"         1 font-lock-function-name-face t)
519
 
     '("\\(%\\sw+%\\)"               1 font-lock-variable-name-face t)
520
 
     '("\\(%[0-9]\\)"                1 font-lock-variable-name-face t)
521
 
     '("[\t ]+\\([+-/][^\t\n\" ]+\\)" 1 font-lock-type-face)
522
 
     '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
523
 
       (1 font-lock-keyword-face)
524
 
       (2 font-lock-function-name-face nil t))
525
 
     '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
526
 
       (1 font-lock-builtin-face)
527
 
       (2 font-lock-variable-name-face t t))))
528
 
  '("\\.[bB][aA][tT]\\'"
529
 
    "\\.[cC][mM][dD]\\'"
530
 
    "\\`[cC][oO][nN][fF][iI][gG]\\."
531
 
    "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
532
 
  '(generic-bat-mode-setup-function)
533
 
  "Generic mode for MS-Windows batch files.")
534
 
 
535
 
(defvar bat-generic-mode-syntax-table nil
536
 
  "Syntax table in use in `bat-generic-mode' buffers.")
537
 
 
538
 
(defvar bat-generic-mode-keymap (make-sparse-keymap)
539
 
  "Keymap for `bat-generic-mode'.")
540
 
 
541
 
(defun bat-generic-mode-compile ()
542
 
  "Run the current BAT file in a compilation buffer."
543
 
  (interactive)
544
 
  (let ((compilation-buffer-name-function
545
 
         (function
546
 
          (lambda (_ign)
547
 
            (concat "*" (buffer-file-name) "*")))))
548
 
    (compile
549
 
     (concat (w32-shell-name) " -c " (buffer-file-name)))))
550
 
 
551
 
(eval-when-compile (require 'comint))
552
 
(defun bat-generic-mode-run-as-comint ()
553
 
  "Run the current BAT file in a comint buffer."
554
 
  (interactive)
555
 
  (require 'comint)
556
 
  (let* ((file (buffer-file-name))
557
 
         (buf-name (concat "*" file "*")))
558
 
    (with-current-buffer (get-buffer-create buf-name)
559
 
      (erase-buffer)
560
 
      (comint-mode)
561
 
      (comint-exec
562
 
       buf-name
563
 
       file
564
 
       (w32-shell-name)
565
 
       nil
566
 
       (list "-c" file))
567
 
      (display-buffer buf-name))))
568
 
 
569
 
(define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile)
570
 
 
571
 
;; Make underscores count as words
572
 
(unless bat-generic-mode-syntax-table
573
 
  (setq bat-generic-mode-syntax-table (make-syntax-table))
574
 
  (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
575
 
 
576
 
;; bat-generic-mode doesn't use the comment functionality of
577
 
;; define-generic-mode because it has a three-letter comment-string,
578
 
;; so we do it here manually instead
579
 
(defun generic-bat-mode-setup-function ()
580
 
  (make-local-variable 'parse-sexp-ignore-comments)
581
 
  (make-local-variable 'comment-start)
582
 
  (make-local-variable 'comment-start-skip)
583
 
  (make-local-variable 'comment-end)
584
 
  (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
585
 
        parse-sexp-ignore-comments t
586
 
        comment-end ""
587
 
        comment-start "REM "
588
 
        comment-start-skip "[Rr][Ee][Mm] *")
589
 
  (set-syntax-table bat-generic-mode-syntax-table)
590
 
  ;; Make keywords case-insensitive
591
 
  (setq font-lock-defaults '(generic-font-lock-keywords nil t))
592
 
  (use-local-map bat-generic-mode-keymap)))
 
463
  (define-obsolete-function-alias 'bat-generic-mode 'bat-mode "24.4"))
593
464
 
594
465
;;; Mailagent
595
466
;; Mailagent is a Unix mail filtering program.  Anyone wanna do a
839
710
  ;; the choice of face for each token group
840
711
  (eval-when-compile
841
712
    (list
842
 
     (generic-make-keywords-list
843
 
      '("FILEFLAGSMASK"
844
 
        "FILEFLAGS"
845
 
        "FILEOS"
846
 
        "FILESUBTYPE"
847
 
        "FILETYPE"
848
 
        "FILEVERSION"
849
 
        "PRODUCTVERSION")
850
 
      font-lock-type-face)
851
 
     (generic-make-keywords-list
852
 
      '("BEGIN"
853
 
        "BLOCK"
854
 
        "END"
855
 
        "VALUE")
856
 
      font-lock-function-name-face)
 
713
     (list (regexp-opt '("FILEFLAGSMASK"
 
714
                         "FILEFLAGS"
 
715
                         "FILEOS"
 
716
                         "FILESUBTYPE"
 
717
                         "FILETYPE"
 
718
                         "FILEVERSION"
 
719
                         "PRODUCTVERSION") 'symbols)
 
720
           1 font-lock-type-face)
 
721
     (list (regexp-opt '("BEGIN" "BLOCK" "END" "VALUE") 'symbols)
 
722
           1 font-lock-function-name-face)
857
723
     '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
858
724
     '("^#[ \t]*define[ \t]+\\(\\sw+\\)("       1 font-lock-function-name-face)
859
725
     '("^#[ \t]*\\(elif\\|if\\)\\>"
1417
1283
    "WIN32SMINOR")
1418
1284
  "Function argument constants used in InstallShield 3 and 5."))
1419
1285
 
1420
 
(defvar rul-generic-mode-syntax-table nil
 
1286
;; c++-mode-syntax-table used to be autoloaded, with an initial nil value.
 
1287
;; This file did not load cc-mode, and therefore rul-generic-mode-syntax-table
 
1288
;; would have different values according to whether or not cc-mode
 
1289
;; happened to be loaded before this file was.
 
1290
(require 'cc-mode)
 
1291
(defvar c++-mode-syntax-table)
 
1292
 
 
1293
(defvar rul-generic-mode-syntax-table
 
1294
  (let ((table (make-syntax-table c++-mode-syntax-table)))
 
1295
    (modify-syntax-entry ?\r "> b" table)
 
1296
    (modify-syntax-entry ?\n "> b" table)
 
1297
    (modify-syntax-entry ?/  ". 124b" table)
 
1298
    (modify-syntax-entry ?*  ". 23" table)
 
1299
    table)
1421
1300
  "Syntax table to use in `rul-generic-mode' buffers.")
1422
1301
 
1423
 
(setq rul-generic-mode-syntax-table
1424
 
      (make-syntax-table c++-mode-syntax-table))
1425
 
 
1426
 
(modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table)
1427
 
(modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table)
1428
 
 
1429
 
(modify-syntax-entry ?/  ". 124b" rul-generic-mode-syntax-table)
1430
 
(modify-syntax-entry ?*  ". 23"   rul-generic-mode-syntax-table)
1431
 
 
1432
1302
;; here manually instead
1433
1303
(defun generic-rul-mode-setup-function ()
1434
1304
  (make-local-variable 'parse-sexp-ignore-comments)
1468
1338
       (1 font-lock-keyword-face)
1469
1339
       (2 font-lock-constant-face nil t))
1470
1340
     ;; system variables
1471
 
     (generic-make-keywords-list
1472
 
      installshield-system-variables-list
1473
 
      font-lock-variable-name-face "[^_]" "[^_]")
 
1341
     (list (concat "[^_]"
 
1342
                   (regexp-opt installshield-system-variables-list 'symbols)
 
1343
                   "[^_]")
 
1344
           1 font-lock-variable-name-face)
1474
1345
     ;; system functions
1475
 
     (generic-make-keywords-list
1476
 
      installshield-system-functions-list
1477
 
      font-lock-function-name-face "[^_]" "[^_]")
 
1346
     (list (concat "[^_]"
 
1347
                   (regexp-opt installshield-system-functions-list 'symbols)
 
1348
                   "[^_]")
 
1349
           1 font-lock-function-name-face)
1478
1350
     ;; type keywords
1479
 
     (generic-make-keywords-list
1480
 
      installshield-types-list
1481
 
      font-lock-type-face "[^_]" "[^_]")
 
1351
     (list (concat "[^_]"
 
1352
                   (regexp-opt installshield-types-list 'symbols)
 
1353
                   "[^_]")
 
1354
           1 font-lock-type-face)
1482
1355
     ;; function argument constants
1483
 
     (generic-make-keywords-list
1484
 
      installshield-funarg-constants-list
1485
 
      font-lock-variable-name-face "[^_]" "[^_]"))) ; is this face the best choice?
 
1356
     (list (concat "[^_]"
 
1357
                   (regexp-opt installshield-funarg-constants-list 'symbols)
 
1358
                   "[^_]")
 
1359
           1 font-lock-variable-name-face))) ; is this face the best choice?
1486
1360
  '("\\.[rR][uU][lL]\\'")
1487
1361
  '(generic-rul-mode-setup-function)
1488
1362
  "Generic mode for InstallShield RUL files.")