Mercurial > emacs
comparison lisp/progmodes/cperl-mode.el @ 65229:b61a0ad9cf07
(cperl-electric-lbrace, cperl-electric-keyword, cperl-electric-pod,
cperl-electric-backspace, cperl-forward-re, cperl-fix-line-spacing,
cperl-fill-paragraph): "?\ " -> "?\s".
(vc-rcs-header, vc-sccs-header): Add defvars.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 30 Aug 2005 10:46:43 +0000 |
parents | 629afbe74e61 |
children | a11fdee52c05 a3716f7538f2 |
comparison
equal
deleted
inserted
replaced
65228:d88a79e06702 | 65229:b61a0ad9cf07 |
---|---|
65 ;; \$` \$' \$" | 65 ;; \$` \$' \$" |
66 ;; $opt::s $opt_s $opt{s} (s => ...) /\s+.../ | 66 ;; $opt::s $opt_s $opt{s} (s => ...) /\s+.../ |
67 ;; likewise with m, tr, y, q, qX instead of s | 67 ;; likewise with m, tr, y, q, qX instead of s |
68 | 68 |
69 ;;; Code: | 69 ;;; Code: |
70 | |
71 (defvar vc-rcs-header) | |
72 (defvar vc-sccs-header) | |
70 | 73 |
71 ;; Some macros are needed for `defcustom' | 74 ;; Some macros are needed for `defcustom' |
72 (eval-when-compile | 75 (eval-when-compile |
73 (condition-case nil | 76 (condition-case nil |
74 (require 'man) | 77 (require 'man) |
1773 (and (cperl-val 'cperl-electric-lbrace-space) | 1776 (and (cperl-val 'cperl-electric-lbrace-space) |
1774 (eq (preceding-char) ?$) | 1777 (eq (preceding-char) ?$) |
1775 (save-excursion | 1778 (save-excursion |
1776 (skip-chars-backward "$") | 1779 (skip-chars-backward "$") |
1777 (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)")) | 1780 (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)")) |
1778 (insert ?\ )) | 1781 (insert ?\s)) |
1779 ;; Check whether we are in comment | 1782 ;; Check whether we are in comment |
1780 (if (and | 1783 (if (and |
1781 (save-excursion | 1784 (save-excursion |
1782 (beginning-of-line) | 1785 (beginning-of-line) |
1783 (not (looking-at "[ \t]*#"))) | 1786 (not (looking-at "[ \t]*#"))) |
1869 Help message may be switched off by setting `cperl-message-electric-keyword' | 1872 Help message may be switched off by setting `cperl-message-electric-keyword' |
1870 to nil." | 1873 to nil." |
1871 (let ((beg (save-excursion (beginning-of-line) (point))) | 1874 (let ((beg (save-excursion (beginning-of-line) (point))) |
1872 (dollar (and (eq last-command-char ?$) | 1875 (dollar (and (eq last-command-char ?$) |
1873 (eq this-command 'self-insert-command))) | 1876 (eq this-command 'self-insert-command))) |
1874 (delete (and (memq last-command-char '(?\ ?\n ?\t ?\f)) | 1877 (delete (and (memq last-command-char '(?\s ?\n ?\t ?\f)) |
1875 (memq this-command '(self-insert-command newline)))) | 1878 (memq this-command '(self-insert-command newline)))) |
1876 my do) | 1879 my do) |
1877 (and (save-excursion | 1880 (and (save-excursion |
1878 (condition-case nil | 1881 (condition-case nil |
1879 (progn | 1882 (progn |
1944 (cperl-ensure-newlines (1- n) pos) | 1947 (cperl-ensure-newlines (1- n) pos) |
1945 (goto-char pos))) | 1948 (goto-char pos))) |
1946 | 1949 |
1947 (defun cperl-electric-pod () | 1950 (defun cperl-electric-pod () |
1948 "Insert a POD chunk appropriate after a =POD directive." | 1951 "Insert a POD chunk appropriate after a =POD directive." |
1949 (let ((delete (and (memq last-command-char '(?\ ?\n ?\t ?\f)) | 1952 (let ((delete (and (memq last-command-char '(?\s ?\n ?\t ?\f)) |
1950 (memq this-command '(self-insert-command newline)))) | 1953 (memq this-command '(self-insert-command newline)))) |
1951 head1 notlast name p really-delete over) | 1954 head1 notlast name p really-delete over) |
1952 (and (save-excursion | 1955 (and (save-excursion |
1953 (forward-word -1) | 1956 (forward-word -1) |
1954 (and | 1957 (and |
2222 (interactive "p") | 2225 (interactive "p") |
2223 (if (and cperl-auto-newline | 2226 (if (and cperl-auto-newline |
2224 (memq last-command '(cperl-electric-semi | 2227 (memq last-command '(cperl-electric-semi |
2225 cperl-electric-terminator | 2228 cperl-electric-terminator |
2226 cperl-electric-lbrace)) | 2229 cperl-electric-lbrace)) |
2227 (memq (preceding-char) '(?\ ?\t ?\n))) | 2230 (memq (preceding-char) '(?\s ?\t ?\n))) |
2228 (let (p) | 2231 (let (p) |
2229 (if (eq last-command 'cperl-electric-lbrace) | 2232 (if (eq last-command 'cperl-electric-lbrace) |
2230 (skip-chars-forward " \t\n")) | 2233 (skip-chars-forward " \t\n")) |
2231 (setq p (point)) | 2234 (setq p (point)) |
2232 (skip-chars-backward " \t\n") | 2235 (skip-chars-backward " \t\n") |
2234 (and (eq last-command 'cperl-electric-else) | 2237 (and (eq last-command 'cperl-electric-else) |
2235 ;; We are removing the whitespace *inside* cperl-electric-else | 2238 ;; We are removing the whitespace *inside* cperl-electric-else |
2236 (setq this-command 'cperl-electric-else-really)) | 2239 (setq this-command 'cperl-electric-else-really)) |
2237 (if (and cperl-auto-newline | 2240 (if (and cperl-auto-newline |
2238 (eq last-command 'cperl-electric-else-really) | 2241 (eq last-command 'cperl-electric-else-really) |
2239 (memq (preceding-char) '(?\ ?\t ?\n))) | 2242 (memq (preceding-char) '(?\s ?\t ?\n))) |
2240 (let (p) | 2243 (let (p) |
2241 (skip-chars-forward " \t\n") | 2244 (skip-chars-forward " \t\n") |
2242 (setq p (point)) | 2245 (setq p (point)) |
2243 (skip-chars-backward " \t\n") | 2246 (skip-chars-backward " \t\n") |
2244 (delete-region (point) p)) | 2247 (delete-region (point) p)) |
3037 (setq is-2arg nil go-forward t))) ; Ignore the tail | 3040 (setq is-2arg nil go-forward t))) ; Ignore the tail |
3038 (if is-2arg ; Not number => have second part | 3041 (if is-2arg ; Not number => have second part |
3039 (progn | 3042 (progn |
3040 (setq i (point) i2 i) | 3043 (setq i (point) i2 i) |
3041 (if ender | 3044 (if ender |
3042 (if (memq (following-char) '(?\ ?\t ?\n ?\f)) | 3045 (if (memq (following-char) '(?\s ?\t ?\n ?\f)) |
3043 (progn | 3046 (progn |
3044 (if (looking-at "[ \t\n\f]+\\(#[^\n]*\n[ \t\n\f]*\\)+") | 3047 (if (looking-at "[ \t\n\f]+\\(#[^\n]*\n[ \t\n\f]*\\)+") |
3045 (goto-char (match-end 0)) | 3048 (goto-char (match-end 0)) |
3046 (skip-chars-forward " \t\n\f")) | 3049 (skip-chars-forward " \t\n\f")) |
3047 (setq i2 (point)))) | 3050 (setq i2 (point)))) |
4029 (progn | 4032 (progn |
4030 (search-forward "}") | 4033 (search-forward "}") |
4031 (setq p (point)) | 4034 (setq p (point)) |
4032 (skip-chars-forward " \t\n") | 4035 (skip-chars-forward " \t\n") |
4033 (delete-region p (point)) | 4036 (delete-region p (point)) |
4034 (insert (make-string cperl-indent-region-fix-constructs ?\ )) | 4037 (insert (make-string cperl-indent-region-fix-constructs ?\s)) |
4035 (beginning-of-line))) | 4038 (beginning-of-line))) |
4036 ;; Looking at: | 4039 ;; Looking at: |
4037 ;; } else | 4040 ;; } else |
4038 (if (looking-at "[ \t]*}\\(\t*\\|[ \t][ \t]+\\)\\<\\(els\\(e\\|if\\)\\|continue\\)\\>") | 4041 (if (looking-at "[ \t]*}\\(\t*\\|[ \t][ \t]+\\)\\<\\(els\\(e\\|if\\)\\|continue\\)\\>") |
4039 (progn | 4042 (progn |
4040 (search-forward "}") | 4043 (search-forward "}") |
4041 (delete-horizontal-space) | 4044 (delete-horizontal-space) |
4042 (insert (make-string cperl-indent-region-fix-constructs ?\ )) | 4045 (insert (make-string cperl-indent-region-fix-constructs ?\s)) |
4043 (beginning-of-line))) | 4046 (beginning-of-line))) |
4044 ;; Looking at: | 4047 ;; Looking at: |
4045 ;; else { | 4048 ;; else { |
4046 (if (looking-at | 4049 (if (looking-at |
4047 "[ \t]*}?[ \t]*\\<\\(\\els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]") | 4050 "[ \t]*}?[ \t]*\\<\\(\\els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]") |
4048 (progn | 4051 (progn |
4049 (forward-word 1) | 4052 (forward-word 1) |
4050 (delete-horizontal-space) | 4053 (delete-horizontal-space) |
4051 (insert (make-string cperl-indent-region-fix-constructs ?\ )) | 4054 (insert (make-string cperl-indent-region-fix-constructs ?\s)) |
4052 (beginning-of-line))) | 4055 (beginning-of-line))) |
4053 ;; Looking at: | 4056 ;; Looking at: |
4054 ;; foreach my $var | 4057 ;; foreach my $var |
4055 (if (looking-at | 4058 (if (looking-at |
4056 "[ \t]*\\<for\\(each\\)?[ \t]+\\(my\\|local\\|our\\)\\(\t*\\|[ \t][ \t]+\\)[^ \t\n]") | 4059 "[ \t]*\\<for\\(each\\)?[ \t]+\\(my\\|local\\|our\\)\\(\t*\\|[ \t][ \t]+\\)[^ \t\n]") |
4057 (progn | 4060 (progn |
4058 (forward-word 2) | 4061 (forward-word 2) |
4059 (delete-horizontal-space) | 4062 (delete-horizontal-space) |
4060 (insert (make-string cperl-indent-region-fix-constructs ?\ )) | 4063 (insert (make-string cperl-indent-region-fix-constructs ?\s)) |
4061 (beginning-of-line))) | 4064 (beginning-of-line))) |
4062 ;; Looking at: | 4065 ;; Looking at: |
4063 ;; foreach my $var ( | 4066 ;; foreach my $var ( |
4064 (if (looking-at | 4067 (if (looking-at |
4065 "[ \t]*\\<for\\(each\\)?[ \t]+\\(my\\|local\\|our\\)[ \t]*\\$[_a-zA-Z0-9]+\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]") | 4068 "[ \t]*\\<for\\(each\\)?[ \t]+\\(my\\|local\\|our\\)[ \t]*\\$[_a-zA-Z0-9]+\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]") |
4066 (progn | 4069 (progn |
4067 (forward-sexp 3) | 4070 (forward-sexp 3) |
4068 (delete-horizontal-space) | 4071 (delete-horizontal-space) |
4069 (insert | 4072 (insert |
4070 (make-string cperl-indent-region-fix-constructs ?\ )) | 4073 (make-string cperl-indent-region-fix-constructs ?\s)) |
4071 (beginning-of-line))) | 4074 (beginning-of-line))) |
4072 ;; Looking at: | 4075 ;; Looking at: |
4073 ;; } foreach my $var () { | 4076 ;; } foreach my $var () { |
4074 (if (looking-at | 4077 (if (looking-at |
4075 "[ \t]*\\(}[ \t]*\\)?\\<\\(\\els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([ \t]+\\(my\\|local\\|our\\)\\)?[ \t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{") | 4078 "[ \t]*\\(}[ \t]*\\)?\\<\\(\\els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([ \t]+\\(my\\|local\\|our\\)\\)?[ \t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{") |
4109 (if (cperl-indent-line parse-data) | 4112 (if (cperl-indent-line parse-data) |
4110 (progn | 4113 (progn |
4111 (cperl-fix-line-spacing end parse-data) | 4114 (cperl-fix-line-spacing end parse-data) |
4112 (setq ret (point))))) | 4115 (setq ret (point))))) |
4113 (insert | 4116 (insert |
4114 (make-string cperl-indent-region-fix-constructs ?\ )))) | 4117 (make-string cperl-indent-region-fix-constructs ?\s)))) |
4115 ((and (looking-at "[ \t]*\n") | 4118 ((and (looking-at "[ \t]*\n") |
4116 (not (if ml | 4119 (not (if ml |
4117 cperl-extra-newline-before-brace-multiline | 4120 cperl-extra-newline-before-brace-multiline |
4118 cperl-extra-newline-before-brace))) | 4121 cperl-extra-newline-before-brace))) |
4119 (setq pp (point)) | 4122 (setq pp (point)) |
4120 (skip-chars-forward " \t\n") | 4123 (skip-chars-forward " \t\n") |
4121 (delete-region pp (point)) | 4124 (delete-region pp (point)) |
4122 (insert | 4125 (insert |
4123 (make-string cperl-indent-region-fix-constructs ?\ )))) | 4126 (make-string cperl-indent-region-fix-constructs ?\s)))) |
4124 ;; Now we are before `{' | 4127 ;; Now we are before `{' |
4125 (if (looking-at "[ \t\n]*{[ \t]*[^ \t\n#]") | 4128 (if (looking-at "[ \t\n]*{[ \t]*[^ \t\n#]") |
4126 (progn | 4129 (progn |
4127 (skip-chars-forward " \t\n") | 4130 (skip-chars-forward " \t\n") |
4128 (setq pp (point)) | 4131 (setq pp (point)) |
4295 ((cperl-to-comment-or-eol) | 4298 ((cperl-to-comment-or-eol) |
4296 (setq has-comment t) | 4299 (setq has-comment t) |
4297 (looking-at "#+[ \t]*") | 4300 (looking-at "#+[ \t]*") |
4298 (setq start (point) c (current-column) | 4301 (setq start (point) c (current-column) |
4299 comment-fill-prefix | 4302 comment-fill-prefix |
4300 (concat (make-string (current-column) ?\ ) | 4303 (concat (make-string (current-column) ?\s) |
4301 (buffer-substring (match-beginning 0) (match-end 0))) | 4304 (buffer-substring (match-beginning 0) (match-end 0))) |
4302 spaces (progn (skip-chars-backward " \t") | 4305 spaces (progn (skip-chars-backward " \t") |
4303 (buffer-substring (point) start)) | 4306 (buffer-substring (point) start)) |
4304 dc (- c (current-column)) len (- start (point)) | 4307 dc (- c (current-column)) len (- start (point)) |
4305 start (point-marker)) | 4308 start (point-marker)) |
5447 (while | 5450 (while |
5448 (progn | 5451 (progn |
5449 (setq e (point)) | 5452 (setq e (point)) |
5450 (skip-chars-backward " \t") | 5453 (skip-chars-backward " \t") |
5451 (delete-region (point) e) | 5454 (delete-region (point) e) |
5452 (indent-to-column col) ;(make-string (- col (current-column)) ?\ )) | 5455 (indent-to-column col) ;(make-string (- col (current-column)) ?\s)) |
5453 (beginning-of-line 2) | 5456 (beginning-of-line 2) |
5454 (and (< (point) end) | 5457 (and (< (point) end) |
5455 (re-search-forward search end t) | 5458 (re-search-forward search end t) |
5456 (goto-char (match-beginning 0)))))))) ; No body | 5459 (goto-char (match-beginning 0)))))))) ; No body |
5457 | 5460 |