Next: , Previous: zap-to-char interactive, Up: zap-to-char

8.1.2 The Body of zap-to-char

The body of the zap-to-char function contains the code that kills (that is, removes) the text in the region from the current position of the cursor up to and including the specified character.

The first part of the code looks like this:

     (if (char-table-p translation-table-for-input)
         (setq char (or (aref translation-table-for-input char) char)))
     (kill-region (point) (progn
                            (search-forward (char-to-string char) nil nil arg)

char-table-p is an hitherto unseen function. It determines whether its argument is a character table. When it is, it sets the character passed to zap-to-char to one of them, if that character exists, or to the character itself. (This becomes important for certain characters in non-European languages. The aref function extracts an element from an array. It is an array-specific function that is not described in this document. See Arrays.)

(point) is the current position of the cursor.

The next part of the code is an expression using progn. The body of the progn consists of calls to search-forward and point.

It is easier to understand how progn works after learning about search-forward, so we will look at search-forward and then at progn.