Mercurial > hg > xemacs-beta
comparison lisp/modes/winmgr-mode.el @ 100:4be1180a9e89 r20-1b2
Import from CVS: tag r20-1b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:15:11 +0200 |
parents | 4103f0995bd7 |
children | 5a88923fcbfe |
comparison
equal
deleted
inserted
replaced
99:2d83cbd90d8d | 100:4be1180a9e89 |
---|---|
1 ;;; winmgr-mode.el --- generic window manager mode | |
2 | |
3 ;; Author: ??? | |
4 ;; Maintainer: David Konerding (rafael@cse.ucsc.edu) | |
5 ;; Modifications by: Stefan Strobel <strobel@lia.univ-savoie.fr> | |
6 ;; Barry A. Warsaw <bwarsaw@python.org> | |
7 ;; Created: ??? | |
8 ;; Keywords: languages | |
9 | |
10 ;; Copyright (C) 199? Someone Claim It | |
11 | |
12 ;; This file is part of XEmacs. | |
13 | |
14 ;; XEmacs is free software; you can redistribute it and/or modify it | |
15 ;; under the terms of the GNU General Public License as published by | |
16 ;; the Free Software Foundation; either version 2 of the License, or | |
17 ;; (at your option) any later version. | |
18 | |
19 ;; XEmacs is distributed in the hope that it will be useful, but | |
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
22 ;; General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
25 ;; along with XEmacs; if not, write to the Free Software | |
26 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
27 ;; 02111-1307, USA. | |
28 | |
29 ;;; Synched up with: Not in FSF. | |
30 | |
31 ;;; Commentary: | |
32 | |
33 ;; This package is a major mode for editing window configuration files and | |
34 ;; also defines font-lock keywords for such files. | |
35 | |
36 ;; winmgr-mode mode will automatically get turned on if you visit a | |
37 ;; a file whose name looks like that of a configuration file | |
38 ;; (IE, .fvwmrc, .mwmrc, .tvtwmrc, etc) | |
39 | |
40 ;; The current font-lock keywords are: | |
41 | |
42 ;; any word of upper or lower case letters at the start of a line | |
43 ;; followed by whitespace gets colored using | |
44 ;; font-lock-function-name-face. | |
45 | |
46 ;; any word of upper or lower case letters at the start of a line | |
47 ;; followed by a "(" (IE, an m4 macro) gets colored using | |
48 ;; font-lock-comment-face | |
49 | |
50 ;; Put this in your .emacs : | |
51 ;; | |
52 ;;(setq auto-mode-alist | |
53 ;; (append '(("\\.[A-Za-z]*wm$" . winmgr-mode) | |
54 ;; ("\\.[A-Za-z]*wmrc" . winmgr-mode) | |
55 ;; auto-mode-alist)) | |
56 ;; | |
57 ;;(autoload 'winmgr-mode "winmgr-mode" | |
58 ;; "Mode for editing window manager config files") | |
59 ;; | |
60 ;;(add-hook 'winmgr-mode-hook | |
61 ;; '(lambda () | |
62 ;; (font-lock-mode t) | |
63 ;; (setq font-lock-keywords winmgr-font-lock-keywords) | |
64 ;; (font-lock-fontify-buffer))) | |
65 ;; | |
66 | |
67 | |
68 ;;; Code: | |
69 (defvar winmgr-mode-hook nil | |
70 "Hook to be run when `winmgr-mode' is entered.") | |
71 | |
72 (defvar winmgr-basic-offset 4 | |
73 "*Number of spaces per indentation level.") | |
74 | |
75 | |
76 ;; font-lock-isms | |
77 (defvar font-lock-m4-face 'default | |
78 "New face for m4 macros.") | |
79 | |
80 (defun winmgr-init-font-lock () | |
81 ;; initialize font-lock faces for winmgr-mode | |
82 (condition-case nil | |
83 (progn | |
84 (copy-face 'default 'm4-face) | |
85 (set-face-foreground 'm4-face "blue") | |
86 (set-face-background 'm4-face "white") | |
87 (setq font-lock-m4-face 'm4-face)) | |
88 (error nil))) | |
89 | |
90 (defvar winmgr-font-lock-keywords | |
91 '(("^[A-Za-z]+[ \n\t]" . font-lock-function-name-face) | |
92 ;;("^#.*" . font-lock-comment-face) | |
93 ("^[A-Za-z]+(.*)" . font-lock-m4-face)) | |
94 "Default font-lock keywords.") | |
95 | |
96 | |
97 | |
98 ;; major-mode stuff | |
99 (defvar winmgr-mode-abbrev-table nil | |
100 "Abbrev table used in `winmgr-mode' buffers.") | |
101 (define-abbrev-table 'winmgr-mode-abbrev-table ()) | |
102 | |
103 | |
104 (defvar winmgr-mode-syntax-table nil | |
105 "Syntax table used in `winmgr-mode' buffers.") | |
106 (if winmgr-mode-syntax-table | |
107 () | |
108 (setq winmgr-mode-syntax-table (make-syntax-table)) | |
109 (modify-syntax-entry ?\# "<" winmgr-mode-syntax-table) | |
110 (modify-syntax-entry ?\n ">" winmgr-mode-syntax-table)) | |
111 | |
112 | |
113 (defvar winmgr-mode-map () | |
114 "Keymap used in `winmgr-mode' buffers.") | |
115 (if winmgr-mode-map | |
116 () | |
117 (setq winmgr-mode-map (make-sparse-keymap)) | |
118 ;; So far there aren't any winmgr-mode specific functions | |
119 ) | |
120 | |
121 | |
122 (defun winmgr-mode () | |
123 "Major mode for editing winmgr config files." | |
124 (interactive) | |
125 (kill-all-local-variables) | |
126 (set-syntax-table winmgr-mode-syntax-table) | |
127 (setq major-mode 'winmgr-mode | |
128 mode-name "Winmgr" | |
129 local-abbrev-table winmgr-mode-abbrev-table) | |
130 (use-local-map winmgr-mode-map) | |
131 ;; local variables | |
132 (make-local-variable 'parse-sexp-ignore-comments) | |
133 (make-local-variable 'comment-start) | |
134 (make-local-variable 'comment-end) | |
135 (make-local-variable 'indent-line-function) | |
136 ;; now set their values | |
137 (setq parse-sexp-ignore-comments t | |
138 comment-start "# " | |
139 comment-end "" | |
140 indent-line-function 'winmgr-indent-line-function) | |
141 (run-hooks 'winmgr-mode-hook)) | |
142 | |
143 | |
144 ;; indentation commands | |
145 | |
146 (defun winmgr-indent-line-function () | |
147 "Indent line based on depth in parentheses. | |
148 See the variable `winmgr-basic-offset.'" | |
149 ;; find the beginning of this construct | |
150 (let ((depth 0) | |
151 (here (point))) | |
152 (condition-case nil | |
153 (while t | |
154 (backward-up-list 1) | |
155 (setq depth (1+ depth))) | |
156 (error nil)) | |
157 (goto-char here) | |
158 (beginning-of-line) | |
159 (delete-horizontal-space) | |
160 (insert-char ?\040 (* depth winmgr-basic-offset)))) | |
161 | |
162 | |
163 (provide 'winmgr-mode) | |
164 | |
165 ;;; winmgr-mode.el ends here |