/[emacs]/emacs/lisp/textmodes/conf-mode.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/conf-mode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by lektu, Wed Aug 31 10:25:00 2005 UTC revision 1.12 by monnier, Tue Oct 18 15:26:08 2005 UTC
# Line 86  not align (only setting space according Line 86  not align (only setting space according
86      (define-key map "\C-c'" 'conf-quote-normal)      (define-key map "\C-c'" 'conf-quote-normal)
87      (define-key map "\C-c\C-a" 'conf-align-assignments)      (define-key map "\C-c\C-a" 'conf-align-assignments)
88      map)      map)
89    "Local keymap for conf-mode buffers.")    "Local keymap for `conf-mode' buffers.")
90    
91  (defvar conf-mode-syntax-table  (defvar conf-mode-syntax-table
92    (let ((table (make-syntax-table)))    (let ((table (make-syntax-table)))
# Line 99  not align (only setting space according Line 99  not align (only setting space according
99      (modify-syntax-entry ?\n ">" table)      (modify-syntax-entry ?\n ">" table)
100      (modify-syntax-entry ?\r ">" table)      (modify-syntax-entry ?\r ">" table)
101      table)      table)
102    "Syntax table in use in Windows style conf-mode buffers.")    "Syntax table in use in Windows style `conf-mode' buffers.")
103    
104  (defvar conf-unix-mode-syntax-table  (defvar conf-unix-mode-syntax-table
105    (let ((table (make-syntax-table conf-mode-syntax-table)))    (let ((table (make-syntax-table conf-mode-syntax-table)))
# Line 107  not align (only setting space according Line 107  not align (only setting space according
107      ;; override      ;; override
108      (modify-syntax-entry ?\; "." table)      (modify-syntax-entry ?\; "." table)
109      table)      table)
110    "Syntax table in use in Unix style conf-mode buffers.")    "Syntax table in use in Unix style `conf-mode' buffers.")
111    
112  (defvar conf-javaprop-mode-syntax-table  (defvar conf-javaprop-mode-syntax-table
113    (let ((table (make-syntax-table conf-unix-mode-syntax-table)))    (let ((table (make-syntax-table conf-unix-mode-syntax-table)))
# Line 124  not align (only setting space according Line 124  not align (only setting space according
124      (modify-syntax-entry ?\' "." table)      (modify-syntax-entry ?\' "." table)
125      (modify-syntax-entry ?\; "." table)      (modify-syntax-entry ?\; "." table)
126      table)      table)
127    "Syntax table in use in PPD conf-mode buffers.")    "Syntax table in use in PPD `conf-mode' buffers.")
128    
129  (defvar conf-xdefaults-mode-syntax-table  (defvar conf-xdefaults-mode-syntax-table
130    (let ((table (make-syntax-table conf-mode-syntax-table)))    (let ((table (make-syntax-table conf-mode-syntax-table)))
# Line 132  not align (only setting space according Line 132  not align (only setting space according
132      ;; override      ;; override
133      (modify-syntax-entry ?\; "." table)      (modify-syntax-entry ?\; "." table)
134      table)      table)
135    "Syntax table in use in Xdefaults style conf-mode buffers.")    "Syntax table in use in Xdefaults style `conf-mode' buffers.")
136    
137    
138  (defvar conf-font-lock-keywords  (defvar conf-font-lock-keywords
# Line 144  not align (only setting space according Line 144  not align (only setting space according
144       (2 'font-lock-constant-face nil t))       (2 'font-lock-constant-face nil t))
145      ;; section { ... } (do this last because some assign ...{...)      ;; section { ... } (do this last because some assign ...{...)
146      ("^[ \t]*\\([^=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))      ("^[ \t]*\\([^=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))
147    "Keywords to hilight in Conf mode")    "Keywords to hilight in Conf mode.")
148    
149  (defvar conf-javaprop-font-lock-keywords  (defvar conf-javaprop-font-lock-keywords
150    '(;; var=val    '(;; var=val
# Line 156  not align (only setting space according Line 156  not align (only setting space according
156       (5 'font-lock-variable-name-face nil t)       (5 'font-lock-variable-name-face nil t)
157       (6 'font-lock-constant-face nil t)       (6 'font-lock-constant-face nil t)
158       (7 'font-lock-variable-name-face nil t)))       (7 'font-lock-variable-name-face nil t)))
159    "Keywords to hilight in Conf Java Properties mode")    "Keywords to hilight in Conf Java Properties mode.")
160    
161  (defvar conf-space-keywords-alist  (defvar conf-space-keywords-alist
162    '(("\\`/etc/gpm/" . "key\\|name\\|foreground\\|background\\|border\\|head")    '(("\\`/etc/gpm/" . "key\\|name\\|foreground\\|background\\|border\\|head")
# Line 188  This variable is best set in the file lo Line 188  This variable is best set in the file lo
188                  '(1 'font-lock-keyword-face)                  '(1 'font-lock-keyword-face)
189                  '(2 'font-lock-variable-name-face))                  '(2 'font-lock-variable-name-face))
190            '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face)))            '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face)))
191    "Keywords to hilight in Conf Space mode")    "Keywords to hilight in Conf Space mode.")
192    
193  (defvar conf-colon-font-lock-keywords  (defvar conf-colon-font-lock-keywords
194    `(;; [section] (do this first because it may look like a parameter)    `(;; [section] (do this first because it may look like a parameter)
# Line 198  This variable is best set in the file lo Line 198  This variable is best set in the file lo
198       (1 'font-lock-variable-name-face))       (1 'font-lock-variable-name-face))
199      ;; section { ... } (do this last because some assign ...{...)      ;; section { ... } (do this last because some assign ...{...)
200      ("^[ \t]*\\([^:\n]+\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))      ("^[ \t]*\\([^:\n]+\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))
201    "Keywords to hilight in Conf Colon mode")    "Keywords to hilight in Conf Colon mode.")
202    
203  (defvar conf-assignment-sign ?=  (defvar conf-assignment-sign ?=
204    "What sign is used for assignments.")    "What sign is used for assignments.")
# Line 231  whitespace.") Line 231  whitespace.")
231              (if (>= arg 0)              (if (>= arg 0)
232                  (progn                  (progn
233                    (indent-to-column arg)                    (indent-to-column arg)
234                    (or (not conf-assignment-space) (memq (char-before (point)) '(?\s ?\t)) (insert ?\s))                    (or (not conf-assignment-space)
235                    (insert conf-assignment-sign (if (and conf-assignment-space (not (eolp))) ?\s "")))                        (memq (char-before (point)) '(?\s ?\t)) (insert ?\s))
236                      (insert conf-assignment-sign
237                              (if (and conf-assignment-space (not (eolp))) ?\s "")))
238                (insert (if conf-assignment-space ?\s "") conf-assignment-sign)                (insert (if conf-assignment-space ?\s "") conf-assignment-sign)
239                (unless (eolp)                (unless (eolp)
240                  (indent-to-column (- arg))                  (indent-to-column (- arg))
241                  (or (not conf-assignment-space) (memq (char-before (point)) '(?\s ?\t)) (insert ?\s))))                  (or (not conf-assignment-space)
242                        (memq (char-before (point)) '(?\s ?\t)) (insert ?\s))))
243            (unless (eolp)            (unless (eolp)
244              (if (>= (current-column) (abs arg))              (if (>= (current-column) (abs arg))
245                  (insert ?\s)                  (insert ?\s)
# Line 255  both, i.e. quotes delimit strings, excep Line 258  both, i.e. quotes delimit strings, excep
258  unbalanced, but hey...)"  unbalanced, but hey...)"
259    (interactive "P")    (interactive "P")
260    (let ((table (copy-syntax-table (syntax-table))))    (let ((table (copy-syntax-table (syntax-table))))
261      (if (or (not arg) (= (prefix-numeric-value arg) 1)) (modify-syntax-entry ?\' "." table))      (if (or (not arg) (= (prefix-numeric-value arg) 1))
262      (if (or (not arg) (= (prefix-numeric-value arg) 2)) (modify-syntax-entry ?\" "." table))          (modify-syntax-entry ?\' "." table))
263        (if (or (not arg) (= (prefix-numeric-value arg) 2))
264            (modify-syntax-entry ?\" "." table))
265      (set-syntax-table table)      (set-syntax-table table)
266      (and (boundp 'font-lock-mode)      (and (boundp 'font-lock-mode)
267           font-lock-mode           font-lock-mode
# Line 326  See also `conf-space-mode', `conf-colon- Line 331  See also `conf-space-mode', `conf-colon-
331                    ((looking-at ".*{"))          ; nop                    ((looking-at ".*{"))          ; nop
332                    ((setq space (1+ space))))                    ((setq space (1+ space))))
333              (forward-line)))              (forward-line)))
334          (if (> jp (max unix win 3))          (cond
335              (conf-javaprop-mode)           ((> jp (max unix win 3)) (conf-javaprop-mode))
336            (if (> colon (max equal space))           ((> colon (max equal space)) (conf-colon-mode))
337                (conf-colon-mode)           ((> space (max equal colon)) (conf-space-mode))
338              (if (> space (max equal colon))           ((or (> win unix) (and (= win unix) (eq system-type 'windows-nt)))
339                  (conf-space-mode)            (conf-windows-mode))
340                (if (or (> win unix)           (t (conf-unix-mode))))
                       (and (= win unix) (eq system-type 'windows-nt)))  
                   (conf-windows-mode)  
                 (conf-unix-mode))))))  
341      (kill-all-local-variables)      (kill-all-local-variables)
342      (use-local-map conf-mode-map)      (use-local-map conf-mode-map)
343    
344      (setq major-mode 'conf-mode      (setq major-mode 'conf-mode
345            mode-name name)            mode-name name)
346        (set (make-local-variable 'font-lock-defaults)
347             '(conf-font-lock-keywords nil t nil nil))
348      (set (make-local-variable 'comment-start) comment)      (set (make-local-variable 'comment-start) comment)
349      (set (make-local-variable 'comment-start-skip)      (set (make-local-variable 'comment-start-skip)
350           (concat (regexp-quote comment-start) "+\\s *"))           (concat (regexp-quote comment-start) "+\\s *"))
351      (set (make-local-variable 'comment-use-syntax) t)      ;; Let newcomment.el decide this for himself.
352        ;; (set (make-local-variable 'comment-use-syntax) t)
353      (set (make-local-variable 'parse-sexp-ignore-comments) t)      (set (make-local-variable 'parse-sexp-ignore-comments) t)
354      (set (make-local-variable 'outline-regexp)      (set (make-local-variable 'outline-regexp)
355           "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)")           "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)")
# Line 368  See also `conf-space-mode', `conf-colon- Line 373  See also `conf-space-mode', `conf-colon-
373  Comments start with `#'.  Comments start with `#'.
374  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
375    
376  # Conf mode font-locks this right on Unix and with C-c C-u  # Conf mode font-locks this right on Unix and with \\[conf-unix-mode]
377    
378  \[Desktop Entry]  \[Desktop Entry]
379           Encoding=UTF-8           Encoding=UTF-8
# Line 384  For details see `conf-mode'.  Example: Line 389  For details see `conf-mode'.  Example:
389  Comments start with `;'.  Comments start with `;'.
390  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
391    
392  ; Conf mode font-locks this right on Windows and with C-c C-w  ; Conf mode font-locks this right on Windows and with \\[conf-windows-mode]
393    
394  \[ExtShellFolderViews]  \[ExtShellFolderViews]
395  Default={5984FFE0-28D4-11CF-AE66-08002B2E1262}  Default={5984FFE0-28D4-11CF-AE66-08002B2E1262}
# Line 407  Comments start with `#' but are also rec Line 412  Comments start with `#' but are also rec
412  between `/*' and `*/'.  between `/*' and `*/'.
413  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
414    
415  # Conf mode font-locks this right with C-c C-j (Java properties)  # Conf mode font-locks this right with \\[conf-javaprop-mode] (Java properties)
416  // another kind of comment  // another kind of comment
417  /* yet another */  /* yet another */
418    
# Line 441  KEYWORDS, or any non-nil non-string for Line 446  KEYWORDS, or any non-nil non-string for
446    
447  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
448    
449  # Conf mode font-locks this right with C-c C-s (space separated)  # Conf mode font-locks this right with \\[conf-space-mode] (space separated)
450    
451  image/jpeg                      jpeg jpg jpe  image/jpeg                      jpeg jpg jpe
452  image/png                       png  image/png                       png
# Line 495  add /dev/mixer         desktop" Line 500  add /dev/mixer         desktop"
500  \"Assignments\" are with `:'.  \"Assignments\" are with `:'.
501  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
502    
503  # Conf mode font-locks this right with C-c C-c (colon)  # Conf mode font-locks this right with \\[conf-colon-mode] (colon)
504    
505  <Multi_key> <exclam> <exclam>           : \"\\241\"     exclamdown  <Multi_key> <exclam> <exclam>           : \"\\241\"     exclamdown
506  <Multi_key> <c> <slash>                 : \"\\242\"     cent"  <Multi_key> <c> <slash>                 : \"\\242\"     cent"
# Line 524  For details see `conf-mode'.  Example: Line 529  For details see `conf-mode'.  Example:
529  Comments start with `*%' and \"assignments\" are with `:'.  Comments start with `*%' and \"assignments\" are with `:'.
530  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
531    
532  *% Conf mode font-locks this right with C-c C-p (PPD)  *% Conf mode font-locks this right with \\[conf-ppd-mode] (PPD)
533    
534  *DefaultTransfer: Null  *DefaultTransfer: Null
535  *Transfer Null.Inverse: \"{ 1 exch sub }\""  *Transfer Null.Inverse: \"{ 1 exch sub }\""
# Line 539  For details see `conf-mode'.  Example: Line 544  For details see `conf-mode'.  Example:
544  Comments start with `!' and \"assignments\" are with `:'.  Comments start with `!' and \"assignments\" are with `:'.
545  For details see `conf-mode'.  Example:  For details see `conf-mode'.  Example:
546    
547  ! Conf mode font-locks this right with C-c C-x (.Xdefaults)  ! Conf mode font-locks this right with \\[conf-xdefaults-mode] (.Xdefaults)
548    
549  *background:                    gray99  *background:                    gray99
550  *foreground:                    black"  *foreground:                    black"
551    (interactive)    (interactive)
552    (conf-colon-mode "!" conf-xdefaults-mode-syntax-table "Conf[Xdefaults]"))    (conf-colon-mode "!" conf-xdefaults-mode-syntax-table "Conf[Xdefaults]"))
553    
   
 ;; font lock support  
 (if (boundp 'font-lock-defaults-alist)  
     (add-to-list  
      'font-lock-defaults-alist  
      (cons 'conf-mode  
            (list 'conf-font-lock-keywords nil t nil nil))))  
   
   
554  (provide 'conf-mode)  (provide 'conf-mode)
555    
556  ;; arch-tag: 0a3805b2-0371-4d3a-8498-8897116b2356  ;; arch-tag: 0a3805b2-0371-4d3a-8498-8897116b2356

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26