Merge from origin/emacs-24
[emacs.git] / lisp / progmodes / perl-mode.el
bloba64944f0dc54db2f70b19d26f04046847df31990
1 ;;; perl-mode.el --- Perl code editing commands for GNU Emacs -*- lexical-binding:t -*-
3 ;; Copyright (C) 1990, 1994, 2001-2015 Free Software Foundation, Inc.
5 ;; Author: William F. Mann
6 ;; Maintainer: emacs-devel@gnu.org
7 ;; Adapted-By: ESR
8 ;; Keywords: languages
10 ;; Adapted from C code editing commands 'c-mode.el', Copyright 1987 by the
11 ;; Free Software Foundation, under terms of its General Public License.
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software: you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation, either version 3 of the License, or
18 ;; (at your option) any later version.
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;;; Commentary:
30 ;; To enter perl-mode automatically, add (autoload 'perl-mode "perl-mode")
31 ;; to your init file and change the first line of your perl script to:
32 ;; #!/usr/bin/perl -- # -*-Perl-*-
33 ;; With arguments to perl:
34 ;; #!/usr/bin/perl -P- # -*-Perl-*-
35 ;; To handle files included with do 'filename.pl';, add something like
36 ;; (setq auto-mode-alist (append (list (cons "\\.pl\\'" 'perl-mode))
37 ;; auto-mode-alist))
38 ;; to your init file; otherwise the .pl suffix defaults to prolog-mode.
40 ;; This code is based on the 18.53 version c-mode.el, with extensive
41 ;; rewriting. Most of the features of c-mode survived intact.
43 ;; I added a new feature which adds functionality to TAB; it is controlled
44 ;; by the variable perl-tab-to-comment. With it enabled, TAB does the
45 ;; first thing it can from the following list: change the indentation;
46 ;; move past leading white space; delete an empty comment; reindent a
47 ;; comment; move to end of line; create an empty comment; tell you that
48 ;; the line ends in a quoted string, or has a # which should be a \#.
50 ;; If your machine is slow, you may want to remove some of the bindings
51 ;; to perl-electric-terminator. I changed the indenting defaults to be
52 ;; what Larry Wall uses in perl/lib, but left in all the options.
54 ;; I also tuned a few things: comments and labels starting in column
55 ;; zero are left there by perl-indent-exp; perl-beginning-of-function
56 ;; goes back to the first open brace/paren in column zero, the open brace
57 ;; in 'sub ... {', or the equal sign in 'format ... ='; perl-indent-exp
58 ;; (meta-^q) indents from the current line through the close of the next
59 ;; brace/paren, so you don't need to start exactly at a brace or paren.
61 ;; It may be good style to put a set of redundant braces around your
62 ;; main program. This will let you reindent it with meta-^q.
64 ;; Known problems (these are all caused by limitations in the Emacs Lisp
65 ;; parsing routine (parse-partial-sexp), which was not designed for such
66 ;; a rich language; writing a more suitable parser would be a big job):
67 ;; 2) The globbing syntax <pattern> is not recognized, so special
68 ;; characters in the pattern string must be backslashed.
70 ;; Here are some ugly tricks to bypass some of these problems: the perl
71 ;; expression /`/ (that's a back-tick) usually evaluates harmlessly,
72 ;; but will trick perl-mode into starting a quoted string, which
73 ;; can be ended with another /`/. Assuming you have no embedded
74 ;; back-ticks, this can used to help solve problem 3:
76 ;; /`/; $ugly = q?"'$?; /`/;
78 ;; The same trick can be used for problem 6 as in:
79 ;; /{/; while (<${glob_me}>)
80 ;; but a simpler solution is to add a space between the $ and the {:
81 ;; while (<$ {glob_me}>)
83 ;; Problem 7 is even worse, but this 'fix' does work :-(
84 ;; $DB'stop#'
85 ;; [$DB'line#'
86 ;; ] =~ s/;9$//;
88 ;;; Code:
90 (defgroup perl nil
91 "Major mode for editing Perl code."
92 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
93 :prefix "perl-"
94 :group 'languages)
96 (defvar perl-mode-abbrev-table nil
97 "Abbrev table in use in perl-mode buffers.")
98 (define-abbrev-table 'perl-mode-abbrev-table ())
100 (defvar perl-mode-map
101 (let ((map (make-sparse-keymap)))
102 (define-key map "\e\C-a" 'perl-beginning-of-function)
103 (define-key map "\e\C-e" 'perl-end-of-function)
104 (define-key map "\e\C-h" 'perl-mark-function)
105 (define-key map "\e\C-q" 'perl-indent-exp)
106 (define-key map "\177" 'backward-delete-char-untabify)
107 map)
108 "Keymap used in Perl mode.")
110 (defvar perl-mode-syntax-table
111 (let ((st (make-syntax-table (standard-syntax-table))))
112 (modify-syntax-entry ?\n ">" st)
113 (modify-syntax-entry ?# "<" st)
114 ;; `$' is also a prefix char so I was tempted to say "/ p",
115 ;; but the `p' thingy basically overrides the `/' :-( -- Stef
116 (modify-syntax-entry ?$ "/" st)
117 (modify-syntax-entry ?% ". p" st)
118 (modify-syntax-entry ?@ ". p" st)
119 (modify-syntax-entry ?& "." st)
120 (modify-syntax-entry ?\' "\"" st)
121 (modify-syntax-entry ?* "." st)
122 (modify-syntax-entry ?+ "." st)
123 (modify-syntax-entry ?- "." st)
124 (modify-syntax-entry ?/ "." st)
125 (modify-syntax-entry ?< "." st)
126 (modify-syntax-entry ?= "." st)
127 (modify-syntax-entry ?> "." st)
128 (modify-syntax-entry ?\\ "\\" st)
129 (modify-syntax-entry ?` "\"" st)
130 (modify-syntax-entry ?| "." st)
132 "Syntax table in use in `perl-mode' buffers.")
134 (defvar perl-imenu-generic-expression
135 '(;; Functions
136 (nil "^[ \t]*sub\\s-+\\([-[:alnum:]+_:]+\\)" 1)
137 ;;Variables
138 ("Variables" "^\\(?:my\\|our\\)\\s-+\\([$@%][-[:alnum:]+_:]+\\)\\s-*=" 1)
139 ("Packages" "^[ \t]*package\\s-+\\([-[:alnum:]+_:]+\\);" 1)
140 ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1))
141 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.")
143 ;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and
144 ;; Jim Campbell <jec@murzim.ca.boeing.com>.
146 (defconst perl--prettify-symbols-alist
147 '(("->" . ?→)
148 ("=>" . ?⇒)
149 ("::" . ?∷)))
151 (defconst perl-font-lock-keywords-1
152 '(;; What is this for?
153 ;;("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face)
155 ;; Fontify preprocessor statements as we do in `c-font-lock-keywords'.
156 ;; Ilya Zakharevich <ilya@math.ohio-state.edu> thinks this is a bad idea.
157 ;; ("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
158 ;; ("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
159 ;; ("^#[ \t]*if\\>"
160 ;; ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
161 ;; (1 font-lock-constant-face) (2 font-lock-variable-name-face nil t)))
162 ;; ("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
163 ;; (1 font-lock-constant-face) (2 font-lock-variable-name-face nil t))
165 ;; Fontify function and package names in declarations.
166 ("\\<\\(package\\|sub\\)\\>[ \t]*\\(\\sw+\\)?"
167 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
168 ("\\<\\(import\\|no\\|require\\|use\\)\\>[ \t]*\\(\\sw+\\)?"
169 (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)))
170 "Subdued level highlighting for Perl mode.")
172 (defconst perl-font-lock-keywords-2
173 (append
174 perl-font-lock-keywords-1
175 `( ;; Fontify keywords, except those fontified otherwise.
176 ,(concat "\\<"
177 (regexp-opt '("if" "until" "while" "elsif" "else" "unless"
178 "do" "dump" "for" "foreach" "exit" "die"
179 "BEGIN" "END" "return" "exec" "eval") t)
180 "\\>")
182 ;; Fontify local and my keywords as types.
183 ("\\<\\(local\\|my\\)\\>" . font-lock-type-face)
185 ;; Fontify function, variable and file name references.
186 ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
187 ;; Additionally underline non-scalar variables. Maybe this is a bad idea.
188 ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
189 ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
190 ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
191 (2 (cons font-lock-variable-name-face '(underline))))
192 ("<\\(\\sw+\\)>" 1 font-lock-constant-face)
194 ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
195 ("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?"
196 (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
197 ("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-constant-face)))
198 "Gaudy level highlighting for Perl mode.")
200 (defvar perl-font-lock-keywords perl-font-lock-keywords-1
201 "Default expressions to highlight in Perl mode.")
203 (defvar perl-quote-like-pairs
204 '((?\( . ?\)) (?\[ . ?\]) (?\{ . ?\}) (?\< . ?\>)))
206 (eval-and-compile
207 (defconst perl--syntax-exp-intro-regexp
208 (concat "\\(?:\\(?:^\\|[^$@&%[:word:]]\\)"
209 (regexp-opt '("split" "if" "unless" "until" "while" "print"
210 "grep" "map" "not" "or" "and" "for" "foreach"))
211 "\\|[-?:.,;|&+*=!~({[]\\|\\(^\\)\\)[ \t\n]*")))
213 ;; FIXME: handle here-docs and regexps.
214 ;; <<EOF <<"EOF" <<'EOF' (no space)
215 ;; see `man perlop'
216 ;; ?...?
217 ;; /.../
218 ;; m [...]
219 ;; m /.../
220 ;; q /.../ = '...'
221 ;; qq /.../ = "..."
222 ;; qx /.../ = `...`
223 ;; qr /.../ = precompiled regexp =~=~ m/.../
224 ;; qw /.../
225 ;; s /.../.../
226 ;; s <...> /.../
227 ;; s '...'...'
228 ;; tr /.../.../
229 ;; y /.../.../
231 ;; <file*glob>
232 (defun perl-syntax-propertize-function (start end)
233 (let ((case-fold-search nil))
234 (goto-char start)
235 (perl-syntax-propertize-special-constructs end)
236 (funcall
237 (syntax-propertize-rules
238 ;; Turn POD into b-style comments. Place the cut rule first since it's
239 ;; more specific.
240 ("^=cut\\>.*\\(\n\\)" (1 "> b"))
241 ("^\\(=\\)\\sw" (1 "< b"))
242 ;; Catch ${ so that ${var} doesn't screw up indentation.
243 ;; This also catches $' to handle 'foo$', although it should really
244 ;; check that it occurs inside a '..' string.
245 ("\\(\\$\\)[{']" (1 (unless (and (eq ?\' (char-after (match-end 1)))
246 (save-excursion
247 (not (nth 3 (syntax-ppss
248 (match-beginning 0))))))
249 (string-to-syntax ". p"))))
250 ;; Handle funny names like $DB'stop.
251 ("\\$ ?{?^?[_[:alpha:]][_[:alnum:]]*\\('\\)[_[:alpha:]]" (1 "_"))
252 ;; format statements
253 ("^[ \t]*format.*=[ \t]*\\(\n\\)"
254 (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
255 ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
256 ;; Be careful not to match "sub { (...) ... }".
257 ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
258 (1 "."))
259 ;; Turn __DATA__ trailer into a comment.
260 ("^\\(_\\)_\\(?:DATA\\|END\\)__[ \t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"
261 (1 "< c") (2 "> c")
262 (0 (ignore (put-text-property (match-beginning 0) (match-end 0)
263 'syntax-multiline t))))
264 ;; Regexp and funny quotes. Distinguishing a / that starts a regexp
265 ;; match from the division operator is ...interesting.
266 ;; Basically, / is a regexp match if it's preceded by an infix operator
267 ;; (or some similar separator), or by one of the special keywords
268 ;; corresponding to builtin functions that can take their first arg
269 ;; without parentheses. Of course, that presume we're looking at the
270 ;; *opening* slash. We can afford to mis-match the closing ones
271 ;; here, because they will be re-treated separately later in
272 ;; perl-font-lock-special-syntactic-constructs.
273 ((concat perl--syntax-exp-intro-regexp "\\(/\\)")
274 (2 (ignore
275 (if (and (match-end 1) ; / at BOL.
276 (save-excursion
277 (goto-char (match-end 1))
278 (forward-comment (- (point-max)))
279 (put-text-property (point) (match-end 2)
280 'syntax-multiline t)
281 (not (memq (char-before)
282 '(?? ?: ?. ?, ?\; ?= ?! ?~ ?\( ?\[)))))
283 nil ;; A division sign instead of a regexp-match.
284 (put-text-property (match-beginning 2) (match-end 2)
285 'syntax-table (string-to-syntax "\""))
286 (perl-syntax-propertize-special-constructs end)))))
287 ("\\(^\\|[?:.,;=!~({[ \t]\\)\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\(?:\\([^])}>= \n\t]\\)\\|\\(?3:=\\)[^>]\\)"
288 ;; Nasty cases:
289 ;; /foo/m $a->m $#m $m @m %m
290 ;; \s (appears often in regexps).
291 ;; -s file
292 ;; y => 3
293 ;; sub tr {...}
294 (3 (ignore
295 (if (save-excursion (goto-char (match-beginning 0))
296 (forward-word -1)
297 (looking-at-p "sub[ \t\n]"))
298 ;; This is defining a function.
300 (put-text-property (match-beginning 3) (match-end 3)
301 'syntax-table
302 (if (assoc (char-after (match-beginning 3))
303 perl-quote-like-pairs)
304 (string-to-syntax "|")
305 (string-to-syntax "\"")))
306 (perl-syntax-propertize-special-constructs end)))))
307 ;; Here documents.
308 ((concat
309 "\\(?:"
310 ;; << "EOF", << 'EOF', or << \EOF
311 "<<[ \t]*\\('[^'\n]*'\\|\"[^\"\n]*\"\\|\\\\[[:alpha:]][[:alnum:]]*\\)"
312 ;; The <<EOF case which needs perl--syntax-exp-intro-regexp, to
313 ;; disambiguate with the left-bitshift operator.
314 "\\|" perl--syntax-exp-intro-regexp "<<\\(?1:\\sw+\\)\\)"
315 ".*\\(\n\\)")
316 (3 (let* ((st (get-text-property (match-beginning 3) 'syntax-table))
317 (name (match-string 1)))
318 (goto-char (match-end 1))
319 (if (save-excursion (nth 8 (syntax-ppss (match-beginning 0))))
320 ;; Leave the property of the newline unchanged.
322 (cons (car (string-to-syntax "< c"))
323 ;; Remember the names of heredocs found on this line.
324 (cons (pcase (aref name 0)
325 (`?\\ (substring name 1))
326 ((or `?\" `?\' `?\`) (substring name 1 -1))
327 (_ name))
328 (cdr st)))))))
329 ;; We don't call perl-syntax-propertize-special-constructs directly
330 ;; from the << rule, because there might be other elements (between
331 ;; the << and the \n) that need to be propertized.
332 ("\\(?:$\\)\\s<"
333 (0 (ignore (perl-syntax-propertize-special-constructs end))))
335 (point) end)))
337 (defvar perl-empty-syntax-table
338 (let ((st (copy-syntax-table)))
339 ;; Make all chars be of punctuation syntax.
340 (dotimes (i 256) (aset st i '(1)))
341 (modify-syntax-entry ?\\ "\\" st)
343 "Syntax table used internally for processing quote-like operators.")
345 (defun perl-quote-syntax-table (char)
346 (let ((close (cdr (assq char perl-quote-like-pairs)))
347 (st (copy-syntax-table perl-empty-syntax-table)))
348 (if (not close)
349 (modify-syntax-entry char "\"" st)
350 (modify-syntax-entry char "(" st)
351 (modify-syntax-entry close ")" st))
352 st))
354 (defun perl-syntax-propertize-special-constructs (limit)
355 "Propertize special constructs like regexps and formats."
356 (let ((state (syntax-ppss))
357 char)
358 (cond
359 ((eq 2 (nth 7 state))
360 ;; A Here document.
361 (let ((names (cdr (get-text-property (nth 8 state) 'syntax-table))))
362 (when (cdr names)
363 (setq names (reverse names))
364 ;; Multiple heredocs on a single line, we have to search from the
365 ;; beginning, since we don't know which names might be
366 ;; before point.
367 (goto-char (nth 8 state)))
368 (while (and names
369 (re-search-forward
370 (concat "^" (regexp-quote (pop names)) "\n")
371 limit 'move))
372 (unless names
373 (put-text-property (1- (point)) (point) 'syntax-table
374 (string-to-syntax "> c"))))))
375 ((or (null (setq char (nth 3 state)))
376 (and (characterp char) (eq (char-syntax (nth 3 state)) ?\")))
377 ;; Normal text, or comment, or docstring, or normal string.
378 nil)
379 ((eq (nth 3 state) ?\n)
380 ;; A `format' command.
381 (when (re-search-forward "^\\s *\\.\\s *\n" limit 'move)
382 (put-text-property (1- (point)) (point)
383 'syntax-table (string-to-syntax "\""))))
385 ;; This is regexp like quote thingy.
386 (setq char (char-after (nth 8 state)))
387 (let ((startpos (point))
388 (twoargs (save-excursion
389 (goto-char (nth 8 state))
390 (skip-syntax-backward " ")
391 (skip-syntax-backward "w")
392 (member (buffer-substring
393 (point) (progn (forward-word 1) (point)))
394 '("tr" "s" "y"))))
395 (close (cdr (assq char perl-quote-like-pairs)))
396 (st (perl-quote-syntax-table char)))
397 (when (with-syntax-table st
398 (if close
399 ;; For paired delimiters, Perl allows nesting them, but
400 ;; since we treat them as strings, Emacs does not count
401 ;; those delimiters in `state', so we don't know how deep
402 ;; we are: we have to go back to the beginning of this
403 ;; "string" and count from there.
404 (condition-case nil
405 (progn
406 ;; Start after the first char since it doesn't have
407 ;; paren-syntax (an alternative would be to let-bind
408 ;; parse-sexp-lookup-properties).
409 (goto-char (1+ (nth 8 state)))
410 (up-list 1)
412 ;; In case of error, make sure we don't move backward.
413 (scan-error (goto-char startpos) nil))
414 (not (or (nth 8 (parse-partial-sexp
415 ;; Since we don't know if point is within
416 ;; the first or the scond arg, we have to
417 ;; start from the beginning.
418 (if twoargs (1+ (nth 8 state)) (point))
419 limit nil nil state 'syntax-table))
420 ;; If we have a self-paired opener and a twoargs
421 ;; command, the form is s/../../ so we have to skip
422 ;; a second time.
423 ;; In the case of s{...}{...}, we only handle the
424 ;; first part here and the next below.
425 (when (and twoargs (not close))
426 (nth 8 (parse-partial-sexp
427 (point) limit
428 nil nil state 'syntax-table)))))))
429 ;; Point is now right after the arg(s).
430 (when (eq (char-before (1- (point))) ?$)
431 (put-text-property (- (point) 2) (1- (point))
432 'syntax-table '(1)))
433 (put-text-property (1- (point)) (point)
434 'syntax-table
435 (if close
436 (string-to-syntax "|")
437 (string-to-syntax "\"")))
438 ;; If we have two args with a non-self-paired starter (e.g.
439 ;; s{...}{...}) we're right after the first arg, so we still have to
440 ;; handle the second part.
441 (when (and twoargs close)
442 ;; Skip whitespace and make sure that font-lock will
443 ;; refontify the second part in the proper context.
444 (put-text-property
445 (point) (progn (forward-comment (point-max)) (point))
446 'syntax-multiline t)
448 (when (< (point) limit)
449 (put-text-property (point) (1+ (point))
450 'syntax-table
451 (if (assoc (char-after)
452 perl-quote-like-pairs)
453 ;; Put an `e' in the cdr to mark this
454 ;; char as "second arg starter".
455 (string-to-syntax "|e")
456 (string-to-syntax "\"e")))
457 (forward-char 1)
458 ;; Re-use perl-syntax-propertize-special-constructs to handle the
459 ;; second part (the first delimiter of second part can't be
460 ;; preceded by "s" or "tr" or "y", so it will not be considered
461 ;; as twoarg).
462 (perl-syntax-propertize-special-constructs limit)))))))))
464 (defun perl-font-lock-syntactic-face-function (state)
465 (cond
466 ((and (nth 3 state)
467 (eq ?e (cdr-safe (get-text-property (nth 8 state) 'syntax-table)))
468 ;; This is a second-arg of s{..}{...} form; let's check if this second
469 ;; arg is executable code rather than a string. For that, we need to
470 ;; look for an "e" after this second arg, so we have to hunt for the
471 ;; end of the arg. Depending on whether the whole arg has already
472 ;; been syntax-propertized or not, the end-char will have different
473 ;; syntaxes, so let's ignore syntax-properties temporarily so we can
474 ;; pretend it has not been syntax-propertized yet.
475 (let* ((parse-sexp-lookup-properties nil)
476 (char (char-after (nth 8 state)))
477 (paired (assq char perl-quote-like-pairs)))
478 (with-syntax-table (perl-quote-syntax-table char)
479 (save-excursion
480 (if (not paired)
481 (parse-partial-sexp (point) (point-max)
482 nil nil state 'syntax-table)
483 (condition-case nil
484 (progn
485 (goto-char (1+ (nth 8 state)))
486 (up-list 1))
487 (scan-error (goto-char (point-max)))))
488 (put-text-property (nth 8 state) (point)
489 'jit-lock-defer-multiline t)
490 (looking-at "[ \t]*\\sw*e")))))
491 nil)
492 (t (funcall (default-value 'font-lock-syntactic-face-function) state))))
494 (defcustom perl-indent-level 4
495 "Indentation of Perl statements with respect to containing block."
496 :type 'integer)
498 ;; Is is not unusual to put both things like perl-indent-level and
499 ;; cperl-indent-level in the local variable section of a file. If only
500 ;; one of perl-mode and cperl-mode is in use, a warning will be issued
501 ;; about the variable. Autoload these here, so that no warning is
502 ;; issued when using either perl-mode or cperl-mode.
503 ;;;###autoload(put 'perl-indent-level 'safe-local-variable 'integerp)
504 ;;;###autoload(put 'perl-continued-statement-offset 'safe-local-variable 'integerp)
505 ;;;###autoload(put 'perl-continued-brace-offset 'safe-local-variable 'integerp)
506 ;;;###autoload(put 'perl-brace-offset 'safe-local-variable 'integerp)
507 ;;;###autoload(put 'perl-brace-imaginary-offset 'safe-local-variable 'integerp)
508 ;;;###autoload(put 'perl-label-offset 'safe-local-variable 'integerp)
510 (defcustom perl-continued-statement-offset 4
511 "Extra indent for lines not starting new statements."
512 :type 'integer)
513 (defcustom perl-continued-brace-offset -4
514 "Extra indent for substatements that start with open-braces.
515 This is in addition to `perl-continued-statement-offset'."
516 :type 'integer)
517 (defcustom perl-brace-offset 0
518 "Extra indentation for braces, compared with other text in same context."
519 :type 'integer)
520 (defcustom perl-brace-imaginary-offset 0
521 "Imagined indentation of an open brace that actually follows a statement."
522 :type 'integer)
523 (defcustom perl-label-offset -2
524 "Offset of Perl label lines relative to usual indentation."
525 :type 'integer)
526 (defcustom perl-indent-continued-arguments nil
527 "If non-nil offset of argument lines relative to usual indentation.
528 If nil, continued arguments are aligned with the first argument."
529 :type '(choice integer (const nil)))
531 (defcustom perl-indent-parens-as-block nil
532 "Non-nil means that non-block ()-, {}- and []-groups are indented as blocks.
533 The closing bracket is aligned with the line of the opening bracket,
534 not the contents of the brackets."
535 :version "24.3"
536 :type 'boolean)
538 (defcustom perl-tab-always-indent tab-always-indent
539 "Non-nil means TAB in Perl mode always indents the current line.
540 Otherwise it inserts a tab character if you type it past the first
541 nonwhite character on the line."
542 :type 'boolean)
544 ;; I changed the default to nil for consistency with general Emacs
545 ;; conventions -- rms.
546 (defcustom perl-tab-to-comment nil
547 "Non-nil means TAB moves to eol or makes a comment in some cases.
548 For lines which don't need indenting, TAB either indents an
549 existing comment, moves to end-of-line, or if at end-of-line already,
550 create a new comment."
551 :type 'boolean)
553 (defcustom perl-nochange "\f"
554 "Lines starting with this regular expression are not auto-indented."
555 :type 'regexp
556 :options '(";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:[^:]"))
558 ;; Outline support
560 (defvar perl-outline-regexp
561 (concat (mapconcat 'cadr perl-imenu-generic-expression "\\|")
562 "\\|^=cut\\>"))
564 (defun perl-outline-level ()
565 (cond
566 ((looking-at "[ \t]*\\(package\\)\\s-")
567 (- (match-beginning 1) (match-beginning 0)))
568 ((looking-at "[ \t]*s\\(ub\\)\\s-")
569 (- (match-beginning 1) (match-beginning 0)))
570 ((looking-at "=head[0-9]") (- (char-before (match-end 0)) ?0))
571 ((looking-at "=cut") 1)
572 (t 3)))
574 (defun perl-current-defun-name ()
575 "The `add-log-current-defun' function in Perl mode."
576 (save-excursion
577 (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t)
578 (match-string-no-properties 1))))
581 (defvar perl-mode-hook nil
582 "Normal hook to run when entering Perl mode.")
584 ;;;###autoload
585 (define-derived-mode perl-mode prog-mode "Perl"
586 "Major mode for editing Perl code.
587 Expression and list commands understand all Perl brackets.
588 Tab indents for Perl code.
589 Comments are delimited with # ... \\n.
590 Paragraphs are separated by blank lines only.
591 Delete converts tabs to spaces as it moves back.
592 \\{perl-mode-map}
593 Variables controlling indentation style:
594 `perl-tab-always-indent'
595 Non-nil means TAB in Perl mode should always indent the current line,
596 regardless of where in the line point is when the TAB command is used.
597 `perl-tab-to-comment'
598 Non-nil means that for lines which don't need indenting, TAB will
599 either delete an empty comment, indent an existing comment, move
600 to end-of-line, or if at end-of-line already, create a new comment.
601 `perl-nochange'
602 Lines starting with this regular expression are not auto-indented.
603 `perl-indent-level'
604 Indentation of Perl statements within surrounding block.
605 The surrounding block's indentation is the indentation
606 of the line on which the open-brace appears.
607 `perl-continued-statement-offset'
608 Extra indentation given to a substatement, such as the
609 then-clause of an if or body of a while.
610 `perl-continued-brace-offset'
611 Extra indentation given to a brace that starts a substatement.
612 This is in addition to `perl-continued-statement-offset'.
613 `perl-brace-offset'
614 Extra indentation for line if it starts with an open brace.
615 `perl-brace-imaginary-offset'
616 An open brace following other text is treated as if it were
617 this far to the right of the start of its line.
618 `perl-label-offset'
619 Extra indentation for line that is a label.
620 `perl-indent-continued-arguments'
621 Offset of argument lines relative to usual indentation.
623 Various indentation styles: K&R BSD BLK GNU LW
624 perl-indent-level 5 8 0 2 4
625 perl-continued-statement-offset 5 8 4 2 4
626 perl-continued-brace-offset 0 0 0 0 -4
627 perl-brace-offset -5 -8 0 0 0
628 perl-brace-imaginary-offset 0 0 4 0 0
629 perl-label-offset -5 -8 -2 -2 -2
631 Turning on Perl mode runs the normal hook `perl-mode-hook'."
632 :abbrev-table perl-mode-abbrev-table
633 (setq-local paragraph-start (concat "$\\|" page-delimiter))
634 (setq-local paragraph-separate paragraph-start)
635 (setq-local paragraph-ignore-fill-prefix t)
636 (setq-local indent-line-function #'perl-indent-line)
637 (setq-local comment-start "# ")
638 (setq-local comment-end "")
639 (setq-local comment-start-skip "\\(^\\|\\s-\\);?#+ *")
640 (setq-local comment-indent-function #'perl-comment-indent)
641 (setq-local parse-sexp-ignore-comments t)
643 ;; Tell font-lock.el how to handle Perl.
644 (setq font-lock-defaults '((perl-font-lock-keywords
645 perl-font-lock-keywords-1
646 perl-font-lock-keywords-2)
647 nil nil ((?\_ . "w")) nil
648 (font-lock-syntactic-face-function
649 . perl-font-lock-syntactic-face-function)))
650 (setq-local prettify-symbols-alist perl--prettify-symbols-alist)
651 (setq-local syntax-propertize-function #'perl-syntax-propertize-function)
652 (add-hook 'syntax-propertize-extend-region-functions
653 #'syntax-propertize-multiline 'append 'local)
654 ;; Electricity.
655 ;; FIXME: setup electric-layout-rules.
656 (setq-local electric-indent-chars
657 (append '(?\{ ?\} ?\; ?\:) electric-indent-chars))
658 (add-hook 'electric-indent-functions #'perl-electric-noindent-p nil t)
659 ;; Tell imenu how to handle Perl.
660 (setq-local imenu-generic-expression perl-imenu-generic-expression)
661 (setq imenu-case-fold-search nil)
662 ;; Setup outline-minor-mode.
663 (setq-local outline-regexp perl-outline-regexp)
664 (setq-local outline-level 'perl-outline-level)
665 (setq-local add-log-current-defun-function #'perl-current-defun-name))
667 ;; This is used by indent-for-comment
668 ;; to decide how much to indent a comment in Perl code
669 ;; based on its context.
670 (defun perl-comment-indent ()
671 (if (and (bolp) (not (eolp)))
672 0 ;Existing comment at bol stays there.
673 comment-column))
675 (define-obsolete-function-alias 'electric-perl-terminator
676 'perl-electric-terminator "22.1")
677 (defun perl-electric-noindent-p (_char)
678 (unless (eolp) 'no-indent))
680 (defun perl-electric-terminator (arg)
681 "Insert character and maybe adjust indentation.
682 If at end-of-line, and not in a comment or a quote, correct the indentation."
683 (interactive "P")
684 (let ((insertpos (point)))
685 (and (not arg) ; decide whether to indent
686 (eolp)
687 (save-excursion
688 (beginning-of-line)
689 (and (not ; eliminate comments quickly
690 (and comment-start-skip
691 (re-search-forward comment-start-skip insertpos t)) )
692 (or (/= last-command-event ?:)
693 ;; Colon is special only after a label ....
694 (looking-at "\\s-*\\(\\w\\|\\s_\\)+$"))
695 (let ((pps (parse-partial-sexp
696 (perl-beginning-of-function) insertpos)))
697 (not (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))
698 (progn ; must insert, indent, delete
699 (insert-char last-command-event 1)
700 (perl-indent-line)
701 (delete-char -1))))
702 (self-insert-command (prefix-numeric-value arg)))
703 (make-obsolete 'perl-electric-terminator 'electric-indent-mode "24.4")
705 ;; not used anymore, but may be useful someday:
706 ;;(defun perl-inside-parens-p ()
707 ;; (condition-case ()
708 ;; (save-excursion
709 ;; (save-restriction
710 ;; (narrow-to-region (point)
711 ;; (perl-beginning-of-function))
712 ;; (goto-char (point-max))
713 ;; (= (char-after (or (scan-lists (point) -1 1) (point-min))) ?\()))
714 ;; (error nil)))
716 (defun perl-indent-command (&optional arg)
717 "Indent Perl code in the active region or current line.
718 In Transient Mark mode, when the region is active, reindent the region.
719 Otherwise, with a prefix argument, reindent the current line
720 unconditionally.
722 Otherwise, if `perl-tab-always-indent' is nil and point is not in
723 the indentation area at the beginning of the line, insert a tab.
725 Otherwise, indent the current line. If point was within the
726 indentation area, it is moved to the end of the indentation area.
727 If the line was already indented properly and point was not
728 within the indentation area, and if `perl-tab-to-comment' is
729 non-nil (the default), then do the first possible action from the
730 following list:
732 1) delete an empty comment
733 2) move forward to start of comment, indenting if necessary
734 3) move forward to end of line
735 4) create an empty comment
736 5) move backward to start of comment, indenting if necessary."
737 (interactive "P")
738 (cond ((use-region-p) ; indent the active region
739 (indent-region (region-beginning) (region-end)))
740 (arg
741 (perl-indent-line "\f")) ; just indent this line
742 ((and (not perl-tab-always-indent)
743 (> (current-column) (current-indentation)))
744 (insert-tab))
746 (let* ((oldpnt (point))
747 (lsexp (progn (beginning-of-line) (point)))
748 (bof (perl-beginning-of-function))
749 (delta (progn
750 (goto-char oldpnt)
751 (perl-indent-line "\f\\|;?#"))))
752 (and perl-tab-to-comment
753 (= oldpnt (point)) ; done if point moved
754 (if (listp delta) ; if line starts in a quoted string
755 (setq lsexp (or (nth 2 delta) bof))
756 (= delta 0)) ; done if indenting occurred
757 (let ((eol (progn (end-of-line) (point)))
758 state)
759 (cond ((= (char-after bof) ?=)
760 (if (= oldpnt eol)
761 (message "In a format statement")))
762 ((progn (setq state (parse-partial-sexp lsexp eol))
763 (nth 3 state))
764 (if (= oldpnt eol) ; already at eol in a string
765 (message "In a string which starts with a %c."
766 (nth 3 state))))
767 ((not (nth 4 state))
768 (if (= oldpnt eol) ; no comment, create one?
769 (indent-for-comment)))
770 ((progn (beginning-of-line)
771 (and comment-start-skip
772 (re-search-forward
773 comment-start-skip eol 'move)))
774 (if (eolp)
775 (progn ; delete existing comment
776 (goto-char (match-beginning 0))
777 (skip-chars-backward " \t")
778 (delete-region (point) eol))
779 (if (or (< oldpnt (point)) (= oldpnt eol))
780 (indent-for-comment) ; indent existing comment
781 (end-of-line))))
782 ((/= oldpnt eol)
783 (end-of-line))
785 (message "Use backslash to quote # characters.")
786 (ding t)))))))))
787 (make-obsolete 'perl-indent-command 'indent-according-to-mode "24.4")
789 (defun perl-indent-line (&optional nochange)
790 "Indent current line as Perl code.
791 Return the amount the indentation
792 changed by, or (parse-state) if line starts in a quoted string."
793 (let ((case-fold-search nil)
794 (pos (- (point-max) (point)))
795 beg indent shift-amt)
796 (beginning-of-line)
797 (setq beg (point))
798 (setq shift-amt
799 (cond ((eq 1 (nth 7 (syntax-ppss))) 0) ;For doc sections!
800 ((listp (setq indent (perl-calculate-indent))) indent)
801 ((eq 'noindent indent) indent)
802 ((looking-at (or nochange perl-nochange)) 0)
804 (skip-chars-forward " \t\f")
805 (setq indent (perl-indent-new-calculate nil indent))
806 (- indent (current-column)))))
807 (skip-chars-forward " \t\f")
808 (if (and (numberp shift-amt) (/= 0 shift-amt))
809 (progn (delete-region beg (point))
810 (indent-to indent)))
811 ;; If initial point was within line's indentation,
812 ;; position after the indentation. Else stay at same point in text.
813 (if (> (- (point-max) pos) (point))
814 (goto-char (- (point-max) pos)))
815 shift-amt))
817 (defun perl-continuation-line-p ()
818 "Move to end of previous line and return non-nil if continued."
819 ;; Statement level. Is it a continuation or a new statement?
820 ;; Find previous non-comment character.
821 (perl-backward-to-noncomment)
822 ;; Back up over label lines, since they don't
823 ;; affect whether our line is a continuation.
824 (while (and (eq (preceding-char) ?:)
825 (memq (char-syntax (char-after (- (point) 2)))
826 '(?w ?_)))
827 (beginning-of-line)
828 (perl-backward-to-noncomment))
829 ;; Now we get the answer.
830 (unless (memq (preceding-char) '(?\; ?\} ?\{))
831 (preceding-char)))
833 (defun perl-hanging-paren-p ()
834 "Non-nil if we are right after a hanging parenthesis-like char."
835 (and (looking-at "[ \t]*$")
836 (save-excursion
837 (skip-syntax-backward " (") (not (bolp)))))
839 (defun perl-indent-new-calculate (&optional virtual default)
841 (and virtual (save-excursion (skip-chars-backward " \t") (bolp))
842 (current-column))
843 (and (looking-at "\\(\\w\\|\\s_\\)+:[^:]")
844 (max 1 (+ (or default (perl-calculate-indent))
845 perl-label-offset)))
846 (and (= (char-syntax (following-char)) ?\))
847 (save-excursion
848 (forward-char 1)
849 (when (condition-case nil (progn (forward-sexp -1) t)
850 (scan-error nil))
851 (perl-indent-new-calculate 'virtual))))
852 (and (and (= (following-char) ?{)
853 (save-excursion (forward-char) (perl-hanging-paren-p)))
854 (+ (or default (perl-calculate-indent))
855 perl-brace-offset))
856 (or default (perl-calculate-indent))))
858 (defun perl-calculate-indent ()
859 "Return appropriate indentation for current line as Perl code.
860 In usual case returns an integer: the column to indent to.
861 Returns (parse-state) if line starts inside a string."
862 (save-excursion
863 (let ((indent-point (point))
864 (case-fold-search nil)
865 (colon-line-end 0)
866 prev-char
867 state containing-sexp)
868 (setq containing-sexp (nth 1 (syntax-ppss indent-point)))
869 (cond
870 ;; Don't auto-indent in a quoted string or a here-document.
871 ((or (nth 3 state) (eq 2 (nth 7 state))) 'noindent)
872 ((null containing-sexp) ; Line is at top level.
873 (skip-chars-forward " \t\f")
874 (if (memq (following-char)
875 (if perl-indent-parens-as-block '(?\{ ?\( ?\[) '(?\{)))
876 0 ; move to beginning of line if it starts a function body
877 ;; indent a little if this is a continuation line
878 (perl-backward-to-noncomment)
879 (if (or (bobp)
880 (memq (preceding-char) '(?\; ?\})))
881 0 perl-continued-statement-offset)))
882 ((/= (char-after containing-sexp) ?{)
883 ;; line is expression, not statement:
884 ;; indent to just after the surrounding open.
885 (goto-char (1+ containing-sexp))
886 (if (perl-hanging-paren-p)
887 ;; We're indenting an arg of a call like:
888 ;; $a = foobarlongnamefun (
889 ;; arg1
890 ;; arg2
891 ;; );
892 (progn
893 (skip-syntax-backward "(")
894 (condition-case nil
895 (while (save-excursion
896 (skip-syntax-backward " ") (not (bolp)))
897 (forward-sexp -1))
898 (scan-error nil))
899 (+ (current-column) perl-indent-level))
900 (if perl-indent-continued-arguments
901 (+ perl-indent-continued-arguments (current-indentation))
902 (skip-chars-forward " \t")
903 (current-column))))
904 ;; Statement level. Is it a continuation or a new statement?
905 ((setq prev-char (perl-continuation-line-p))
906 ;; This line is continuation of preceding line's statement;
907 ;; indent perl-continued-statement-offset more than the
908 ;; previous line of the statement.
909 (perl-backward-to-start-of-continued-exp)
910 (+ (if (or (save-excursion
911 (perl-continuation-line-p))
912 (and (eq prev-char ?\,)
913 (looking-at "[[:alnum:]_]+[ \t\n]*=>")))
914 ;; If the continued line is itself a continuation
915 ;; line, then align, otherwise add an offset.
916 0 perl-continued-statement-offset)
917 (current-column)
918 (if (save-excursion (goto-char indent-point)
919 (looking-at
920 (if perl-indent-parens-as-block
921 "[ \t]*[{(\[]" "[ \t]*{")))
922 perl-continued-brace-offset 0)))
924 ;; This line starts a new statement.
925 ;; Position at last unclosed open.
926 (goto-char containing-sexp)
928 ;; Is line first statement after an open-brace?
929 ;; If no, find that first statement and indent like it.
930 (save-excursion
931 (forward-char 1)
932 ;; Skip over comments and labels following openbrace.
933 (while (progn
934 (skip-chars-forward " \t\f\n")
935 (cond ((looking-at ";?#")
936 (forward-line 1) t)
937 ((looking-at "\\(\\w\\|\\s_\\)+:[^:]")
938 (setq colon-line-end (line-end-position))
939 (search-forward ":")))))
940 ;; The first following code counts
941 ;; if it is before the line we want to indent.
942 (and (< (point) indent-point)
943 (if (> colon-line-end (point))
944 (- (current-indentation) perl-label-offset)
945 (current-column))))
946 ;; If no previous statement,
947 ;; indent it relative to line brace is on.
948 ;; For open paren in column zero, don't let statement
949 ;; start there too. If perl-indent-level is zero,
950 ;; use perl-brace-offset + perl-continued-statement-offset
951 ;; For open-braces not the first thing in a line,
952 ;; add in perl-brace-imaginary-offset.
953 (+ (if (and (bolp) (zerop perl-indent-level))
954 (+ perl-brace-offset perl-continued-statement-offset)
955 perl-indent-level)
956 ;; Move back over whitespace before the openbrace.
957 ;; If openbrace is not first nonwhite thing on the line,
958 ;; add the perl-brace-imaginary-offset.
959 (progn (skip-chars-backward " \t")
960 (if (bolp) 0 perl-brace-imaginary-offset))
961 ;; If the openbrace is preceded by a parenthesized exp,
962 ;; move to the beginning of that;
963 ;; possibly a different line
964 (progn
965 (if (eq (preceding-char) ?\))
966 (forward-sexp -1))
967 ;; Get initial indentation of the line we are on.
968 (current-indentation)))))))))
970 (defun perl-backward-to-noncomment ()
971 "Move point backward to after the first non-white-space, skipping comments."
972 (forward-comment (- (point-max))))
974 (defun perl-backward-to-start-of-continued-exp ()
975 (while
976 (let ((c (preceding-char)))
977 (cond
978 ((memq c '(?\; ?\{ ?\[ ?\()) (forward-comment (point-max)) nil)
979 ((memq c '(?\) ?\] ?\} ?\"))
980 (forward-sexp -1) (forward-comment (- (point))) t)
981 ((eq ?w (char-syntax c))
982 (forward-word -1) (forward-comment (- (point))) t)
983 (t (forward-char -1) (forward-comment (- (point))) t)))))
985 ;; note: this may be slower than the c-mode version, but I can understand it.
986 (defalias 'indent-perl-exp 'perl-indent-exp)
987 (defun perl-indent-exp ()
988 "Indent each line of the Perl grouping following point."
989 (interactive)
990 (let* ((case-fold-search nil)
991 (oldpnt (point-marker))
992 (bof-mark (save-excursion
993 (end-of-line 2)
994 (perl-beginning-of-function)
995 (point-marker)))
996 eol last-mark lsexp-mark delta)
997 (if (= (char-after (marker-position bof-mark)) ?=)
998 (message "Can't indent a format statement")
999 (message "Indenting Perl expression...")
1000 (setq eol (line-end-position))
1001 (save-excursion ; locate matching close paren
1002 (while (and (not (eobp)) (<= (point) eol))
1003 (parse-partial-sexp (point) (point-max) 0))
1004 (setq last-mark (point-marker)))
1005 (setq lsexp-mark bof-mark)
1006 (beginning-of-line)
1007 (while (< (point) (marker-position last-mark))
1008 (setq delta (perl-indent-line nil))
1009 (if (numberp delta) ; unquoted start-of-line?
1010 (progn
1011 (if (eolp)
1012 (delete-horizontal-space))
1013 (setq lsexp-mark (point-marker))))
1014 (end-of-line)
1015 (setq eol (point))
1016 (if (nth 4 (parse-partial-sexp (marker-position lsexp-mark) eol))
1017 (progn ; line ends in a comment
1018 (beginning-of-line)
1019 (if (or (not (looking-at "\\s-*;?#"))
1020 (listp delta)
1021 (and (/= 0 delta)
1022 (= (- (current-indentation) delta) comment-column)))
1023 (if (and comment-start-skip
1024 (re-search-forward comment-start-skip eol t))
1025 (indent-for-comment))))) ; indent existing comment
1026 (forward-line 1))
1027 (goto-char (marker-position oldpnt))
1028 (message "Indenting Perl expression...done"))))
1030 (defun perl-beginning-of-function (&optional arg)
1031 "Move backward to next beginning-of-function, or as far as possible.
1032 With argument, repeat that many times; negative args move forward.
1033 Returns new value of point in all cases."
1034 (interactive "p")
1035 (or arg (setq arg 1))
1036 (if (< arg 0) (forward-char 1))
1037 (and (/= arg 0)
1038 (re-search-backward
1039 "^\\s(\\|^\\s-*sub\\b[ \t\n]*\\_<[^{]+{\\|^\\s-*format\\b[^=]*=\\|^\\."
1040 nil 'move arg)
1041 (goto-char (1- (match-end 0))))
1042 (point))
1044 ;; note: this routine is adapted directly from emacs lisp.el, end-of-defun;
1045 ;; no bugs have been removed :-)
1046 (defun perl-end-of-function (&optional arg)
1047 "Move forward to next end-of-function.
1048 The end of a function is found by moving forward from the beginning of one.
1049 With argument, repeat that many times; negative args move backward."
1050 (interactive "p")
1051 (or arg (setq arg 1))
1052 (let ((first t))
1053 (while (and (> arg 0) (< (point) (point-max)))
1054 (let ((pos (point)))
1055 (while (progn
1056 (if (and first
1057 (progn
1058 (forward-char 1)
1059 (perl-beginning-of-function 1)
1060 (not (bobp))))
1062 (or (bobp) (forward-char -1))
1063 (perl-beginning-of-function -1))
1064 (setq first nil)
1065 (forward-list 1)
1066 (skip-chars-forward " \t")
1067 (if (looking-at "[#\n]")
1068 (forward-line 1))
1069 (<= (point) pos))))
1070 (setq arg (1- arg)))
1071 (while (< arg 0)
1072 (let ((pos (point)))
1073 (perl-beginning-of-function 1)
1074 (forward-sexp 1)
1075 (forward-line 1)
1076 (if (>= (point) pos)
1077 (if (progn (perl-beginning-of-function 2) (not (bobp)))
1078 (progn
1079 (forward-list 1)
1080 (skip-chars-forward " \t")
1081 (if (looking-at "[#\n]")
1082 (forward-line 1)))
1083 (goto-char (point-min)))))
1084 (setq arg (1+ arg)))))
1086 (defalias 'mark-perl-function 'perl-mark-function)
1087 (defun perl-mark-function ()
1088 "Put mark at end of Perl function, point at beginning."
1089 (interactive)
1090 (push-mark (point))
1091 (perl-end-of-function)
1092 (push-mark (point))
1093 (perl-beginning-of-function)
1094 (backward-paragraph))
1096 (provide 'perl-mode)
1098 ;;; perl-mode.el ends here