Mercurial > hg > xemacs-beta
view lisp/fontcolor.el @ 5648:3f4a234f4672
Support non-ASCII correctly in character classes, test this.
src/ChangeLog addition:
2012-04-21 Aidan Kehoe <kehoea@parhasard.net>
Support non-ASCII correctly in character classes ([:alnum:] and
friends).
* regex.c:
* regex.c (ISBLANK, ISUNIBYTE): New. Make these and friends
independent of the locale, since we want them to be consistent in
XEmacs.
* regex.c (print_partial_compiled_pattern): Print the flags for
charset_mule; don't print non-ASCII as the character values in
ranges, this breaks with locales.
* regex.c (enum):
Define various flags the charset_mule and charset_mule_not opcodes
can now take.
* regex.c (CHAR_CLASS_MAX_LENGTH): Update this.
* regex.c (re_iswctype, re_wctype): New, from GNU.
* regex.c (re_wctype_can_match_non_ascii): New; used when deciding
on whether to use charset_mule or the ASCII-only regex character
set opcode.
* regex.c (regex_compile):
Error correctly on long, non-existent character class names.
Break out the handling of charsets that can match non-ASCII into a
separate clause. Use compile_char_class when compiling character
classes.
* regex.c (compile_char_class): New. Used in regex_compile when
compiling character sets that may match non-ASCII.
* regex.c (re_compile_fastmap):
If there are flags set for charset_mule or charset_mule_not, we
can't use the fastmap (since we need to check syntax table values
that aren't available there).
* regex.c (re_match_2_internal):
Check the new flags passed to the charset_mule{,_not} opcode,
observe them if appropriate.
* regex.h:
* regex.h (enum):
Expose re_wctype_t here, imported from GNU.
tests/ChangeLog addition:
2012-04-21 Aidan Kehoe <kehoea@parhasard.net>
* automated/regexp-tests.el:
* automated/regexp-tests.el (Assert-char-class):
Check that #'string-match errors correctly with an over-long
character class name.
Add tests for character class functionality that supports
non-ASCII characters. These tests expose bugs in GNU Emacs
24.0.94.2, but pass under current XEmacs.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 21 Apr 2012 18:58:28 +0100 |
parents | 308d34e9f07d |
children |
line wrap: on
line source
;;; fontcolor.el --- Lisp interface to fonts and colors ;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. ;; Copyright (C) 1995 Ben Wing ;; Copyright (C) 2010 Didier Verna ;; Author: Chuck Thompson <cthomp@xemacs.org> ;; Author: Ben Wing <ben@xemacs.org> ;; Maintainer: XEmacs Development Team ;; Keywords: faces, internal, dumped ;; This file is part of XEmacs. ;; XEmacs is free software: you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by the ;; Free Software Foundation, either version 3 of the License, or (at your ;; option) any later version. ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;; for more details. ;; You should have received a copy of the GNU General Public License ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. ;;; Synched up with: Not in FSF. ;;; Commentary: ;; This file is dumped with XEmacs. ;;; Code: (defun fontcolor-property-1 (function object domain &optional matchspec) (let ((instance (if matchspec (specifier-matching-instance object matchspec domain) (specifier-instance object domain)))) (and instance (funcall function instance)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; font specifiers (defun make-font-specifier (spec-list) "Return a new `font' specifier object with the given specification list. SPEC-LIST can be a list of specifications (each of which is a cons of a locale and a list of instantiators), a single instantiator, or a list of instantiators. See `make-specifier' for more information about specifiers. Valid instantiators for font specifiers are: -- a string naming a font; syntax is platform dependent. Some examples for a 14-point upright medium-weight Courier font: X11 (and GTK1): \"-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*\" Xft (and GTK2): \"Courier-14\" MS-Windows: \"Courier:14:Western\" -- a font instance (use that instance directly if the device matches, or use the string that generated it) -- a vector of no elements (only on TTY's; this means to set no font at all, thus using the \"natural\" font of the terminal's text) -- a vector of one element (a face to inherit from) " (make-specifier-and-init 'font spec-list)) (defun font-name (font &optional domain charset) "Return the name of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-name' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-name font domain charset)) (defun font-ascent (font &optional domain charset) "Return the ascent of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-ascent' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-ascent font domain charset)) (defun font-descent (font &optional domain charset) "Return the descent of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-descent' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-descent font domain charset)) (defun font-width (font &optional domain charset) "Return the width of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-width' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-width font domain charset)) (defun font-height (font &optional domain charset) "Return the height of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-height' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-height font domain charset)) (defun font-proportional-p (font &optional domain charset) "Return whether FONT is proportional in the specified DOMAIN, if known. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-proportional-p' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-proportional-p font domain charset)) (defun font-properties (font &optional domain charset) "Return the properties of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-properties' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-properties font domain charset)) (defun font-truename (font &optional domain charset) "Return the truename of the FONT in the specified DOMAIN, if any. FONT should be a font specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `font-instance-truename' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'font-instance-truename font domain charset)) (defun font-instance-height (font-instance) "Return the height in pixels of FONT-INSTANCE. The returned value is the maximum height for all characters in the font,\n\ and is equivalent to the sum of the font instance's ascent and descent." (+ (font-instance-ascent font-instance) (font-instance-descent font-instance))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; color specifiers (defun make-color-specifier (spec-list) "Return a new `color' specifier object with the given specification list. SPEC-LIST can be a list of specifications (each of which is a cons of a locale and a list of instantiators), a single instantiator, or a list of instantiators. See `make-specifier' for a detailed description of how specifiers work. Valid instantiators for color specifiers are: -- a string naming a color (e.g. under X this might be \"lightseagreen2\" or \"#F534B2\") -- a color instance (use that instance directly if the device matches, or use the string that generated it) -- a vector of no elements (only on TTY's; this means to set no color at all, thus using the \"natural\" color of the terminal's text) -- a vector of one or two elements: a face to inherit from, and optionally a symbol naming which property of that face to inherit, either `foreground' or `background' (if omitted, defaults to the same property that this color specifier is used for; if this specifier is not part of a face, the instantiator would not be valid)." (make-specifier-and-init 'color spec-list)) (defun color-name (color &optional domain) "Return the name of the COLOR in the specified DOMAIN, if any. COLOR should be a color specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `color-instance-name' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'color-instance-name color domain)) (defun color-rgb-components (color &optional domain) "Return the RGB components of the COLOR in the specified DOMAIN, if any. COLOR should be a color specifier object and DOMAIN is normally a window and defaults to the selected window if omitted. This is equivalent to using `specifier-instance' and applying `color-instance-rgb-components' to the result. See `make-specifier' for more information about specifiers." (fontcolor-property-1 'color-instance-rgb-components color domain)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-boolean specifiers (defun make-face-boolean-specifier (spec-list) "Return a new `face-boolean' specifier object with the given spec list. SPEC-LIST can be a list of specifications (each of which is a cons of a locale and a list of instantiators), a single instantiator, or a list of instantiators. See `make-specifier' for a detailed description of how specifiers work. Valid instantiators for face-boolean specifiers are -- t or nil -- a vector of one, two or three elements: a face to inherit from, optionally a symbol naming the property of that face to inherit from (if omitted, defaults to the same property that this face-boolean specifier is used for; if this specifier is not part of a face, the instantiator would not be valid), and optionally a value which, if non-nil, means to invert the sense of the inherited property." (make-specifier-and-init 'face-boolean spec-list)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-background-placement specifiers (defun make-face-background-placement-specifier (spec-list) "Return a new `face-background-placement' specifier object. SPEC-LIST can be a list of specifications (each of which is a cons of a locale and a list of instantiators), a single instantiator, or a list of instantiators. See `make-specifier' for a detailed description of how specifiers work. Valid instantiators for face-background-placement specifiers are: -- absolute or relative (symbols), -- a vector of one element: a face to inherit from." (make-specifier-and-init 'face-background-placement spec-list)) ;;; fontcolor.el ends here.