comparison lisp/simple.el @ 32507:5151dde2a183

(syntax-flag-table, string-to-syntax): Remove.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 15 Oct 2000 22:09:04 +0000
parents b84a9fb24453
children 99da951a3b7f
comparison
equal deleted inserted replaced
32506:a85522b7799c 32507:5151dde2a183
3950 specifying the syntax when calling `modify-syntax-entry'. CODE is the 3950 specifying the syntax when calling `modify-syntax-entry'. CODE is the
3951 corresponing syntax code as it is stored in a syntax cell, and 3951 corresponing syntax code as it is stored in a syntax cell, and
3952 can be used as value of a `syntax-table' property. 3952 can be used as value of a `syntax-table' property.
3953 DESCRIPTION is the descriptive string for the syntax.") 3953 DESCRIPTION is the descriptive string for the syntax.")
3954 3954
3955 (defconst syntax-flag-table
3956 '((?1 . #b10000000000000000)
3957 (?2 . #b100000000000000000)
3958 (?3 . #b1000000000000000000)
3959 (?4 . #b10000000000000000000)
3960 (?p . #b100000000000000000000)
3961 (?b . #b1000000000000000000000)
3962 (?n . #b10000000000000000000000))
3963 "Alist of pairs (CHAR . FLAG) mapping characters to syntax flags.
3964 CHAR is a character that is allowed as second or following character
3965 in the string argument to `modify-syntax-entry' specifying the syntax.
3966 FLAG is the corresponding syntax flag value that is stored in a
3967 syntax table.")
3968
3969 (defun string-to-syntax (string)
3970 "Convert a syntax specification STRING into syntax cell form.
3971 STRING should be a string as it is allowed as argument of
3972 `modify-syntax-entry'. Value is the equivalent cons cell
3973 \(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table'
3974 text property."
3975 (let* ((first-char (aref string 0))
3976 (code (or (nth 1 (assq first-char syntax-code-table))
3977 (error "Invalid syntax specification `%s'" string)))
3978 (length (length string))
3979 (i 1)
3980 matching-char)
3981 ;; Determine the matching character, if any.
3982 (when (and (> length 1)
3983 (memq first-char '(?\( ?\))))
3984 (setq matching-char (aref string i)))
3985 (setq i (1+ i))
3986 ;; Add any flags to the syntax code.
3987 (while (< i length)
3988 (let ((flag (or (cdr (assq (aref string i) syntax-flag-table))
3989 (error "Invalid syntax flag in `%s'" string))))
3990 (setq code (logior flag code))
3991 (setq i (1+ i))))
3992
3993 (cons code matching-char)))
3994
3995 ;;; simple.el ends here 3955 ;;; simple.el ends here