annotate lisp/prim/syntax.el @ 129:e292c9648bb9 xemacs-20-1p3

Import from CVS: tag xemacs-20-1p3
author cvs
date Mon, 13 Aug 2007 09:28:38 +0200
parents 131b0175ea99
children 3bb7ccffb0c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; Syntax-table hacking stuff, moved from syntax.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1993 Free Software Foundation, Inc.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
3 ;; Copyright (C) 1995 Sun Microsystems.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
18 ;; along with XEmacs; see the file COPYING. If not, write to the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
19 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
20 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Synched up with: FSF 19.28.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Note: FSF does not have a file syntax.el. This stuff is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; in syntax.c. See comments there about not merging past 19.28.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
26 ;; Significantly hacked upon by Ben Wing.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
27
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defun make-syntax-table (&optional oldtable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 "Return a new syntax table.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
30 It inherits all characters from the standard syntax table."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
31 (make-char-table 'syntax))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
32
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
33 (defun simple-set-syntax-entry (char spec table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
34 (put-char-table char spec table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
35
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
36 (defun char-syntax-from-code (code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
37 "Extract the syntax designator from the internal syntax code CODE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
38 CODE is the value actually contained in the syntax table."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
39 (if (consp code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
40 (setq code (car code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
41 (aref (syntax-designator-chars) (logand code 127)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
42
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
43 (defun set-char-syntax-in-code (code desig)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
44 "Return a new internal syntax code whose syntax designator is DESIG.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
45 Other characteristics are the same as in CODE."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
46 (let ((newcode (if (consp code) (car code) code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
47 (setq newcode (logior (string-match
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
48 (regexp-quote (char-to-string desig))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
49 (syntax-designator-chars))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
50 (logand newcode (lognot 127))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
51 (if (consp code) (cons newcode (cdr code))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
52 newcode)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
54 (defun syntax-code-to-string (code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
55 "Return a string equivalent to internal syntax code CODE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
56 The string can be passed to `modify-syntax-entry'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
57 If CODE is invalid, return nil."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
58 (let ((match (and (consp code) (cdr code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
59 (codes (syntax-designator-chars)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
60 (if (consp code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
61 (setq code (car code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
62 (if (or (not (integerp code))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
63 (> (logand code 127) (length codes)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
64 nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
65 (with-output-to-string
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
66 (let* ((spec (elt codes (logand code 127)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
67 (b3 (lsh code -16))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
68 (start1 (/= 0 (logand b3 128))) ;logtest!
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
69 (start1b (/= 0 (logand b3 64)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
70 (start2 (/= 0 (logand b3 32)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
71 (start2b (/= 0 (logand b3 16)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
72 (end1 (/= 0 (logand b3 8)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
73 (end1b (/= 0 (logand b3 4)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
74 (end2 (/= 0 (logand b3 2)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
75 (end2b (/= 0 (logand b3 1)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
76 (prefix (/= 0 (logand code 128)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
77 (single-char-p (or (= spec ?<) (= spec ?>)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
78 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
79 (write-char spec)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
80 (write-char (if match match 32))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
81 ;;; (if start1 (if single-char-p (write-char ?a) (write-char ?1)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
82 (if start1 (if single-char-p (write-char ? ) (write-char ?1)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
83 (if start2 (write-char ?2))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
84 ;;; (if end1 (if single-char-p (write-char ?a) (write-char ?3)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
85 (if end1 (if single-char-p (write-char ? ) (write-char ?3)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
86 (if end2 (write-char ?4))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
87 (if start1b (if single-char-p (write-char ?b) (write-char ?5)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
88 (if start2b (write-char ?6))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
89 (if end1b (if single-char-p (write-char ?b) (write-char ?7)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
90 (if end2b (write-char ?8))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
91 (if prefix (write-char ?p)))))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
92
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
93 (defun syntax-string-to-code (string)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
94 "Return the internal syntax code equivalent to STRING.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
95 STRING should be something acceptable as the second argument to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
96 `modify-syntax-entry'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
97 If STRING is invalid, signal an error."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
98 (let* ((bflag nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
99 (b3 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
100 (ch0 (aref string 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
101 (len (length string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
102 (code (string-match (regexp-quote (char-to-string ch0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
103 (syntax-designator-chars)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
104 (i 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
105 ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
106 (or code
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
107 (error "Invalid syntax designator: %S" string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
108 (while (< i len)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
109 (setq ch (aref string i))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
110 (incf i)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
111 (case ch
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
112 (?1 (setq b3 (logior b3 128)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
113 (?2 (setq b3 (logior b3 32)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
114 (?3 (setq b3 (logior b3 8)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
115 (?4 (setq b3 (logior b3 2)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
116 (?5 (setq b3 (logior b3 64)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
117 (?6 (setq b3 (logior b3 16)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
118 (?7 (setq b3 (logior b3 4)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
119 (?8 (setq b3 (logior b3 1)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
120 (?a (case ch0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
121 (?< (setq b3 (logior b3 128)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
122 (?> (setq b3 (logior b3 8)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
123 (?b (case ch0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
124 (?< (setq b3 (logior b3 64) bflag t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
125 (?> (setq b3 (logior b3 4) bflag t))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
126 (?p (setq code (logior code (lsh 1 7))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
127 (?\ nil) ;; ignore for compatibility
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
128 (otherwise
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
129 (error "Invalid syntax description flag: %S" string))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
130 ;; default single char style if `b' has not been seen
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
131 (if (not bflag)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
132 (case ch0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
133 (?< (setq b3 (logior b3 128)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
134 (?> (setq b3 (logior b3 8)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
135 (setq code (logior code (lsh b3 16)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
136 (if (and (> len 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
137 ;; tough luck if you want to make space a paren!
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
138 (/= (aref string 1) ?\ ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
139 (setq code (cons code (aref string 1))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
140 code))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
141
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
142 (defun modify-syntax-entry (char-range spec &optional table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
143 "Set syntax for the characters CHAR-RANGE according to string SPEC.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
144 CHAR-RANGE is a single character or a range of characters,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
145 as per `put-char-table'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 The syntax is changed only for table TABLE, which defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 the current buffer's syntax table.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
148 The first character of SPEC should be one of the following:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 Space whitespace syntax. w word constituent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 _ symbol constituent. . punctuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 \( open-parenthesis. \) close-parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 \" string quote. \\ character-quote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 $ paired delimiter. ' expression quote or prefix operator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 < comment starter. > comment ender.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
155 / character-quote. @ inherit from `standard-syntax-table'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 Only single-character comment start and end sequences are represented thus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 Two-character sequences are represented as described below.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
159 The second character of SPEC is the matching parenthesis,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 used only if the first character is `(' or `)'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 Any additional characters are flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Defined flags are the characters 1, 2, 3, 4, 5, 6, 7, 8, p, a, and b.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 1 means C is the first of a two-char comment start sequence of style a.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 2 means C is the second character of such a sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 3 means C is the first of a two-char comment end sequence of style a.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 4 means C is the second character of such a sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 5 means C is the first of a two-char comment start sequence of style b.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 6 means C is the second character of such a sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 7 means C is the first of a two-char comment end sequence of style b.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 8 means C is the second character of such a sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 p means C is a prefix character for `backward-prefix-chars';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 such characters are treated as whitespace when they occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 between expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 a means C is comment starter or comment ender for comment style a (default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 b means C is comment starter or comment ender for comment style b."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; I really don't know why this is interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; help-form should at least be made useful whilst reading the second arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "cSet syntax for character: \nsSet syntax for %c to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (cond ((syntax-table-p table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ((not table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq table (syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (wrong-type-argument 'syntax-table-p table))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
186 (let ((code (syntax-string-to-code spec)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
187 (simple-set-syntax-entry char-range code table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
188 nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
189
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
190 (defun map-syntax-table (__function __table &optional __range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
191 "Map FUNCTION over entries in syntax table TABLE, collapsing inheritance.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
192 This is similar to `map-char-table', but works only on syntax tables, and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
193 collapses any entries that call for inheritance by invisibly substituting
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
194 the inherited values from the standard syntax table."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
195 (check-argument-type 'syntax-table-p __table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
196 (map-char-table #'(lambda (__key __value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
197 (if (eq ?@ (char-syntax-from-code __value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
198 (map-char-table #'(lambda (__key __value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
199 (funcall __function
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
200 __key __value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
201 (standard-syntax-table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
202 __key)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
203 (funcall __function __key __value)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
204 __table __range))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;(defun test-xm ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ; (let ((o (copy-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ; (n (copy-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ; (codes (syntax-designator-chars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ; (flags "12345678abp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ; (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ; (let ((spec (concat (char-to-string (elt codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ; (random (length codes))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ; (if (= (random 4) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ; "b"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ; " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ; (let* ((n (random 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ; (s (make-string n 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ; (while (> n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ; (setq n (1- n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ; (aset s n (aref flags (random (length flags)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ; s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ; (message "%S..." spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ; (modify-syntax-entry ?a spec o)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ; (xmodify-syntax-entry ?a spec n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ; (or (= (aref o ?a) (aref n ?a))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ; (error "%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ; (format "fucked with %S: %x %x"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ; spec (aref o ?a) (aref n ?a))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defun describe-syntax-table (table stream)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
233 (let (first-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
234 last-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
235 prev-val
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
236 (describe-one
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
237 (if (featurep 'mule)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
238 #'(lambda (first last value stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
239 (if (equal first last)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
240 (cond ((vectorp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
241 (princ (format "%s, row %d\t"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
242 (charset-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
243 (aref first 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
244 (aref first 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
245 stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
246 ((symbolp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
247 (princ first stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
248 (princ "\t" stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
249 (t
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
250 (princ (text-char-description first) stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
251 (princ "\t" stream)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
252 (cond ((vectorp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
253 (princ (format "%s, rows %d .. %d\t"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
254 (charset-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
255 (aref first 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
256 (aref first 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
257 (aref last 1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
258 stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
259 ((symbolp first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
260 (princ (format "%s .. %s\t" first last) stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
261 (t
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
262 (princ (format "%s .. %s\t"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
263 (text-char-description first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
264 (text-char-description last))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
265 stream))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
266 (describe-syntax-code value stream))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
267 #'(lambda (first last value stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
268 (let* ((tem (text-char-description first))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
269 (pos (length tem))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
270 ;;(limit (cond ((numberp ctl-arrow) ctl-arrow)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
271 ;; ((memq ctl-arrow '(t nil)) 256)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
272 ;; (t 160)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
273 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
274 (princ tem stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
275 (if (> last first)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
276 (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
277 (princ " .. " stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
278 (setq tem (text-char-description last))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
279 (princ tem stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
280 (setq pos (+ pos (length tem) 4))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
281 (while (progn (write-char ?\ stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
282 (setq pos (1+ pos))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
283 (< pos 16))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
284 (describe-syntax-code value stream)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
285 (map-syntax-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
286 #'(lambda (range value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
287 (cond
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
288 ((not first-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
289 (setq first-char range
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
290 last-char range
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
291 prev-val value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
292 ((and (equal value prev-val)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
293 (or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
294 (and (characterp range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
295 (characterp first-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
296 (or (not (featurep 'mule))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
297 (eq (char-charset range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
298 (char-charset first-char)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
299 (= (char-int last-char) (1- (char-int range))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
300 (and (vectorp range)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
301 (vectorp first-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
302 (eq (aref range 0) (aref first-char 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
303 (= (aref last-char 1) (1- (aref range 1))))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
304 (setq last-char range))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
305 (t
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
306 (funcall describe-one first-char last-char prev-val stream)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
307 (setq first-char range
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
308 last-char range
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
309 prev-val value)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
310 nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
311 table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
312 (if first-char
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
313 (funcall describe-one first-char last-char prev-val stream))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defun describe-syntax-code (code stream)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
316 (let ((match (and (consp code) (cdr code)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (invalid (gettext "**invalid**")) ;(empty "") ;constants
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (standard-output (or stream standard-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; #### I18N3 should temporarily set buffer to output-translatable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (in #'(lambda (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (princ ",\n\t\t\t\t ")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
322 (princ string)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
323 (syntax-string (syntax-code-to-string code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
324 (if (consp code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
325 (setq code (car code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
326 (if (null syntax-string)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (princ invalid)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
328 (princ syntax-string)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
329 (princ "\tmeaning: ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
330 (princ (aref ["whitespace" "punctuation" "word-constituent"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
331 "symbol-constituent" "open-paren" "close-paren"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
332 "expression-prefix" "string-quote" "paired-delimiter"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
333 "escape" "character-quote" "comment-begin" "comment-end"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
334 "inherit" "extended-word-constituent"]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
335 (logand code 127)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
336
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
337 (if match
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
338 (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
339 (princ ", matches ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
340 (princ (text-char-description match))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
341 (let* ((spec (elt syntax-string 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (b3 (lsh code -16))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (start1 (/= 0 (logand b3 128))) ;logtest!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (start1b (/= 0 (logand b3 64)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (start2 (/= 0 (logand b3 32)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (start2b (/= 0 (logand b3 16)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (end1 (/= 0 (logand b3 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (end1b (/= 0 (logand b3 4)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (end2 (/= 0 (logand b3 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (end2b (/= 0 (logand b3 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (prefix (/= 0 (logand code 128)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
352 (single-char-p (or (= spec ?<) (= spec ?>))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (if start1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if single-char-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (princ ", style A")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
356 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
357 (gettext "first character of comment-start sequence A"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (if start2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
359 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
360 (gettext "second character of comment-start sequence A")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if end1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (if single-char-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (princ ", style A")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
364 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
365 (gettext "first character of comment-end sequence A"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if end2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
367 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
368 (gettext "second character of comment-end sequence A")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if start1b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if single-char-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (princ ", style B")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
372 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
373 (gettext "first character of comment-start sequence B"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (if start2b
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
375 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
376 (gettext "second character of comment-start sequence B")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if end1b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if single-char-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (princ ", style B")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
380 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
381 (gettext "first character of comment-end sequence B"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if end2b
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
383 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
384 (gettext "second character of comment-end sequence B")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if prefix
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
386 (funcall in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
387 (gettext "prefix character for `backward-prefix-chars'"))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
388 (terpri stream))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun symbol-near-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "Return the first textual item to the nearest point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;alg stolen from etag.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if (not (memq (char-syntax (preceding-char)) '(?w ?_)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (while (not (looking-at "\\sw\\|\\s_\\|\\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (while (looking-at "\\sw\\|\\s_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (if (re-search-backward "\\sw\\|\\s_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (progn (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (progn (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (while (looking-at "\\s'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 nil)))