Function: cperl-block-declaration-p

cperl-block-declaration-p is a byte-compiled function defined in cperl-mode.el.gz.

Signature

(cperl-block-declaration-p)

Documentation

Test whether the following ?\{ opens a declaration block.

Returns the column where the declaring keyword is found, or nil if this isn't a declaration block. Declaration blocks are named subroutines, packages and the like. They start with a keyword and a name, to be followed by various descriptive items which are just skipped over for our purpose. Declaration blocks end a statement, so there's no semicolon.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-block-declaration-p ()
  "Test whether the following ?\\{ opens a declaration block.
Returns the column where the declaring keyword is found, or nil
if this isn't a declaration block.  Declaration blocks are named
subroutines, packages and the like.  They start with a keyword
and a name, to be followed by various descriptive items which are
just skipped over for our purpose.  Declaration blocks end a
statement, so there's no semicolon."
  ;; A scan error means that none of the declarators has been found
  (condition-case nil
      (let ((is-block-declaration nil)
            (continue-searching t))
        (while (and continue-searching (not (bobp)))
          (forward-sexp -1)
          (cond
           ((looking-at (rx (eval cperl--block-declaration-rx)))
            (setq is-block-declaration (current-column)
                  continue-searching nil))
           ;; Another brace means this is no block declaration
           ((looking-at "{")
            (setq continue-searching nil))
           (t
            (cperl-backward-to-noncomment (point-min))
            ;; A semicolon or an opening brace prevent this block from
            ;; being a block declaration
            (when (or (eq (preceding-char) ?\;)
                      (eq (preceding-char) ?{))
              (setq continue-searching nil)))))
        is-block-declaration)
    (error nil)))