Function: define-char-code-property

define-char-code-property is a byte-compiled function defined in mule-cmds.el.gz.

Signature

(define-char-code-property NAME TABLE &optional DOCSTRING)

Documentation

Define NAME as a character code property given by TABLE.

TABLE is a char-table of purpose char-code-property-table with these extra slots:
  1st: NAME.
  2nd: Function to call to get a property value of a character.
    It is called with three arguments CHAR, VAL, and TABLE, where
    CHAR is a character, VAL is the value of (aref TABLE CHAR).
  3rd: Function to call to put a property value of a character.
    It is called with the same arguments as above.
  4th: Function to call to get a description string of a property value.
    It is called with one argument VALUE, a property value.
  5th: Data used by the above functions.

TABLE may be a name of file to load to build a char-table. The file should contain a call of define-char-code-property with a char-table of the above format as the argument TABLE.

TABLE may also be nil, in which case no property value is pre-assigned.

Optional 3rd argument DOCSTRING is a documentation string of the property.

See also the documentation of get-char-code-property and put-char-code-property.

Probably introduced at or before Emacs version 23.1.

Source Code

;; Defined in /usr/src/emacs/lisp/international/mule-cmds.el.gz
(defun define-char-code-property (name table &optional docstring)
  "Define NAME as a character code property given by TABLE.
TABLE is a char-table of purpose `char-code-property-table' with
these extra slots:
  1st: NAME.
  2nd: Function to call to get a property value of a character.
    It is called with three arguments CHAR, VAL, and TABLE, where
    CHAR is a character, VAL is the value of (aref TABLE CHAR).
  3rd: Function to call to put a property value of a character.
    It is called with the same arguments as above.
  4th: Function to call to get a description string of a property value.
    It is called with one argument VALUE, a property value.
  5th: Data used by the above functions.

TABLE may be a name of file to load to build a char-table.  The
file should contain a call of `define-char-code-property' with a
char-table of the above format as the argument TABLE.

TABLE may also be nil, in which case no property value is pre-assigned.

Optional 3rd argument DOCSTRING is a documentation string of the property.

See also the documentation of `get-char-code-property' and
`put-char-code-property'."
  (or (symbolp name)
      (error "Not a symbol: %s" name))
  (if (char-table-p table)
      (or (and (eq (char-table-subtype table) 'char-code-property-table)
	       (eq (char-table-extra-slot table 0) name))
	  (error "Invalid char-table: %s" table))
    (or (stringp table)
	(error "Not a char-table nor a file name: %s" table)))
  (if (stringp table) (setq table (purecopy table)))
  (if (and (stringp table)
           (char-table-p (alist-get name char-code-property-alist)))
      ;; The table is already setup and we're apparently trying to
      ;; undo that, probably because `charprop.el' is being re-loaded.
      ;; Just skip it, in order to work around a recursive load (bug#52945).
      nil
    (setf (alist-get name char-code-property-alist) table)
    (put name 'char-code-property-documentation (purecopy docstring))))