Function: pascal-func-completion

pascal-func-completion is a byte-compiled function defined in pascal.el.gz.

Signature

(pascal-func-completion TYPE PASCAL-STR)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/pascal.el.gz
;; Calculate all possible completions for functions if argument is `function',
;; completions for procedures if argument is `procedure' or both functions and
;; procedures otherwise.

(defun pascal-func-completion (type pascal-str)
  ;; Build regular expression for function/procedure names
  (save-excursion
    (if (string= pascal-str "")
        (setq pascal-str "[a-zA-Z_]"))
    (let ((pascal-str (concat (cond
                               ((eq type 'procedure) "\\<\\(procedure\\)\\s +")
                               ((eq type 'function) "\\<\\(function\\)\\s +")
                               (t "\\<\\(function\\|procedure\\)\\s +"))
                              "\\<\\(" pascal-str "[a-zA-Z0-9_.]*\\)\\>"))
          (pascal-all ())
          match)

      (if (not (looking-at "\\<\\(function\\|procedure\\)\\>"))
          (re-search-backward "\\<\\(function\\|procedure\\)\\>" nil t))
      (forward-char 1)

      ;; Search through all reachable functions
      (while (pascal-beg-of-defun)
        (if (re-search-forward pascal-str (line-end-position) t)
            (progn (setq match (buffer-substring (match-beginning 2)
                                                 (match-end 2)))
                   (push match pascal-all)))
        (goto-char (match-beginning 0)))

      pascal-all)))