Function: cperl-find-sub-attrs
cperl-find-sub-attrs is a byte-compiled function defined in
cperl-mode.el.gz.
Signature
(cperl-find-sub-attrs &optional ST-L B-FNAME E-FNAME POS)
Documentation
Syntactically mark (and fontify) attributes of a subroutine.
Should be called with the point before leading colon of an attribute.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-find-sub-attrs (&optional st-l b-fname e-fname pos)
"Syntactically mark (and fontify) attributes of a subroutine.
Should be called with the point before leading colon of an attribute."
;; Works *before* syntax recognition is done
(or st-l (setq st-l (list nil))) ; Avoid overwriting '()
(let (st p reset-st after-first (start (point)) start1 end1)
(condition-case b
(while (looking-at
(concat
"\\(" ; 1=optional? colon
":" cperl-maybe-white-and-comment-rex ; 2=whitespace/comment?
"\\)"
(if after-first "?" "")
;; No space between name and paren allowed...
"\\(\\sw+\\)" ; 3=name
"\\((\\)?")) ; 4=optional paren
(and (match-beginning 1)
(cperl-postpone-fontification
(match-beginning 0) (cperl-1+ (match-beginning 0))
'face font-lock-constant-face))
(setq start1 (match-beginning 3) end1 (match-end 3))
(cperl-postpone-fontification start1 end1
'face font-lock-constant-face)
(goto-char end1) ; end or before `('
(if (match-end 4) ; Have attribute arguments...
(progn
(if st nil
(setq st (cperl-cached-syntax-table st-l))
(modify-syntax-entry ?\( "()" st)
(modify-syntax-entry ?\) ")(" st))
(setq reset-st (syntax-table) p (point))
(set-syntax-table st)
(forward-sexp 1)
(set-syntax-table reset-st)
(setq reset-st nil)
(cperl-commentify p (point) t))) ; mark as string
(forward-comment (buffer-size))
(setq after-first t))
(error (message
"L%d: attribute `%s': %s"
(count-lines (point-min) (point))
(and start1 end1 (buffer-substring start1 end1)) b)
(setq start nil)))
(and start
(progn
(put-text-property start (point)
'attrib-group (if (looking-at "{") t 0))
(and pos
(< 1 (count-lines (+ 3 pos) (point))) ; end of `sub'
;; Apparently, we do not need `multiline': faces added now
(put-text-property (+ 3 pos) (cperl-1+ (point))
'syntax-type 'sub-decl))
(and b-fname ; Fontify here: the following condition
(cperl-postpone-fontification ; is too hard to determine by
b-fname e-fname 'face ; a REx, so do it here
(if (looking-at "{")
font-lock-function-name-face
font-lock-variable-name-face)))))
;; now restore the initial state
(if st
(progn
(modify-syntax-entry ?\( "." st)
(modify-syntax-entry ?\) "." st)))
(if reset-st
(set-syntax-table reset-st))))