annotate lisp/modes/xrdb-mode.el @ 161:28f395d8dc7a r20-3b7

Import from CVS: tag r20-3b7
author cvs
date Mon, 13 Aug 2007 09:42:26 +0200
parents 34a5b81f86ba
children 0132846995bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1 ;;; xrdb-mode.el --- mode for editing X resource database files
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
3 ;; Author: 1994-1997 Barry A. Warsaw
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
4 ;; Maintainer: tools-help@python.org
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
5 ;; Created: May 1994
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
6 ;; Version: 1.21
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
7 ;; Last Modified: 1997/02/24 03:34:56
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
8 ;; Keywords: data languages
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
9
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
10 ;; Copyright (C) 1994 Barry A. Warsaw
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
11
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
12 ;; This file is not part of GNU Emacs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
13
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
14 ;; This program is free software; you can redistribute it and/or modify
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2 of the License, or
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
17 ;; (at your option) any later version.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
18 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
19 ;; This program is distributed in the hope that it will be useful,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
22 ;; GNU General Public License for more details.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
23 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
25 ;; along with this program; if not, write to the Free Software
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
26 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
27
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
28 ;;; Commentary:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
29 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
30 ;; In 1994 I wrote:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
31 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
32 ;; "I used to be like you. I used to hack on X resource database files
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
33 ;; all the time, and when I did, I found this mode to be fairly
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
34 ;; useful. It's by no means perfect. At one time I had a collection
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
35 ;; of hacks that did some nice indentation of resource lines, but
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
36 ;; they were not organized in any way. This mode was my attempt to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
37 ;; congeal this mess into a proper major mode. I release it now, not
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
38 ;; because it will change your life, but because I don't plan to do
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
39 ;; anything more with it.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
40 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
41 ;; I have since been enlightened and no longer have to cavort with
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
42 ;; mere mortal X hackers anymore. I like my brain cells, so now I
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
43 ;; use NEXTSTEP where all is glory. Or would you say I traded one
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
44 ;; vice for another? Hmm... Anyway, if you are still down in the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
45 ;; trenches and would like to inherit this file, let me know. I
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
46 ;; don't intend to do any work on it any more... unless I lose my
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
47 ;; place in paradise. I promise to be good, Steve. :-) :-)"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
48 ;;
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
49 ;; I have fallen from grace and have been kicked out of paradise. So
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
50 ;; has Steve Jobs apparently :-)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
51 ;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
52 ;; To use, put the following in your .emacs:
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
53 ;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
54 ;; (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
55 ;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
56 ;; You may also want something like:
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
57 ;;
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
58 ;; (setq auto-mode-alist
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
59 ;; (append '(("\\.Xdefaults$" . xrdb-mode)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
60 ;; ("\\.Xenvironment$" . xrdb-mode)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
61 ;; ("\\.Xresources$" . xrdb-mode)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
62 ;; )
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
63 ;; auto-mode-alist))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
64
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
65
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
66 ;; Code:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
67
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
68
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
69 ;; These variables are available for your customization
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
70 (defgroup xrdb nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
71 "Mode for editing X resource database files."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
72 :group 'languages)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
73
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
74 (defcustom xrdb-mode-hook nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
75 "*Hook to be run when `xrdb-mode' is entered."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
76 :type 'hook
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
77 :group 'xrdb)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
78
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
79 (defcustom xrdb-subdivide-by 'paragraph
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
80 "*Extent of alignment calculations.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
81 Can be one of `buffer', `paragraph', `page', or `line'. Do a
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
82 \\[describe-function] xrdb-indent-buffer RET for more information."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
83 :type '(radio (const buffer) (const paragraph)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
84 (const page) (const line))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 26
diff changeset
85 :group 'xrdb)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
86
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
87
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
88
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
89 ;; no need to customize anything below this line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
90 (defconst xrdb-comment-re "^[ \t]*[!]"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
91 "Character which starts a comment.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
92 (defconst xrdb-separator-char ?:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
93 "Character which separates resource specs from values.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
94
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
95
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
96 ;; utilities
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
97 (defsubst xrdb-point (position)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
98 ;; Returns the value of point at certain commonly referenced POSITIONs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
99 ;; POSITION can be one of the following symbols:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
100 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
101 ;; bol -- beginning of line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
102 ;; eol -- end of line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
103 ;; bod -- beginning of defun
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
104 ;; boi -- back to indentation
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
105 ;; ionl -- indentation of next line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
106 ;; iopl -- indentation of previous line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
107 ;; bonl -- beginning of next line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
108 ;; bopl -- beginning of previous line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
109 ;; bop -- beginning of paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
110 ;; eop -- end of paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
111 ;; bopg -- beginning of page
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
112 ;; eopg -- end of page
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
113 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
114 ;; This function does not modify point or mark.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
115 (let ((here (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
116 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
117 ((eq position 'bol) (beginning-of-line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
118 ((eq position 'eol) (end-of-line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
119 ((eq position 'boi) (back-to-indentation))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
120 ((eq position 'bonl) (forward-line 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
121 ((eq position 'bopl) (forward-line -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
122 ((eq position 'bop) (forward-paragraph -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
123 ((eq position 'eop) (forward-paragraph 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
124 ((eq position 'bopg) (forward-page -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
125 ((eq position 'eopg) (forward-page 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
126 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
127 (error "unknown buffer position requested: %s" position)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
128 (prog1
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
129 (point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
130 (goto-char here))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
131 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
132
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
133 (defsubst xrdb-skip-to-separator ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
134 ;; skip forward from the beginning of the line to the separator
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
135 ;; character as given by xrdb-separator-char. Returns t if the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
136 ;; char was found, otherwise, nil.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
137 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
138 (skip-chars-forward
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
139 (concat "^" (char-to-string xrdb-separator-char))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
140 (xrdb-point 'eol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
141 (= (following-char) xrdb-separator-char))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
142
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
143
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
144
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
145 ;; commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
146 (defun xrdb-electric-separator (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
147 "Insert the separator character.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
148 Re-align the line unless an argument is given."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
149 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
150 ;; first insert the character
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
151 (self-insert-command (prefix-numeric-value arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
152 ;; only do electric behavior if arg is not given
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
153 (if (not arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
154 (xrdb-align-to (xrdb-point 'bol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
155 (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
156 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
157 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
158 (forward-comment (- (point-max)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
159 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
160 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
161 (current-column)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
162
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
163 (defun xrdb-align-to (start end goalcolumn)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
164 (interactive "r\nnAlign to column: ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
165 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
166 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
167 (narrow-to-region start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
168 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
169 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
170 (if (and (not (looking-at xrdb-comment-re))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
171 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
172 goalcolumn)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
173 (indent-code-rigidly (xrdb-point 'bol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
174 (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
175 (- goalcolumn (current-column))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
176 (forward-line 1)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
177
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
178 (defun xrdb-indent-line (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
179 "Re-align current line."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
180 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
181 ;; narrow to the region specified by xrdb-subdivide-by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
182 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
183 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
184 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
185 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
186 ((eq xrdb-subdivide-by 'buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
187 ((eq xrdb-subdivide-by 'page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
188 (narrow-to-page))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
189 ((eq xrdb-subdivide-by 'paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
190 (narrow-to-region (xrdb-point 'bop) (xrdb-point 'eop)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
191 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
192 (narrow-to-region (xrdb-point 'bopl) (xrdb-point 'bonl))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
193 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
194 ;; indent line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
195 (xrdb-align-to (xrdb-point 'bol) (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
196 (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
197 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
198
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
199 (defun xrdb-indent-region (start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
200 "Re-align region."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
201 (interactive "r")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
202 ;; narrow to region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
203 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
204 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
205 (narrow-to-region start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
206 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
207 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
208
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
209 (defun xrdb-indent-page ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
210 "Re-align the current page."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
211 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
212 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
213 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
214 (narrow-to-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
215 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
216 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
217
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
218 (defun xrdb-indent-paragraph ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
219 "Re-align the current paragraph."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
220 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
221 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
222 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
223 (narrow-to-region (xrdb-point 'bop) (xrdb-point 'eop))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
224 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
225 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
226
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
227 (defun xrdb-indent-buffer (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
228 "Re-align the entire buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
229 Alignment calculations are controlled by the variable
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
230 `xrdb-subdivide-by', which can take the values `buffer', `paragraph',
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
231 `page', or `line', with the following meanings:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
232
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
233 buffer - all non-comment lines are aligned with the longest line in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
234 the buffer. Since every line must be scanned, this will
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
235 take the longest to perform.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
236
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
237 paragraph - alignment of lines spanning paragraphs. A paragraph is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
238 defined as all contiguous lines between blank or comment
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
239 lines.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
240
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
241 page - alignment of lines spanning pages (i.e. separated by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
242 page-delimiter, usually ^L).
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
243
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
244 none - alignment of lines based on the previous line.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
245
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
246 With optional \\[universal-argument], queries for alignment subdivision."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
247 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
248 (let ((align-by (if (not arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
249 xrdb-subdivide-by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
250 (completing-read
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
251 "Align by: "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
252 '(("buffer" . buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
253 ("paragraph" . paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
254 ("page" . page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
255 ("line" . line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
256 nil t (format "%s" xrdb-subdivide-by)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
257 (message "Aligning by %s..." align-by)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
258 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
259 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
260 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
261 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
262 ;; by buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
263 ((eq align-by 'buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
264 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
265 ;; by paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
266 ((eq align-by 'paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
267 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
268 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
269 (narrow-to-region (point) (xrdb-point 'eop))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
270 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
271 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
272 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
273 (forward-paragraph 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
274 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
275 ;; by page
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
276 ((eq align-by 'page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
277 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
278 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
279 (narrow-to-region (point) (xrdb-point 'eopg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
280 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
281 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
282 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
283 (forward-page 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
284 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
285 ;; by line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
286 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
287 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
288 (let ((prev-goalcol 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
289 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
290 ;; skip comments and blank lines
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
291 (if (not (looking-at paragraph-start))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
292 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
293 (xrdb-align-to (xrdb-point 'bol) (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
294 prev-goalcol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
295 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
296 (setq prev-goalcol (- (point) (xrdb-point 'boi)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
297 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
298 (forward-line 1))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
299 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
300 (message "Aligning by %s... done." align-by)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
301 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
302
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
303
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
304 ;; major-mode stuff
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
305 (defvar xrdb-mode-abbrev-table nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
306 "Abbrev table used in `xrdb-mode' buffers.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
307 (define-abbrev-table 'xrdb-mode-abbrev-table ())
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
308
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
309
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
310 (defvar xrdb-mode-syntax-table nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
311 "Syntax table used in `xrdb-mode' buffers.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
312 (if xrdb-mode-syntax-table
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
313 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
314 (setq xrdb-mode-syntax-table (make-syntax-table))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
315 (modify-syntax-entry ?! "<" xrdb-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
316 (modify-syntax-entry ?\n ">" xrdb-mode-syntax-table))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
317
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
318
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
319 (defvar xrdb-mode-map ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
320 "Keymap used in `xrdb-mode' buffers.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
321 (if xrdb-mode-map
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
322 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
323 (setq xrdb-mode-map (make-sparse-keymap))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
324 (let ((ekey (char-to-string xrdb-separator-char)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
325 ;; make the separator key electric
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
326 (define-key xrdb-mode-map ekey 'xrdb-electric-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
327 (define-key xrdb-mode-map "\t" 'xrdb-indent-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
328 (define-key xrdb-mode-map "\C-c\C-a" 'xrdb-indent-paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
329 (define-key xrdb-mode-map "\C-c\C-b" 'xrdb-submit-bug-report)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
330 (define-key xrdb-mode-map "\C-c\C-p" 'xrdb-indent-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
331 (define-key xrdb-mode-map "\C-c\C-r" 'xrdb-indent-region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
332 (define-key xrdb-mode-map "\C-c\C-u" 'xrdb-indent-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
333 (define-key xrdb-mode-map "\C-c>" 'xrdb-align-to)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
334 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
335
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
336 (defun xrdb-mode ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
337 "Major mode for editing xrdb config files"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
338 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
339 (kill-all-local-variables)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
340 (set-syntax-table xrdb-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
341 (setq major-mode 'xrdb-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
342 mode-name "xrdb"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
343 local-abbrev-table xrdb-mode-abbrev-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
344 (use-local-map xrdb-mode-map)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
345 ;; local variables
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
346 (make-local-variable 'parse-sexp-ignore-comments)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
347 (make-local-variable 'comment-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
348 (make-local-variable 'comment-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
349 (make-local-variable 'paragraph-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
350 (make-local-variable 'paragraph-separate)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
351 (make-local-variable 'paragraph-ignore-fill-prefix)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
352 ;; now set their values
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
353 (setq parse-sexp-ignore-comments t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
354 comment-start "! "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
355 comment-end "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
356 (setq indent-region-function 'xrdb-indent-region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
357 paragraph-ignore-fill-prefix t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
358 paragraph-start (concat "^[ \t]*$\\|^[ \t]*[!]\\|" page-delimiter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
359 paragraph-separate paragraph-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
360 (run-hooks 'xrdb-mode-hook))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
361
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
362
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
363
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
364 ;; faces and font-locking
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
365 (defvar xrdb-option-name-face 'xrdb-option-name-face
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
366 "Face for option name on a line in an X resource db file")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
367 (defvar xrdb-option-value-face 'xrdb-option-value-face
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
368 "Face for option value on a line in an X resource db file")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
369
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
370 (make-face 'xrdb-option-name-face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
371 (make-face 'xrdb-option-value-face)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
372
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
373 (defun xrdb-font-lock-mode-hook ()
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
374 (or (face-differs-from-default-p 'xrdb-option-name-face)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
375 (copy-face 'font-lock-keyword-face 'xrdb-option-name-face))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
376 (or (face-differs-from-default-p 'xrdb-option-value-face)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
377 (copy-face 'font-lock-string-face 'xrdb-option-value-face))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
378 (remove-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
379 (add-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
380
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
381 (defvar xrdb-font-lock-keywords
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
382 (list '("^[ \t]*\\([^\n:]*:\\)[ \t]*\\(.*\\)$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
383 (1 xrdb-option-name-face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
384 (2 xrdb-option-value-face)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
385 "Additional expressions to highlight in X resource db mode.")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
386 (put 'xrdb-mode 'font-lock-defaults '(xrdb-font-lock-keywords))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
387
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
388
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
389
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
390 ;; commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
391 (defun xrdb-region-goal-column ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
392 ;; Returns the goal column of the current region. Assumes the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
393 ;; buffer has been narrowed to the region to scan.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
394 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
395 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
396 (let ((goalcol -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
397 linecol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
398 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
399 ;; skip any comments
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
400 (if (and (not (looking-at xrdb-comment-re))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
401 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
402 (< goalcol (setq linecol (current-column)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
403 )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
404 (setq goalcol linecol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
405 (forward-line 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
406 (if (< goalcol 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
407 nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
408 goalcol))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
409
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
410
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
411
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
412 ;; submitting bug reports
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
413
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
414 (defconst xrdb-version "1.21"
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
415 "xrdb-mode version number.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
416
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
417 (defconst xrdb-mode-help-address "tools-help@python.org"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
418 "Address for xrdb-mode bug reports.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
419
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
420 (eval-when-compile
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
421 (require 'reporter))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
422
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
423 (defun xrdb-submit-bug-report ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
424 "Submit via mail a bug report on xrdb-mode."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
425 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
426 ;; load in reporter
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
427 (let ((reporter-prompt-for-summary-p t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
428 (varlist '(xrdb-subdivide-by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
429 xrdb-mode-hook
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
430 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
431 (and (if (y-or-n-p "Do you want to submit a report on xrdb-mode? ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
432 t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
433 (message "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
434 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
435 (require 'reporter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
436 (reporter-submit-bug-report
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
437 xrdb-mode-help-address "xrdb-mode" varlist nil nil "Dear Barry,")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
438 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
439
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
440
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
441 (provide 'xrdb-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
442 ;; xrdb-mode.el ends here