Next / Previous / Contents / Shipman's homepage

5.9. ibp-bracket-field: What field contains a given position?

Given an ibp-line-object and a position within that line, this function tries to find the field containing that position.

There are three cases:

This function just checks for the first case. If the position isn't before the tail, we call Section 5.10, “ibp-bracket-tail-field: What tail field contains the cursor?”.

;; - - -   i b p - b r a c k e t - f i e l d   - - -

(defun ibp-bracket-field (line p)
  "Find the field containing a position p within an ibp-line-object

    [ if (line is a ibp-line-object for a line with a tail)
      and (p is a position within line) ->
        if p is in the head part of line ->
          return an ibp-field-object representing the head part, with
          nil filler
        else if p is in a tail field of line ->
          return an ibp-field-object representing that field
        else ->
          return nil ]
  (if (< p (ibp-line-tail line))
      (ibp-field-object (ibp-line-beg line) (ibp-line-tail line) nil)
    (ibp-bracket-tail-field line)))