Next / Previous / Contents / Shipman's homepage

5.4. ibp-tab: Tab function

This command has two different functions. If the cursor is sitting inside an incomplete field, it fills up the rest of the field with characters from the field's default content. If the cursor is sitting within a completed field, it just moves the cursor just past the end of that field.

ibp.el
;; - - -   i b p - t a b   - - -

(defun ibp-tab (count)
  "Tab function for IBP data entry; supports repeat count."

This command can be repeated using the usual emacs C-u mechanism. The convention for repeatable commands is that they take a count argument; the default value of this argument is one, but the user can use C-u to repeat it an arbitrary number of times. The interactive function sets up a function that takes a numeric argument; the "p" argument specifies that the argument must be a number, and it is passed to the function as an integer (rather than as a string).

ibp.el
  (interactive "p")      ;; Argument is the repeat count, default 1

Using a while loop, we call the ibp-tab-once function count times.

ibp.el
  (while (> count 0)
    (ibp-tab-once)
    (setq count (1- count))))