Function: find-composition

find-composition is a byte-compiled function defined in composite.el.gz.

Signature

(find-composition POS &optional LIMIT STRING DETAIL-P)

Documentation

Return information about a composition at or near buffer position POS.

If the character at POS has composition property, the value is a list
(FROM TO VALID-P).

FROM and TO specify the range of text that has the same composition property, VALID-P is t if this composition is valid, and nil if not.

If there's no composition at POS, and the optional 2nd argument LIMIT is non-nil, search for a composition toward the position given by LIMIT.

If no composition is found, return nil.

Optional 3rd argument STRING, if non-nil, is a string to look for a composition in; nil means the current buffer.

If a valid composition is found and the optional 4th argument DETAIL-P is non-nil, the return value is a list of the form

   (FROM TO COMPONENTS RELATIVE-P MOD-FUNC WIDTH)

COMPONENTS is a vector of integers, the meaning depends on RELATIVE-P.

RELATIVE-P is t if the composition method is relative, else nil.

If RELATIVE-P is t, COMPONENTS is a vector of characters to be composed. If RELATIVE-P is nil, COMPONENTS is a vector of characters and composition rules as described in compose-region.

MOD-FUNC is a modification function of the composition.

WIDTH is a number of columns the composition occupies on the screen.

When Automatic Composition mode is on, this function also finds a chunk of text that is automatically composed. If such a chunk is found closer to POS than the position that has composition property, the value is a list of FROM, TO, and a glyph-string that specifies how the chunk is to be composed; DETAIL-P is ignored in this case. See the function composition-get-gstring for the format of the glyph-string.

Probably introduced at or before Emacs version 21.1.

Source Code

;; Defined in /usr/src/emacs/lisp/composite.el.gz
(defun find-composition (pos &optional limit string detail-p)
  "Return information about a composition at or near buffer position POS.

If the character at POS has `composition' property, the value is a list
\(FROM TO VALID-P).

FROM and TO specify the range of text that has the same `composition'
property, VALID-P is t if this composition is valid, and nil if not.

If there's no composition at POS, and the optional 2nd argument LIMIT
is non-nil, search for a composition toward the position given by LIMIT.

If no composition is found, return nil.

Optional 3rd argument STRING, if non-nil, is a string to look for a
composition in; nil means the current buffer.

If a valid composition is found and the optional 4th argument DETAIL-P
is non-nil, the return value is a list of the form

   (FROM TO COMPONENTS RELATIVE-P MOD-FUNC WIDTH)

COMPONENTS is a vector of integers, the meaning depends on RELATIVE-P.

RELATIVE-P is t if the composition method is relative, else nil.

If RELATIVE-P is t, COMPONENTS is a vector of characters to be
composed.  If RELATIVE-P is nil, COMPONENTS is a vector of characters
and composition rules as described in `compose-region'.

MOD-FUNC is a modification function of the composition.

WIDTH is a number of columns the composition occupies on the screen.

When Automatic Composition mode is on, this function also finds a
chunk of text that is automatically composed.  If such a chunk is
found closer to POS than the position that has `composition'
property, the value is a list of FROM, TO, and a glyph-string
that specifies how the chunk is to be composed; DETAIL-P is
ignored in this case.  See the function `composition-get-gstring'
for the format of the glyph-string."
  (let ((result (find-composition-internal pos limit string detail-p)))
    (if (and detail-p (> (length result) 3) (nth 2 result) (not (nth 3 result)))
	;; This is a valid rule-base composition.
	(decode-composition-components (nth 2 result) 'nocopy))
    result))