diff options
| author | Daniel Pfeiffer | 2004-12-01 00:02:01 +0000 |
|---|---|---|
| committer | Daniel Pfeiffer | 2004-12-01 00:02:01 +0000 |
| commit | 30a2ee1b335d65cc288fa9e766268527f403f21a (patch) | |
| tree | 9b2906ece4152de73a275700055cc94abda1173b | |
| parent | 08adf84e8b9381992f8a7cc22c421bf414049b4a (diff) | |
| download | emacs-30a2ee1b335d65cc288fa9e766268527f403f21a.tar.gz emacs-30a2ee1b335d65cc288fa9e766268527f403f21a.zip | |
Fix copy'n'paste mess up.
| -rw-r--r-- | lisp/textmodes/conf-mode.el | 525 |
1 files changed, 0 insertions, 525 deletions
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index b6b7d0d1197..59ffbb29a4c 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el | |||
| @@ -517,531 +517,6 @@ For details see `conf-mode'. Example: | |||
| 517 | ;;;###autoload | 517 | ;;;###autoload |
| 518 | (defun conf-ppd-mode () | 518 | (defun conf-ppd-mode () |
| 519 | "Conf Mode starter for Adobe/CUPS PPD files. | 519 | "Conf Mode starter for Adobe/CUPS PPD files. |
| 520 | Comments start with `!' and \"assignments\" are with `:'. | ||
| 521 | For details see `conf-mode'. Example: | ||
| 522 | |||
| 523 | *% Conf mode font-locks this right with C-c C-p (PPD) | ||
| 524 | |||
| 525 | *ShortNickName: \"HP LaserJet 4/4M\" | ||
| 526 | ;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files | ||
| 527 | |||
| 528 | ;; Copyright (C) 2004 by Daniel Pfeiffer <occitan@esperanto.org> | ||
| 529 | ;; Keywords: conf ini windows java | ||
| 530 | |||
| 531 | ;; This file is part of GNU Emacs. | ||
| 532 | |||
| 533 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 534 | ;; it under the terms of the GNU General Public License as published by | ||
| 535 | ;; the Free Software Foundation; either version 2, or (at your option) | ||
| 536 | ;; any later version. | ||
| 537 | |||
| 538 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 539 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 540 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 541 | ;; GNU General Public License for more details. | ||
| 542 | |||
| 543 | ;; You should have received a copy of the GNU General Public License | ||
| 544 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 545 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 546 | ;; Boston, MA 02111-1307, USA. | ||
| 547 | |||
| 548 | ;;; Commentary: | ||
| 549 | ;; | ||
| 550 | ;; This mode is designed to edit many similar varieties of Conf/Ini files and | ||
| 551 | ;; Java properties. It started out from Aurélien Tisné's ini-mode. | ||
| 552 | ;; `conf-space-keywords' were inspired by Robert Fitzgerald's any-ini-mode. | ||
| 553 | |||
| 554 | |||
| 555 | ;;; Code: | ||
| 556 | |||
| 557 | (require 'newcomment) | ||
| 558 | |||
| 559 | ;; Variables: | ||
| 560 | |||
| 561 | (defgroup conf nil | ||
| 562 | "Configuration files." | ||
| 563 | :group 'data | ||
| 564 | :version "21.4") | ||
| 565 | |||
| 566 | (defcustom conf-assignment-column 24 | ||
| 567 | "Align assignments to this column by default with \\[conf-align-assignments]. | ||
| 568 | If this number is negative, the `=' comes before the whitespace. Use 0 to | ||
| 569 | not align (only setting space according to `conf-assignment-space')." | ||
| 570 | :type 'integer | ||
| 571 | :group 'conf) | ||
| 572 | |||
| 573 | (defcustom conf-javaprop-assignment-column 32 | ||
| 574 | "Value for `conf-assignment-column' in Java properties buffers." | ||
| 575 | :type 'integer | ||
| 576 | :group 'conf) | ||
| 577 | |||
| 578 | (defcustom conf-colon-assignment-column (- (abs conf-assignment-column)) | ||
| 579 | "Value for `conf-assignment-column' in Java properties buffers." | ||
| 580 | :type 'integer | ||
| 581 | :group 'conf) | ||
| 582 | |||
| 583 | (defcustom conf-assignment-space t | ||
| 584 | "Put at least one space around assignments when aligning." | ||
| 585 | :type 'boolean | ||
| 586 | :group 'conf) | ||
| 587 | |||
| 588 | (defcustom conf-colon-assignment-space nil | ||
| 589 | "Value for `conf-assignment-space' in colon style Conf mode buffers." | ||
| 590 | :type 'boolean | ||
| 591 | :group 'conf) | ||
| 592 | |||
| 593 | |||
| 594 | (defvar conf-mode-map | ||
| 595 | (let ((map (make-sparse-keymap))) | ||
| 596 | (define-key map "\C-c\C-u" 'conf-unix-mode) | ||
| 597 | (define-key map "\C-c\C-w" 'conf-windows-mode) | ||
| 598 | (define-key map "\C-c\C-j" 'conf-javaprop-mode) | ||
| 599 | (define-key map "\C-c\C-s" 'conf-space-mode) | ||
| 600 | (define-key map "\C-c " 'conf-space-mode) | ||
| 601 | (define-key map "\C-c\C-c" 'conf-colon-mode) | ||
| 602 | (define-key map "\C-c:" 'conf-colon-mode) | ||
| 603 | (define-key map "\C-c\C-x" 'conf-xdefaults-mode) | ||
| 604 | (define-key map "\C-c\C-p" 'conf-ppd-mode) | ||
| 605 | (define-key map "\C-c\C-q" 'conf-quote-normal) | ||
| 606 | (define-key map "\C-c\"" 'conf-quote-normal) | ||
| 607 | (define-key map "\C-c'" 'conf-quote-normal) | ||
| 608 | (define-key map "\C-c\C-a" 'conf-align-assignments) | ||
| 609 | map) | ||
| 610 | "Local keymap for conf-mode buffers.") | ||
| 611 | |||
| 612 | (defvar conf-mode-syntax-table | ||
| 613 | (let ((table (make-syntax-table))) | ||
| 614 | (modify-syntax-entry ?= "." table) | ||
| 615 | (modify-syntax-entry ?_ "_" table) | ||
| 616 | (modify-syntax-entry ?- "_" table) | ||
| 617 | (modify-syntax-entry ?. "_" table) | ||
| 618 | (modify-syntax-entry ?\' "\"" table) | ||
| 619 | (modify-syntax-entry ?\; "<" table) | ||
| 620 | (modify-syntax-entry ?\n ">" table) | ||
| 621 | (modify-syntax-entry ?\r ">" table) | ||
| 622 | table) | ||
| 623 | "Syntax table in use in Windows style conf-mode buffers.") | ||
| 624 | |||
| 625 | (defvar conf-unix-mode-syntax-table | ||
| 626 | (let ((table (make-syntax-table conf-mode-syntax-table))) | ||
| 627 | (modify-syntax-entry ?\# "<" table) | ||
| 628 | ;; override | ||
| 629 | (modify-syntax-entry ?\; "." table) | ||
| 630 | table) | ||
| 631 | "Syntax table in use in Unix style conf-mode buffers.") | ||
| 632 | |||
| 633 | (defvar conf-javaprop-mode-syntax-table | ||
| 634 | (let ((table (make-syntax-table conf-unix-mode-syntax-table))) | ||
| 635 | (modify-syntax-entry ?/ ". 124" table) | ||
| 636 | (modify-syntax-entry ?* ". 23b" table) | ||
| 637 | table) | ||
| 638 | "Syntax table in use in Java prperties buffers.") | ||
| 639 | |||
| 640 | (defvar conf-ppd-mode-syntax-table | ||
| 641 | (let ((table (make-syntax-table conf-mode-syntax-table))) | ||
| 642 | (modify-syntax-entry ?* ". 1" table) | ||
| 643 | (modify-syntax-entry ?% ". 2" table) | ||
| 644 | ;; override | ||
| 645 | (modify-syntax-entry ?\' "." table) | ||
| 646 | (modify-syntax-entry ?\; "." table) | ||
| 647 | table) | ||
| 648 | "Syntax table in use in PPD conf-mode buffers.") | ||
| 649 | |||
| 650 | (defvar conf-xdefaults-mode-syntax-table | ||
| 651 | (let ((table (make-syntax-table conf-mode-syntax-table))) | ||
| 652 | (modify-syntax-entry ?! "<" table) | ||
| 653 | ;; override | ||
| 654 | (modify-syntax-entry ?\; "." table) | ||
| 655 | table) | ||
| 656 | "Syntax table in use in Xdefaults style conf-mode buffers.") | ||
| 657 | |||
| 658 | |||
| 659 | (defvar conf-font-lock-keywords | ||
| 660 | `(;; [section] (do this first because it may look like a parameter) | ||
| 661 | ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face) | ||
| 662 | ;; var=val or var[index]=val | ||
| 663 | ("^[ \t]*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?[ \t]*=" | ||
| 664 | (1 'font-lock-variable-name-face) | ||
| 665 | (2 'font-lock-constant-face nil t)) | ||
| 666 | ;; section { ... } (do this last because some assign ...{...) | ||
| 667 | ("^[ \t]*\\([^=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend)) | ||
| 668 | "Keywords to hilight in Conf mode") | ||
| 669 | |||
| 670 | (defvar conf-javaprop-font-lock-keywords | ||
| 671 | '(;; var=val | ||
| 672 | ("^[ \t]*\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(?:\\.\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(?:\\.\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(\\..+?\\)?\\)?\\)?\\)?\\)?\\)?\\([:= \t]\\|$\\)" | ||
| 673 | (1 'font-lock-variable-name-face) | ||
| 674 | (2 'font-lock-constant-face nil t) | ||
| 675 | (3 'font-lock-variable-name-face nil t) | ||
| 676 | (4 'font-lock-constant-face nil t) | ||
| 677 | (5 'font-lock-variable-name-face nil t) | ||
| 678 | (6 'font-lock-constant-face nil t) | ||
| 679 | (7 'font-lock-variable-name-face nil t))) | ||
| 680 | "Keywords to hilight in Conf Java Properties mode") | ||
| 681 | |||
| 682 | (defvar conf-space-keywords-alist | ||
| 683 | '(("\\`/etc/gpm/" . "key\\|name\\|foreground\\|background\\|border\\|head") | ||
| 684 | ("\\`/etc/magic\\'" . "[^ \t]+[ \t]+\\(?:[bl]?e?\\(?:short\\|long\\)\\|byte\\|string\\)[^ \t]*") | ||
| 685 | ("/mod\\(?:ules\\|probe\\)\\.conf" . "alias\\|in\\(?:clude\\|stall\\)\\|options\\|remove") | ||
| 686 | ("/manpath\\.config" . "MAN\\(?:DATORY_MANPATH\\|PATH_MAP\\|DB_MAP\\)") | ||
| 687 | ("/sensors\\.conf" . "chip\\|bus\\|label\\|compute\\|set\\|ignore") | ||
| 688 | ("/sane\\(\\.d\\)?/" . "option\\|device\\|port\\|usb\\|sc\\(?:si\\|anner\\)") | ||
| 689 | ("/resmgr\\.conf" . "class\\|add\\|allow\\|deny") | ||
| 690 | ("/dictionary\\.lst\\'" . "DICT\\|HYPH\\|THES") | ||
| 691 | ("/tuxracer/options" . "set")) | ||
| 692 | "File name based settings for `conf-space-keywords'.") | ||
| 693 | |||
| 694 | (defvar conf-space-keywords nil | ||
| 695 | "Regexps for functions that may come before a space assignment. | ||
| 696 | This allows constructs such as | ||
| 697 | keyword var value | ||
| 698 | This variable is best set in the file local variables, or through | ||
| 699 | `conf-space-keywords-alist'.") | ||
| 700 | |||
| 701 | (defvar conf-space-font-lock-keywords | ||
| 702 | `(;; [section] (do this first because it may look like a parameter) | ||
| 703 | ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face) | ||
| 704 | ;; section { ... } (do this first because it looks like a parameter) | ||
| 705 | ("^[ \t]*\\(.+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face) | ||
| 706 | ;; var val | ||
| 707 | (eval if conf-space-keywords | ||
| 708 | (list (concat "^[ \t]*\\(" conf-space-keywords "\\)[ \t]+\\([^\000- ]+\\)") | ||
| 709 | '(1 'font-lock-keyword-face) | ||
| 710 | '(2 'font-lock-variable-name-face)) | ||
| 711 | '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face))) | ||
| 712 | "Keywords to hilight in Conf Space mode") | ||
| 713 | |||
| 714 | (defvar conf-colon-font-lock-keywords | ||
| 715 | `(;; [section] (do this first because it may look like a parameter) | ||
| 716 | ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face) | ||
| 717 | ;; var: val | ||
| 718 | ("^[ \t]*\\(.+?\\)[ \t]*:" | ||
| 719 | (1 'font-lock-variable-name-face)) | ||
| 720 | ;; section { ... } (do this last because some assign ...{...) | ||
| 721 | ("^[ \t]*\\([^:\n]+\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend)) | ||
| 722 | "Keywords to hilight in Conf Colon mode") | ||
| 723 | |||
| 724 | (defvar conf-assignment-sign ?= | ||
| 725 | "What sign is used for assignments.") | ||
| 726 | |||
| 727 | (defvar conf-assignment-regexp ".+?\\([ \t]*=[ \t]*\\)" | ||
| 728 | "Regexp to recognize assignments. | ||
| 729 | It is anchored after the first sexp on a line. There must a | ||
| 730 | grouping for the assignment sign, including leading and trailing | ||
| 731 | whitespace.") | ||
| 732 | |||
| 733 | |||
| 734 | ;; If anybody can figure out how to get the same effect by configuring | ||
| 735 | ;; `align', I'd be glad to hear. | ||
| 736 | (defun conf-align-assignments (&optional arg) | ||
| 737 | (interactive "P") | ||
| 738 | (setq arg (if arg | ||
| 739 | (prefix-numeric-value arg) | ||
| 740 | conf-assignment-column)) | ||
| 741 | (save-excursion | ||
| 742 | (goto-char (point-min)) | ||
| 743 | (while (not (eobp)) | ||
| 744 | (let ((cs (comment-beginning))) ; go before comment if within | ||
| 745 | (if cs (goto-char cs))) | ||
| 746 | (while (forward-comment 9)) ; max-int? | ||
| 747 | (when (and (not (eobp)) | ||
| 748 | (looking-at conf-assignment-regexp)) | ||
| 749 | (goto-char (match-beginning 1)) | ||
| 750 | (delete-region (point) (match-end 1)) | ||
| 751 | (if conf-assignment-sign | ||
| 752 | (if (>= arg 0) | ||
| 753 | (progn | ||
| 754 | (indent-to-column arg) | ||
| 755 | (or (not conf-assignment-space) (memq (char-before (point)) '(? ?\t)) (insert ? )) | ||
| 756 | (insert conf-assignment-sign (if (and conf-assignment-space (not (eolp))) ?\ ""))) | ||
| 757 | (insert (if conf-assignment-space ?\ "") conf-assignment-sign) | ||
| 758 | (unless (eolp) | ||
| 759 | (indent-to-column (- arg)) | ||
| 760 | (or (not conf-assignment-space) (memq (char-before (point)) '(? ?\t)) (insert ? )))) | ||
| 761 | (unless (eolp) | ||
| 762 | (if (>= (current-column) (abs arg)) | ||
| 763 | (insert ? ) | ||
| 764 | (indent-to-column (abs arg)))))) | ||
| 765 | (forward-line)))) | ||
| 766 | |||
| 767 | |||
| 768 | (defun conf-quote-normal (arg) | ||
| 769 | "Set the syntax of ' and \" to punctuation. | ||
| 770 | With prefix arg, only do it for ' if 1, or only for \" if 2. | ||
| 771 | This only affects the current buffer. Some conf files use quotes | ||
| 772 | to delimit strings, while others allow quotes as simple parts of | ||
| 773 | the assigned value. In those files font locking will be wrong, | ||
| 774 | and you can correct it with this command. (Some files even do | ||
| 775 | both, i.e. quotes delimit strings, except when they are | ||
| 776 | unbalanced, but hey...)" | ||
| 777 | (interactive "P") | ||
| 778 | (let ((table (copy-syntax-table (syntax-table)))) | ||
| 779 | (if (or (not arg) (= (prefix-numeric-value arg) 1)) (modify-syntax-entry ?\' "." table)) | ||
| 780 | (if (or (not arg) (= (prefix-numeric-value arg) 2)) (modify-syntax-entry ?\" "." table)) | ||
| 781 | (set-syntax-table table) | ||
| 782 | (and (boundp 'font-lock-mode) | ||
| 783 | font-lock-mode | ||
| 784 | (font-lock-fontify-buffer)))) | ||
| 785 | |||
| 786 | |||
| 787 | (defun conf-outline-level () | ||
| 788 | (let ((depth 0) | ||
| 789 | (pt (match-end 0))) | ||
| 790 | (condition-case nil | ||
| 791 | (while (setq pt (scan-lists pt -1 1) | ||
| 792 | depth (1+ depth))) | ||
| 793 | (scan-error depth)))) | ||
| 794 | |||
| 795 | |||
| 796 | |||
| 797 | ;;;###autoload | ||
| 798 | (defun conf-mode (&optional comment syntax-table name) | ||
| 799 | "Mode for Unix and Windows Conf files and Java properties. | ||
| 800 | Most conf files know only three kinds of constructs: parameter | ||
| 801 | assignments optionally grouped into sections and comments. Yet | ||
| 802 | there is a great range of variation in the exact syntax of conf | ||
| 803 | files. See below for various wrapper commands that set up the | ||
| 804 | details for some of the most widespread variants. | ||
| 805 | |||
| 806 | This mode sets up font locking, outline, imenu and it provides | ||
| 807 | alignment support through `conf-align-assignments'. If strings | ||
| 808 | come out wrong, try `conf-quote-normal'. | ||
| 809 | |||
| 810 | Some files allow continuation lines, either with a backslash at | ||
| 811 | the end of line, or by indenting the next line (further). These | ||
| 812 | constructs cannot currently be recognized. | ||
| 813 | |||
| 814 | Because of this great variety of nuances, which are often not | ||
| 815 | even clearly specified, please don't expect it to get every file | ||
| 816 | quite right. Patches that clearly identify some special case, | ||
| 817 | without breaking the general ones, are welcome. | ||
| 818 | |||
| 819 | If instead you start this mode with the generic `conf-mode' | ||
| 820 | command, it will parse the buffer. It will generally well | ||
| 821 | identify the first four cases listed below. If the buffer | ||
| 822 | doesn't have enough contents to decide, this is identical to | ||
| 823 | `conf-windows-mode' on Windows, elsewhere to `conf-unix-mode'. | ||
| 824 | See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode', | ||
| 825 | `conf-ppd-mode' and `conf-xdefaults-mode'. | ||
| 826 | |||
| 827 | \\{conf-mode-map}" | ||
| 828 | |||
| 829 | (interactive) | ||
| 830 | (if (not comment) | ||
| 831 | (let ((unix 0) (win 0) (equal 0) (colon 0) (space 0) (jp 0)) | ||
| 832 | (save-excursion | ||
| 833 | (goto-char (point-min)) | ||
| 834 | (while (not (eobp)) | ||
| 835 | (skip-chars-forward " \t\f") | ||
| 836 | (cond ((eq (char-after) ?\#) (setq unix (1+ unix))) | ||
| 837 | ((eq (char-after) ?\;) (setq win (1+ win))) | ||
| 838 | ((eq (char-after) ?\[)) ; nop | ||
| 839 | ((eolp)) ; nop | ||
| 840 | ((eq (char-after) ?})) ; nop | ||
| 841 | ;; recognize at most double spaces within names | ||
| 842 | ((looking-at "[^ \t\n=:]+\\(?: ?[^ \t\n=:]+\\)*[ \t]*[=:]") | ||
| 843 | (if (eq (char-before (match-end 0)) ?=) | ||
| 844 | (setq equal (1+ equal)) | ||
| 845 | (setq colon (1+ colon)))) | ||
| 846 | ((looking-at "/[/*]") (setq jp (1+ jp))) | ||
| 847 | ((looking-at ".*{")) ; nop | ||
| 848 | ((setq space (1+ space)))) | ||
| 849 | (forward-line))) | ||
| 850 | (if (> jp (max unix win 3)) | ||
| 851 | (conf-javaprop-mode) | ||
| 852 | (if (> colon (max equal space)) | ||
| 853 | (conf-colon-mode) | ||
| 854 | (if (> space (max equal colon)) | ||
| 855 | (conf-space-mode) | ||
| 856 | (if (or (> win unix) | ||
| 857 | (and (= win unix) (eq system-type 'windows-nt))) | ||
| 858 | (conf-windows-mode) | ||
| 859 | (conf-unix-mode)))))) | ||
| 860 | (kill-all-local-variables) | ||
| 861 | (use-local-map conf-mode-map) | ||
| 862 | |||
| 863 | (setq major-mode 'conf-mode | ||
| 864 | mode-name name) | ||
| 865 | (set (make-local-variable 'comment-start) comment) | ||
| 866 | (set (make-local-variable 'comment-start-skip) | ||
| 867 | (concat (regexp-quote comment-start) "+\\s *")) | ||
| 868 | (set (make-local-variable 'comment-use-syntax) t) | ||
| 869 | (set (make-local-variable 'parse-sexp-ignore-comments) t) | ||
| 870 | (set (make-local-variable 'outline-regexp) | ||
| 871 | "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)") | ||
| 872 | (set (make-local-variable 'outline-heading-end-regexp) | ||
| 873 | "[\n}]") | ||
| 874 | (set (make-local-variable 'outline-level) | ||
| 875 | 'conf-outline-level) | ||
| 876 | (set-syntax-table syntax-table) | ||
| 877 | (setq imenu-generic-expression | ||
| 878 | '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1) | ||
| 879 | ;; [section] | ||
| 880 | (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1) | ||
| 881 | ;; section { ... } | ||
| 882 | (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1))) | ||
| 883 | |||
| 884 | (run-mode-hooks 'conf-mode-hook))) | ||
| 885 | |||
| 886 | ;;;###autoload | ||
| 887 | (defun conf-unix-mode () | ||
| 888 | "Conf Mode starter for Unix style Conf files. | ||
| 889 | Comments start with `#'. | ||
| 890 | For details see `conf-mode'. Example: | ||
| 891 | |||
| 892 | # Conf mode font-locks this right on Unix and with C-c C-u | ||
| 893 | |||
| 894 | \[Desktop Entry] | ||
| 895 | Encoding=UTF-8 | ||
| 896 | Name=The GIMP | ||
| 897 | Name[ca]=El GIMP | ||
| 898 | Name[cs]=GIMP" | ||
| 899 | (interactive) | ||
| 900 | (conf-mode "#" conf-unix-mode-syntax-table "Conf[Unix]")) | ||
| 901 | |||
| 902 | ;;;###autoload | ||
| 903 | (defun conf-windows-mode () | ||
| 904 | "Conf Mode starter for Windows style Conf files. | ||
| 905 | Comments start with `;'. | ||
| 906 | For details see `conf-mode'. Example: | ||
| 907 | |||
| 908 | ; Conf mode font-locks this right on Windows and with C-c C-w | ||
| 909 | |||
| 910 | \[ExtShellFolderViews] | ||
| 911 | Default={5984FFE0-28D4-11CF-AE66-08002B2E1262} | ||
| 912 | {5984FFE0-28D4-11CF-AE66-08002B2E1262}={5984FFE0-28D4-11CF-AE66-08002B2E1262} | ||
| 913 | |||
| 914 | \[{5984FFE0-28D4-11CF-AE66-08002B2E1262}] | ||
| 915 | PersistMoniker=file://Folder.htt" | ||
| 916 | (interactive) | ||
| 917 | (conf-mode ";" conf-mode-syntax-table "Conf[WinIni]")) | ||
| 918 | |||
| 919 | ;; Here are a few more or less widespread styles. There are others, so | ||
| 920 | ;; obscure, they are not covered. E.g. RFC 2614 allows both Unix and Windows | ||
| 921 | ;; comments. Or the donkey has (* Pascal comments *) -- roll your own starter | ||
| 922 | ;; if you need it. | ||
| 923 | |||
| 924 | ;;;###autoload | ||
| 925 | (defun conf-javaprop-mode () | ||
| 926 | "Conf Mode starter for Java properties files. | ||
| 927 | Comments start with `#' but are also recognized with `//' or | ||
| 928 | between `/*' and `*/'. | ||
| 929 | For details see `conf-mode'. Example: | ||
| 930 | |||
| 931 | # Conf mode font-locks this right with C-c C-j (Java properties) | ||
| 932 | // another kind of comment | ||
| 933 | /* yet another */ | ||
| 934 | |||
| 935 | name:value | ||
| 936 | name=value | ||
| 937 | name value | ||
| 938 | x.1 = | ||
| 939 | x.2.y.1.z.1 = | ||
| 940 | x.2.y.1.z.2.zz =" | ||
| 941 | (interactive) | ||
| 942 | (conf-mode "#" conf-javaprop-mode-syntax-table "Conf[JavaProp]") | ||
| 943 | (set (make-local-variable 'conf-assignment-column) | ||
| 944 | conf-javaprop-assignment-column) | ||
| 945 | (set (make-local-variable 'conf-assignment-regexp) | ||
| 946 | ".+?\\([ \t]*[=: \t][ \t]*\\|$\\)") | ||
| 947 | (set (make-local-variable 'conf-font-lock-keywords) | ||
| 948 | conf-javaprop-font-lock-keywords) | ||
| 949 | (setq comment-start-skip "\\(?:#+\\|/[/*]+\\)\\s *") | ||
| 950 | (setq imenu-generic-expression | ||
| 951 | '(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1)))) | ||
| 952 | |||
| 953 | ;;;###autoload | ||
| 954 | (defun conf-space-mode (&optional keywords) | ||
| 955 | "Conf Mode starter for space separated conf files. | ||
| 956 | \"Assignments\" are with ` '. Keywords before the parameters are | ||
| 957 | recognized according to `conf-space-keywords'. Interactively | ||
| 958 | with a prefix ARG of `0' no keywords will be recognized. With | ||
| 959 | any other prefix arg you will be prompted for a regexp to match | ||
| 960 | the keywords. Programmatically you can pass such a regexp as | ||
| 961 | KEYWORDS, or any non-nil non-string for no keywords. | ||
| 962 | |||
| 963 | For details see `conf-mode'. Example: | ||
| 964 | |||
| 965 | # Conf mode font-locks this right with C-c C-s (space separated) | ||
| 966 | |||
| 967 | image/jpeg jpeg jpg jpe | ||
| 968 | image/png png | ||
| 969 | image/tiff tiff tif | ||
| 970 | |||
| 971 | # Or with keywords (from a recognized file name): | ||
| 972 | class desktop | ||
| 973 | # Standard multimedia devices | ||
| 974 | add /dev/audio desktop | ||
| 975 | add /dev/mixer desktop" | ||
| 976 | (interactive | ||
| 977 | (list (if current-prefix-arg | ||
| 978 | (if (> (prefix-numeric-value current-prefix-arg) 0) | ||
| 979 | (read-string "Regexp to match keywords: ") | ||
| 980 | t)))) | ||
| 981 | (conf-unix-mode) | ||
| 982 | (setq mode-name "Conf[Space]") | ||
| 983 | (set (make-local-variable 'conf-assignment-sign) | ||
| 984 | nil) | ||
| 985 | (set (make-local-variable 'conf-font-lock-keywords) | ||
| 986 | conf-space-font-lock-keywords) | ||
| 987 | ;; This doesn't seem right, but the next two depend on conf-space-keywords | ||
| 988 | ;; being set, while after-change-major-mode-hook might set up imenu, needing | ||
| 989 | ;; the following result: | ||
| 990 | (hack-local-variables-prop-line) | ||
| 991 | (hack-local-variables) | ||
| 992 | (if keywords | ||
| 993 | (set (make-local-variable 'conf-space-keywords) | ||
| 994 | (if (stringp keywords) keywords)) | ||
| 995 | (or conf-space-keywords | ||
| 996 | (not buffer-file-name) | ||
| 997 | (set (make-local-variable 'conf-space-keywords) | ||
| 998 | (assoc-default buffer-file-name conf-space-keywords-alist | ||
| 999 | 'string-match)))) | ||
| 1000 | (set (make-local-variable 'conf-assignment-regexp) | ||
| 1001 | (if conf-space-keywords | ||
| 1002 | (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)") | ||
| 1003 | ".+?\\([ \t]+\\|$\\)")) | ||
| 1004 | (setq imenu-generic-expression | ||
| 1005 | `(,@(cdr imenu-generic-expression) | ||
| 1006 | ("Parameters" | ||
| 1007 | ,(if conf-space-keywords | ||
| 1008 | (concat "^[ \t]*\\(?:" conf-space-keywords | ||
| 1009 | "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)") | ||
| 1010 | "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)") | ||
| 1011 | 1)))) | ||
| 1012 | |||
| 1013 | ;;;###autoload | ||
| 1014 | (defun conf-colon-mode (&optional comment syntax-table name) | ||
| 1015 | "Conf Mode starter for Colon files. | ||
| 1016 | \"Assignments\" are with `:'. | ||
| 1017 | For details see `conf-mode'. Example: | ||
| 1018 | |||
| 1019 | # Conf mode font-locks this right with C-c C-c (colon) | ||
| 1020 | |||
| 1021 | <Multi_key> <exclam> <exclam> : \"\\241\" exclamdown | ||
| 1022 | <Multi_key> <c> <slash> : \"\\242\" cent" | ||
| 1023 | (interactive) | ||
| 1024 | (if comment | ||
| 1025 | (conf-mode comment syntax-table name) | ||
| 1026 | (conf-unix-mode) | ||
| 1027 | (setq mode-name "Conf[Colon]")) | ||
| 1028 | (set (make-local-variable 'conf-assignment-space) | ||
| 1029 | conf-colon-assignment-space) | ||
| 1030 | (set (make-local-variable 'conf-assignment-column) | ||
| 1031 | conf-colon-assignment-column) | ||
| 1032 | (set (make-local-variable 'conf-assignment-sign) | ||
| 1033 | ?:) | ||
| 1034 | (set (make-local-variable 'conf-assignment-regexp) | ||
| 1035 | ".+?\\([ \t]*:[ \t]*\\)") | ||
| 1036 | (set (make-local-variable 'conf-font-lock-keywords) | ||
| 1037 | conf-colon-font-lock-keywords) | ||
| 1038 | (setq imenu-generic-expression | ||
| 1039 | `(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*:" 1) | ||
| 1040 | ,@(cdr imenu-generic-expression)))) | ||
| 1041 | |||
| 1042 | ;;;###autoload | ||
| 1043 | (defun conf-ppd-mode () | ||
| 1044 | "Conf Mode starter for Adobe/CUPS PPD files. | ||
| 1045 | Comments start with `*%' and \"assignments\" are with `:'. | 520 | Comments start with `*%' and \"assignments\" are with `:'. |
| 1046 | For details see `conf-mode'. Example: | 521 | For details see `conf-mode'. Example: |
| 1047 | 522 | ||