Function: cperl-after-block-p

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

Signature

(cperl-after-block-p LIM &optional PRE-BLOCK)

Documentation

Return non-nil if the preceding } (if PRE-BLOCK, following {) delimits a block.

Would not look before LIM. Assumes that LIM is a good place to begin a statement. The kind of block we treat here is one after which a new statement would start; thus the block in ${func()} does not count.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
;; What is the difference of (cperl-after-block-p lim t) and (cperl-block-p)?
;; No save-excursion; condition-case ...  In (cperl-block-p) the block
;; may be a part of an in-statement construct, such as
;;   ${something()}, print {FH} $data.
;; Moreover, one takes positive approach (looks for else,grep etc)
;; another negative (looks for bless,tr etc)
(defun cperl-after-block-p (lim &optional pre-block)
  "Return non-nil if the preceding } (if PRE-BLOCK, following {) delimits a block.
Would not look before LIM.  Assumes that LIM is a good place to begin a
statement.  The kind of block we treat here is one after which a new
statement would start; thus the block in ${func()} does not count."
  (save-excursion
    (condition-case nil
	(progn
	  (or pre-block (forward-sexp -1))
	  (cperl-backward-to-noncomment lim)
	  (or (eq (point) lim)
	      ;; if () {}   // sub f () {}   // sub f :a(') {}
	      (eq (preceding-char) ?\) )
	      ;; label: {}
	      (save-excursion (cperl-after-label))
	      ;; sub :attr {}
	      (get-text-property (cperl-1- (point)) 'attrib-group)
              (save-excursion (cperl-block-declaration-p))
	      (if (memq (char-syntax (preceding-char)) '(?w ?_)) ; else {}
		  (save-excursion
		    (forward-sexp -1)
		    ;; else {}     but not    else::func {}
		    (or (and (looking-at "\\(else\\|catch\\|try\\|continue\\|grep\\|map\\|BEGIN\\|END\\|UNITCHECK\\|CHECK\\|INIT\\)\\>")
			     (not (looking-at "\\(\\sw\\|_\\)+::")))
			;; sub f {}
			(progn
			  (cperl-backward-to-noncomment lim)
			  (and (cperl-char-ends-sub-keyword-p (preceding-char))
			       (progn
				 (forward-sexp -1)
				 (looking-at
                                  (concat cperl-sub-regexp "[ \t\n\f#]")))))))
		;; What precedes is not word...  XXXX Last statement in sub???
		(cperl-after-expr-p lim))))
      (error nil))))