;;; perl-mode.el --- Perl code editing commands for GNU Emacs
-;; Copyright (C) 1990, 1994, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1994, 2001-2012 Free Software Foundation, Inc.
;; Author: William F. Mann
;; Maintainer: FSF
'(;; Functions
(nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1)
;;Variables
- ("Variables" "^\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1)
+ ("Variables" "^\\(?:my\\|our\\)\\s-+\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1)
("Packages" "^package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1)
("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1))
"Imenu generic expression for Perl mode. See `imenu-generic-expression'.")
(put-text-property (match-beginning 2) (match-end 2)
'syntax-table (string-to-syntax "\""))
(perl-syntax-propertize-special-constructs end)))))
- ("\\(^\\|[?:.,;=!~({[ \t]\\)\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\([^])}> \n\t]\\)"
+ ("\\(^\\|[?:.,;=!~({[ \t]\\)\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\(?:\\([^])}>= \n\t]\\)\\|\\(?3:=\\)[^>]\\)"
;; Nasty cases:
;; /foo/m $a->m $#m $m @m %m
;; \s (appears often in regexps).
;; -s file
+ ;; y => 3
;; sub tr {...}
(3 (ignore
(if (save-excursion (goto-char (match-beginning 0))
;; we are: we have to go back to the beginning of this
;; "string" and count from there.
(condition-case nil
- (progn
+ (progn
;; Start after the first char since it doesn't have
;; paren-syntax (an alternative would be to let-bind
;; parse-sexp-lookup-properties).
;; In case of error, make sure we don't move backward.
(scan-error (goto-char startpos) nil))
(not (or (nth 8 (parse-partial-sexp
- (point) limit nil nil state 'syntax-table))
+ ;; Since we don't know if point is within
+ ;; the first or the scond arg, we have to
+ ;; start from the beginning.
+ (if twoargs (1+ (nth 8 state)) (point))
+ limit nil nil state 'syntax-table))
;; If we have a self-paired opener and a twoargs
;; command, the form is s/../../ so we have to skip
;; a second time.
;; s{...}{...}) we're right after the first arg, so we still have to
;; handle the second part.
(when (and twoargs close)
- ;; Skip whitespace and make sure that font-lock will
- ;; refontify the second part in the proper context.
- (put-text-property
- (point) (progn (forward-comment (point-max)) (point))
+ ;; Skip whitespace and make sure that font-lock will
+ ;; refontify the second part in the proper context.
+ (put-text-property
+ (point) (progn (forward-comment (point-max)) (point))
'syntax-multiline t)
- ;;
+ ;;
(when (< (point) limit)
- (put-text-property (point) (1+ (point))
- 'syntax-table
- (if (assoc (char-after)
- perl-quote-like-pairs)
+ (put-text-property (point) (1+ (point))
+ 'syntax-table
+ (if (assoc (char-after)
+ perl-quote-like-pairs)
;; Put an `e' in the cdr to mark this
;; char as "second arg starter".
(string-to-syntax "|e")
(defalias 'electric-perl-terminator 'perl-electric-terminator)
(defun perl-electric-terminator (arg)
- "Insert character and adjust indentation.
-If at end-of-line, and not in a comment or a quote, correct the's indentation."
+ "Insert character and maybe adjust indentation.
+If at end-of-line, and not in a comment or a quote, correct the indentation."
(interactive "P")
(let ((insertpos (point)))
(and (not arg) ; decide whether to indent
(setq shift-amt
(cond ((eq (char-after bof) ?=) 0)
((listp (setq indent (perl-calculate-indent bof))) indent)
+ ((eq 'noindent indent) indent)
((looking-at (or nochange perl-nochange)) 0)
(t
(skip-chars-forward " \t\f")
(save-excursion
(beginning-of-line)
(looking-at "\\s-+sub\\>"))
- (> indent-point (save-excursion (forward-sexp 1) (point))))
+ (> indent-point (save-excursion
+ (condition-case nil
+ (forward-sexp 1)
+ (scan-error nil))
+ (point))))
(perl-beginning-of-function))
(while (< (point) indent-point) ;repeat until right sexp
(setq state (parse-partial-sexp (point) indent-point 0))
;; following_quotep minimum_paren-depth_this_scan)
;; Parsing stops if depth in parentheses becomes equal to third arg.
(setq containing-sexp (nth 1 state)))
- (cond ((nth 3 state) state) ; In a quoted string?
+ (cond ((nth 3 state) 'noindent) ; In a quoted string?
((null containing-sexp) ; Line is at top level.
(skip-chars-forward " \t\f")
(if (= (following-char) ?{)