1 |
;;; perl-mode.el --- Perl code editing commands for GNU Emacs |
;;; perl-mode.el --- Perl code editing commands for GNU Emacs |
2 |
|
|
3 |
;; Copyright (C) 1990, 1994 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1994, 2003 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: William F. Mann |
;; Author: William F. Mann |
6 |
;; Maintainer: FSF |
;; Maintainer: FSF |
260 |
;; Funny things in sub arg specifications like `sub myfunc ($$)' |
;; Funny things in sub arg specifications like `sub myfunc ($$)' |
261 |
("\\<sub\\s-+\\S-+\\s-*(\\([^)]+\\))" 1 '(1)) |
("\\<sub\\s-+\\S-+\\s-*(\\([^)]+\\))" 1 '(1)) |
262 |
;; regexp and funny quotes |
;; regexp and funny quotes |
263 |
("[;(=!~{][ \t\n]*\\(/\\)" (1 '(7))) |
("[?:.,;=!~({[][ \t\n]*\\(/\\)" (1 '(7))) |
264 |
("[;( =!~{\t\n]\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\([^])}> \n\t]\\)" |
("[?:.,;=!~({[ \t\n]\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\([^])}> \n\t]\\)" |
265 |
;; Nasty cases: |
;; Nasty cases: |
266 |
;; /foo/m $a->m $#m $m @m %m |
;; /foo/m $a->m $#m $m @m %m |
267 |
;; \s (appears often in regexps). |
;; \s (appears often in regexps). |
268 |
;; -s file |
;; -s file |
269 |
(2 (if (assoc (char-after (match-beginning 2)) |
(2 (if (assoc (char-after (match-beginning 2)) |
270 |
perl-quote-like-pairs) |
perl-quote-like-pairs) |
271 |
'(15) '(7)))))) |
'(15) '(7)))) |
272 |
|
;; TODO: here-documents ("<<\\(\\sw\\|['\"]\\)") |
273 |
|
)) |
274 |
|
|
275 |
(defvar perl-empty-syntax-table |
(defvar perl-empty-syntax-table |
276 |
(let ((st (copy-syntax-table))) |
(let ((st (copy-syntax-table))) |
371 |
|
|
372 |
(defcustom perl-indent-level 4 |
(defcustom perl-indent-level 4 |
373 |
"*Indentation of Perl statements with respect to containing block." |
"*Indentation of Perl statements with respect to containing block." |
374 |
:type 'integer |
:type 'integer) |
|
:group 'perl) |
|
375 |
(defcustom perl-continued-statement-offset 4 |
(defcustom perl-continued-statement-offset 4 |
376 |
"*Extra indent for lines not starting new statements." |
"*Extra indent for lines not starting new statements." |
377 |
:type 'integer |
:type 'integer) |
|
:group 'perl) |
|
378 |
(defcustom perl-continued-brace-offset -4 |
(defcustom perl-continued-brace-offset -4 |
379 |
"*Extra indent for substatements that start with open-braces. |
"*Extra indent for substatements that start with open-braces. |
380 |
This is in addition to `perl-continued-statement-offset'." |
This is in addition to `perl-continued-statement-offset'." |
381 |
:type 'integer |
:type 'integer) |
|
:group 'perl) |
|
382 |
(defcustom perl-brace-offset 0 |
(defcustom perl-brace-offset 0 |
383 |
"*Extra indentation for braces, compared with other text in same context." |
"*Extra indentation for braces, compared with other text in same context." |
384 |
:type 'integer |
:type 'integer) |
|
:group 'perl) |
|
385 |
(defcustom perl-brace-imaginary-offset 0 |
(defcustom perl-brace-imaginary-offset 0 |
386 |
"*Imagined indentation of an open brace that actually follows a statement." |
"*Imagined indentation of an open brace that actually follows a statement." |
387 |
:type 'integer |
:type 'integer) |
|
:group 'perl) |
|
388 |
(defcustom perl-label-offset -2 |
(defcustom perl-label-offset -2 |
389 |
"*Offset of Perl label lines relative to usual indentation." |
"*Offset of Perl label lines relative to usual indentation." |
390 |
:type 'integer |
:type 'integer) |
|
:group 'perl) |
|
391 |
(defcustom perl-indent-continued-arguments nil |
(defcustom perl-indent-continued-arguments nil |
392 |
"*If non-nil offset of argument lines relative to usual indentation. |
"*If non-nil offset of argument lines relative to usual indentation. |
393 |
If nil, continued arguments are aligned with the first argument." |
If nil, continued arguments are aligned with the first argument." |
394 |
:type '(choice integer (const nil)) |
:type '(choice integer (const nil))) |
|
:group 'perl) |
|
395 |
|
|
396 |
(defcustom perl-tab-always-indent t |
(defcustom perl-tab-always-indent tab-always-indent |
397 |
"*Non-nil means TAB in Perl mode always indents the current line. |
"Non-nil means TAB in Perl mode always indents the current line. |
398 |
Otherwise it inserts a tab character if you type it past the first |
Otherwise it inserts a tab character if you type it past the first |
399 |
nonwhite character on the line." |
nonwhite character on the line." |
400 |
:type 'boolean |
:type 'boolean) |
|
:group 'perl) |
|
401 |
|
|
402 |
;; I changed the default to nil for consistency with general Emacs |
;; I changed the default to nil for consistency with general Emacs |
403 |
;; conventions -- rms. |
;; conventions -- rms. |
406 |
For lines which don't need indenting, TAB either indents an |
For lines which don't need indenting, TAB either indents an |
407 |
existing comment, moves to end-of-line, or if at end-of-line already, |
existing comment, moves to end-of-line, or if at end-of-line already, |
408 |
create a new comment." |
create a new comment." |
409 |
:type 'boolean |
:type 'boolean) |
|
:group 'perl) |
|
410 |
|
|
411 |
(defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:" |
(defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:" |
412 |
"*Lines starting with this regular expression are not auto-indented." |
"*Lines starting with this regular expression are not auto-indented." |
413 |
:type 'regexp |
:type 'regexp) |
|
:group 'perl) |
|
414 |
|
|
415 |
;;;###autoload |
;;;###autoload |
416 |
(defun perl-mode () |
(defun perl-mode () |
885 |
(or arg (setq arg 1)) |
(or arg (setq arg 1)) |
886 |
(let ((first t)) |
(let ((first t)) |
887 |
(while (and (> arg 0) (< (point) (point-max))) |
(while (and (> arg 0) (< (point) (point-max))) |
888 |
(let ((pos (point)) npos) |
(let ((pos (point))) |
889 |
(while (progn |
(while (progn |
890 |
(if (and first |
(if (and first |
891 |
(progn |
(progn |
929 |
|
|
930 |
(provide 'perl-mode) |
(provide 'perl-mode) |
931 |
|
|
932 |
|
;;; arch-tag: 8c7ff68d-15f3-46a2-ade2-b7c41f176826 |
933 |
;;; perl-mode.el ends here |
;;; perl-mode.el ends here |