annotate lisp/utils/symbol-syntax.el @ 187:b405438285a2 r20-3b20

Import from CVS: tag r20-3b20
author cvs
date Mon, 13 Aug 2007 09:56:28 +0200
parents 131b0175ea99
children
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 ;;; symbol-syntax.el --- find chars with symbol syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Sun Microsystems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Created by: JBW, JBW@_CORTEZ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Created on: Wed Jun 20 15:15:34 1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Last modified by: Ben Wing, wing@666.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Last modified on: Mon Oct 2 02:32:05 GMT 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; Filename: symbol-syntax.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; Keywords: matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; 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
26 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
28 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar symbol-syntax-table-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; '((c-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; (emacs-lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; (lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; (text-mode-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun update-symbol-syntax-table-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (let ((alist symbol-syntax-table-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (while (consp alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (cond ((null (car alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (error "Missing alist item"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ((null (car (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (error "Alist item with null car"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; this functionality not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ((symbolp (setq item (car (car alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (or (null (cdr (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (error "Alist item expected to have null cdr"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (while (symbolp item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq item (symbol-value item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (setcar (car alist) item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (cond ((not (syntax-table-p (car (car alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (error "Alist item car expected to be symbol table"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ((null (cdr (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setcdr (car alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (make-symbol-syntax-table (car (car alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defun get-symbol-syntax-table (norm-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (let (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (if (setq result (assq norm-table symbol-syntax-table-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (update-symbol-syntax-table-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (setq result (assq norm-table symbol-syntax-table-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (setq symbol-syntax-table-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (cons (list norm-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 symbol-syntax-table-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (update-symbol-syntax-table-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (or (setq result (assq norm-table symbol-syntax-table-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (error "Syntax table missing from symbol-syntax-table-alist"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (or (setq result (cdr result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (error "Alist item has null cdr"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (or (syntax-table-p result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (error "Non-syntax-table item in alist"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun make-symbol-syntax-table (in-table)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
80 (let ((out-table (copy-syntax-table in-table)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
81 (map-syntax-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
82 #'(lambda (key value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
83 (if (eq ?_ (char-syntax-from-code value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
84 (put-char-table key (set-char-syntax-in-code value ?w)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
85 out-table))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
86 nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
87 out-table)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 out-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; stuff for examining contents of syntax tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;(show-chars-with-syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; '(c-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; emacs-lisp-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; lisp-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; ?_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defun show-chars-with-syntax (tables syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (let ((osyn (syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (schars nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (while (consp tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (let* ((chars nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (table-symbol (car tables))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (table table-symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (or (symbolp table-symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (error "bad argument non-symbol"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (while (symbolp table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq table (symbol-value table)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
111 (map-syntax-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
112 #'(lambda (key value)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
113 (if (eq syntax (char-syntax-from-code value))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
114 (setq chars (cons key chars)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
115 nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
116 table)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
117 (setq schars (cons (list table-symbol (nreverse chars))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 schars)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
119 (setq tables (cdr tables))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (nreverse schars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (provide 'symbol-syntax)