annotate lisp/modes/xrdb-mode.el @ 49:b46643e427ac

Added tag r19-16b90 for changeset 56c54cf7c5b6
author cvs
date Mon, 13 Aug 2007 08:56:06 +0200
parents 441bb1e64a06
children 34a5b81f86ba
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
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
70 (defvar xrdb-mode-hook nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
71 "*Hook to be run when `xrdb-mode' is entered.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
72
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
73 (defvar xrdb-subdivide-by 'paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
74 "*Extent of alignment calculations.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
75 Can be one of `buffer', `paragraph', `page', or `line'. Do a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
76 \\[describe-function] xrdb-indent-buffer RET for more information.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
77
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
78
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
79
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
80 ;; no need to customize anything below this line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
81 (defconst xrdb-comment-re "^[ \t]*[!]"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
82 "Character which starts a comment.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
83 (defconst xrdb-separator-char ?:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
84 "Character which separates resource specs from values.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
85
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
86
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
87 ;; utilities
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
88 (defsubst xrdb-point (position)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
89 ;; Returns the value of point at certain commonly referenced POSITIONs.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
90 ;; POSITION can be one of the following symbols:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
91 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
92 ;; bol -- beginning of line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
93 ;; eol -- end of line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
94 ;; bod -- beginning of defun
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
95 ;; boi -- back to indentation
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
96 ;; ionl -- indentation of next line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
97 ;; iopl -- indentation of previous line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
98 ;; bonl -- beginning of next line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
99 ;; bopl -- beginning of previous line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
100 ;; bop -- beginning of paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
101 ;; eop -- end of paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
102 ;; bopg -- beginning of page
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
103 ;; eopg -- end of page
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
104 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
105 ;; This function does not modify point or mark.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
106 (let ((here (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
107 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
108 ((eq position 'bol) (beginning-of-line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
109 ((eq position 'eol) (end-of-line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
110 ((eq position 'boi) (back-to-indentation))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
111 ((eq position 'bonl) (forward-line 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
112 ((eq position 'bopl) (forward-line -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
113 ((eq position 'bop) (forward-paragraph -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
114 ((eq position 'eop) (forward-paragraph 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
115 ((eq position 'bopg) (forward-page -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
116 ((eq position 'eopg) (forward-page 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
117 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
118 (error "unknown buffer position requested: %s" position)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
119 (prog1
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
120 (point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
121 (goto-char here))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
122 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
123
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
124 (defsubst xrdb-skip-to-separator ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
125 ;; skip forward from the beginning of the line to the separator
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
126 ;; character as given by xrdb-separator-char. Returns t if the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
127 ;; char was found, otherwise, nil.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
128 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
129 (skip-chars-forward
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
130 (concat "^" (char-to-string xrdb-separator-char))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
131 (xrdb-point 'eol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
132 (= (following-char) xrdb-separator-char))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
133
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
134
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
135
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
136 ;; commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
137 (defun xrdb-electric-separator (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
138 "Insert the separator character.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
139 Re-align the line unless an argument is given."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
140 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
141 ;; first insert the character
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
142 (self-insert-command (prefix-numeric-value arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
143 ;; only do electric behavior if arg is not given
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
144 (if (not arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
145 (xrdb-align-to (xrdb-point 'bol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
146 (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
147 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
148 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
149 (forward-comment (- (point-max)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
150 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
151 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
152 (current-column)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
153
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
154 (defun xrdb-align-to (start end goalcolumn)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
155 (interactive "r\nnAlign to column: ")
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 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
158 (narrow-to-region start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
159 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
160 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
161 (if (and (not (looking-at xrdb-comment-re))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
162 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
163 goalcolumn)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
164 (indent-code-rigidly (xrdb-point 'bol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
165 (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
166 (- goalcolumn (current-column))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
167 (forward-line 1)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
168
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
169 (defun xrdb-indent-line (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
170 "Re-align current line."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
171 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
172 ;; narrow to the region specified by xrdb-subdivide-by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
173 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
174 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
175 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
176 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
177 ((eq xrdb-subdivide-by 'buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
178 ((eq xrdb-subdivide-by 'page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
179 (narrow-to-page))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
180 ((eq xrdb-subdivide-by 'paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
181 (narrow-to-region (xrdb-point 'bop) (xrdb-point 'eop)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
182 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
183 (narrow-to-region (xrdb-point 'bopl) (xrdb-point 'bonl))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
184 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
185 ;; indent line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
186 (xrdb-align-to (xrdb-point 'bol) (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
187 (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
188 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
189
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
190 (defun xrdb-indent-region (start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
191 "Re-align region."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
192 (interactive "r")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
193 ;; narrow to region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
194 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
195 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
196 (narrow-to-region start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
197 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
198 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
199
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
200 (defun xrdb-indent-page ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
201 "Re-align the current page."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
202 (interactive)
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-page)
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-paragraph ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
210 "Re-align the current paragraph."
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-region (xrdb-point 'bop) (xrdb-point 'eop))
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-buffer (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
219 "Re-align the entire buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
220 Alignment calculations are controlled by the variable
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
221 `xrdb-subdivide-by', which can take the values `buffer', `paragraph',
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
222 `page', or `line', with the following meanings:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
223
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
224 buffer - all non-comment lines are aligned with the longest line in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
225 the buffer. Since every line must be scanned, this will
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
226 take the longest to perform.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
227
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
228 paragraph - alignment of lines spanning paragraphs. A paragraph is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
229 defined as all contiguous lines between blank or comment
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
230 lines.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
231
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
232 page - alignment of lines spanning pages (i.e. separated by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
233 page-delimiter, usually ^L).
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
234
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
235 none - alignment of lines based on the previous line.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
236
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
237 With optional \\[universal-argument], queries for alignment subdivision."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
238 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
239 (let ((align-by (if (not arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
240 xrdb-subdivide-by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
241 (completing-read
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
242 "Align by: "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
243 '(("buffer" . buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
244 ("paragraph" . paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
245 ("page" . page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
246 ("line" . line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
247 nil t (format "%s" xrdb-subdivide-by)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
248 (message "Aligning by %s..." align-by)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
249 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
250 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
251 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
252 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
253 ;; by buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
254 ((eq align-by 'buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
255 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
256 ;; by paragraph
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
257 ((eq align-by 'paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
258 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
259 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
260 (narrow-to-region (point) (xrdb-point 'eop))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
261 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
262 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
263 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
264 (forward-paragraph 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
265 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
266 ;; by page
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
267 ((eq align-by 'page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
268 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
269 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
270 (narrow-to-region (point) (xrdb-point 'eopg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
271 (xrdb-align-to (point-min) (point-max) (xrdb-region-goal-column))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
272 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
273 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
274 (forward-page 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
275 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
276 ;; by line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
277 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
278 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
279 (let ((prev-goalcol 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
280 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
281 ;; skip comments and blank lines
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
282 (if (not (looking-at paragraph-start))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
283 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
284 (xrdb-align-to (xrdb-point 'bol) (xrdb-point 'bonl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
285 prev-goalcol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
286 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
287 (setq prev-goalcol (- (point) (xrdb-point 'boi)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
288 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
289 (forward-line 1))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
290 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
291 (message "Aligning by %s... done." align-by)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
292 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
293
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
294
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
295 ;; major-mode stuff
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
296 (defvar xrdb-mode-abbrev-table nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
297 "Abbrev table used in `xrdb-mode' buffers.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
298 (define-abbrev-table 'xrdb-mode-abbrev-table ())
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
299
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
300
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
301 (defvar xrdb-mode-syntax-table nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
302 "Syntax table used in `xrdb-mode' buffers.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
303 (if xrdb-mode-syntax-table
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
304 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
305 (setq xrdb-mode-syntax-table (make-syntax-table))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
306 (modify-syntax-entry ?! "<" xrdb-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
307 (modify-syntax-entry ?\n ">" xrdb-mode-syntax-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-map ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
311 "Keymap used in `xrdb-mode' buffers.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
312 (if xrdb-mode-map
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-map (make-sparse-keymap))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
315 (let ((ekey (char-to-string xrdb-separator-char)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
316 ;; make the separator key electric
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
317 (define-key xrdb-mode-map ekey 'xrdb-electric-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
318 (define-key xrdb-mode-map "\t" 'xrdb-indent-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
319 (define-key xrdb-mode-map "\C-c\C-a" 'xrdb-indent-paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
320 (define-key xrdb-mode-map "\C-c\C-b" 'xrdb-submit-bug-report)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
321 (define-key xrdb-mode-map "\C-c\C-p" 'xrdb-indent-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
322 (define-key xrdb-mode-map "\C-c\C-r" 'xrdb-indent-region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
323 (define-key xrdb-mode-map "\C-c\C-u" 'xrdb-indent-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
324 (define-key xrdb-mode-map "\C-c>" 'xrdb-align-to)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
325 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
326
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
327 (defun xrdb-mode ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
328 "Major mode for editing xrdb config files"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
329 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
330 (kill-all-local-variables)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
331 (set-syntax-table xrdb-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
332 (setq major-mode 'xrdb-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
333 mode-name "xrdb"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
334 local-abbrev-table xrdb-mode-abbrev-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
335 (use-local-map xrdb-mode-map)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
336 ;; local variables
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
337 (make-local-variable 'parse-sexp-ignore-comments)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
338 (make-local-variable 'comment-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
339 (make-local-variable 'comment-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
340 (make-local-variable 'paragraph-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
341 (make-local-variable 'paragraph-separate)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
342 (make-local-variable 'paragraph-ignore-fill-prefix)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
343 ;; now set their values
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
344 (setq parse-sexp-ignore-comments t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
345 comment-start "! "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
346 comment-end "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
347 (setq indent-region-function 'xrdb-indent-region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
348 paragraph-ignore-fill-prefix t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
349 paragraph-start (concat "^[ \t]*$\\|^[ \t]*[!]\\|" page-delimiter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
350 paragraph-separate paragraph-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
351 (run-hooks 'xrdb-mode-hook))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
352
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
353
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
354
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
355 ;; faces and font-locking
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
356 (defvar xrdb-option-name-face 'xrdb-option-name-face
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
357 "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
358 (defvar xrdb-option-value-face 'xrdb-option-value-face
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
359 "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
360
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
361 (make-face 'xrdb-option-name-face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
362 (make-face 'xrdb-option-value-face)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
363
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
364 (defun xrdb-font-lock-mode-hook ()
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
365 (or (face-differs-from-default-p 'xrdb-option-name-face)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
366 (copy-face 'font-lock-keyword-face 'xrdb-option-name-face))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
367 (or (face-differs-from-default-p 'xrdb-option-value-face)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
368 (copy-face 'font-lock-string-face 'xrdb-option-value-face))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
369 (remove-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
370 (add-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
371
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
372 (defvar xrdb-font-lock-keywords
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
373 (list '("^[ \t]*\\([^\n:]*:\\)[ \t]*\\(.*\\)$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
374 (1 xrdb-option-name-face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
375 (2 xrdb-option-value-face)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
376 "Additional expressions to highlight in X resource db mode.")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
377 (put 'xrdb-mode 'font-lock-defaults '(xrdb-font-lock-keywords))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
378
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
379
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
380
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
381 ;; commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
382 (defun xrdb-region-goal-column ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
383 ;; Returns the goal column of the current region. Assumes the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
384 ;; buffer has been narrowed to the region to scan.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
385 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
386 (beginning-of-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
387 (let ((goalcol -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
388 linecol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
389 (while (< (point) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
390 ;; skip any comments
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
391 (if (and (not (looking-at xrdb-comment-re))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
392 (xrdb-skip-to-separator)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
393 (< goalcol (setq linecol (current-column)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
394 )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
395 (setq goalcol linecol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
396 (forward-line 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
397 (if (< goalcol 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
398 nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
399 goalcol))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
400
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
401
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
402
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
403 ;; submitting bug reports
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
404
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
405 (defconst xrdb-version "1.21"
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
406 "xrdb-mode version number.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
407
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
408 (defconst xrdb-mode-help-address "tools-help@python.org"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
409 "Address for xrdb-mode bug reports.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
410
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
411 (eval-when-compile
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
412 (require 'reporter))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
413
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
414 (defun xrdb-submit-bug-report ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
415 "Submit via mail a bug report on xrdb-mode."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
416 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
417 ;; load in reporter
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
418 (let ((reporter-prompt-for-summary-p t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
419 (varlist '(xrdb-subdivide-by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
420 xrdb-mode-hook
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
421 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
422 (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
423 t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
424 (message "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
425 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
426 (require 'reporter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
427 (reporter-submit-bug-report
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
428 xrdb-mode-help-address "xrdb-mode" varlist nil nil "Dear Barry,")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
429 )))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
430
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
431
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
432 (provide 'xrdb-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
433 ;; xrdb-mode.el ends here