comparison lisp/progmodes/cperl-mode.el @ 80057:1db7c78912f4

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 05 Feb 2008 14:24:26 +0000
parents a1342e6e097a
children f991f10f15ec
comparison
equal deleted inserted replaced
80056:20a6490b2f90 80057:1db7c78912f4
1248 ["Contract a group" cperl-contract-level 1248 ["Contract a group" cperl-contract-level
1249 cperl-use-syntax-table-text-property] 1249 cperl-use-syntax-table-text-property]
1250 ["Contract groups" cperl-contract-levels 1250 ["Contract groups" cperl-contract-levels
1251 cperl-use-syntax-table-text-property] 1251 cperl-use-syntax-table-text-property]
1252 "----" 1252 "----"
1253 ["Find next interpolated" cperl-next-interpolated-REx 1253 ["Find next interpolated" cperl-next-interpolated-REx
1254 (next-single-property-change (point-min) 'REx-interpolated)] 1254 (next-single-property-change (point-min) 'REx-interpolated)]
1255 ["Find next interpolated (no //o)" 1255 ["Find next interpolated (no //o)"
1256 cperl-next-interpolated-REx-0 1256 cperl-next-interpolated-REx-0
1257 (or (text-property-any (point-min) (point-max) 'REx-interpolated t) 1257 (or (text-property-any (point-min) (point-max) 'REx-interpolated t)
1258 (text-property-any (point-min) (point-max) 'REx-interpolated 1))] 1258 (text-property-any (point-min) (point-max) 'REx-interpolated 1))]
2843 (progn 2843 (progn
2844 (forward-sexp -1) 2844 (forward-sexp -1)
2845 (skip-chars-backward " \t") 2845 (skip-chars-backward " \t")
2846 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:"))) 2846 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:")))
2847 (get-text-property (point) 'first-format-line))) 2847 (get-text-property (point) 'first-format-line)))
2848 2848
2849 ;; Look at previous line that's at column 0 2849 ;; Look at previous line that's at column 0
2850 ;; to determine whether we are in top-level decls 2850 ;; to determine whether we are in top-level decls
2851 ;; or function's arg decls. Set basic-indent accordingly. 2851 ;; or function's arg decls. Set basic-indent accordingly.
2852 ;; Now add a little if this is a continuation line. 2852 ;; Now add a little if this is a continuation line.
2853 (and state 2853 (and state
3077 ;; Indenter for stuff at toplevel 3077 ;; Indenter for stuff at toplevel
3078 ;; 3078 ;;
3079 ((eq 'toplevel (elt i 0)) ;; [toplevel start char-after state immed-after-block] 3079 ((eq 'toplevel (elt i 0)) ;; [toplevel start char-after state immed-after-block]
3080 (+ (save-excursion ; To beg-of-defun, or end of last sexp 3080 (+ (save-excursion ; To beg-of-defun, or end of last sexp
3081 (goto-char (elt i 1)) ; start = Good place to start parsing 3081 (goto-char (elt i 1)) ; start = Good place to start parsing
3082 (- (current-indentation) ; 3082 (- (current-indentation) ;
3083 (if (elt i 4) cperl-indent-level 0))) ; immed-after-block 3083 (if (elt i 4) cperl-indent-level 0))) ; immed-after-block
3084 (if (eq (elt i 2) ?{) cperl-continued-brace-offset 0) ; char-after 3084 (if (eq (elt i 2) ?{) cperl-continued-brace-offset 0) ; char-after
3085 ;; Look at previous line that's at column 0 3085 ;; Look at previous line that's at column 0
3086 ;; to determine whether we are in top-level decls 3086 ;; to determine whether we are in top-level decls
3087 ;; or function's arg decls. Set basic-indent accordingly. 3087 ;; or function's arg decls. Set basic-indent accordingly.
3897 (progn 3897 (progn
3898 (goto-char tb) 3898 (goto-char tb)
3899 ;;; XXX What to do: foo <<bar ??? 3899 ;;; XXX What to do: foo <<bar ???
3900 ;;; XXX Need to support print {a} <<B ??? 3900 ;;; XXX Need to support print {a} <<B ???
3901 (forward-sexp -1) 3901 (forward-sexp -1)
3902 (save-match-data 3902 (save-match-data
3903 ; $foo << b; $f .= <<B; 3903 ; $foo << b; $f .= <<B;
3904 ; ($f+1) << b; a($f) . <<B; 3904 ; ($f+1) << b; a($f) . <<B;
3905 ; foo 1, <<B; $x{a} <<b; 3905 ; foo 1, <<B; $x{a} <<b;
3906 (cond 3906 (cond
3907 ((looking-at "[0-9$({]") 3907 ((looking-at "[0-9$({]")
3929 e1 (match-end 4))) ; 3 + 1 3929 e1 (match-end 4))) ; 3 + 1
3930 (setq tag (buffer-substring b1 e1) 3930 (setq tag (buffer-substring b1 e1)
3931 qtag (regexp-quote tag)) 3931 qtag (regexp-quote tag))
3932 (cond (cperl-pod-here-fontify 3932 (cond (cperl-pod-here-fontify
3933 ;; Highlight the starting delimiter 3933 ;; Highlight the starting delimiter
3934 (cperl-postpone-fontification 3934 (cperl-postpone-fontification
3935 b1 e1 'face my-cperl-delimiters-face) 3935 b1 e1 'face my-cperl-delimiters-face)
3936 (cperl-put-do-not-fontify b1 e1 t))) 3936 (cperl-put-do-not-fontify b1 e1 t)))
3937 (forward-line) 3937 (forward-line)
3938 (setq i (point)) 3938 (setq i (point))
3939 (if end-of-here-doc 3939 (if end-of-here-doc
4289 ;;;m?(\?\?{b,a})? + m/(??{aa})(?(?=xx)aa|bb)(?#aac)/; 4289 ;;;m?(\?\?{b,a})? + m/(??{aa})(?(?=xx)aa|bb)(?#aac)/;
4290 ;;;m$(^ab[c]\$)$ + m+(^ab[c]\$\+)+ + m](^ab[c\]$|.+)] + m)(^ab[c]$|.+\)); 4290 ;;;m$(^ab[c]\$)$ + m+(^ab[c]\$\+)+ + m](^ab[c\]$|.+)] + m)(^ab[c]$|.+\));
4291 ;;;m^a[\^b]c^ + m.a[^b]\.c.; 4291 ;;;m^a[\^b]c^ + m.a[^b]\.c.;
4292 (save-excursion 4292 (save-excursion
4293 (goto-char (1+ b)) 4293 (goto-char (1+ b))
4294 ;; First 4294 ;; First
4295 (cperl-look-at-leading-count is-x-REx e) 4295 (cperl-look-at-leading-count is-x-REx e)
4296 (setq hairy-RE 4296 (setq hairy-RE
4297 (concat 4297 (concat
4298 (if is-x-REx 4298 (if is-x-REx
4299 (if (eq (char-after b) ?\#) 4299 (if (eq (char-after b) ?\#)
4450 ;; Test for arguments: 4450 ;; Test for arguments:
4451 (cond 4451 (cond
4452 ;; This is not pretty: the 5.8.7 logic: 4452 ;; This is not pretty: the 5.8.7 logic:
4453 ;; \0numx -> octal (up to total 3 dig) 4453 ;; \0numx -> octal (up to total 3 dig)
4454 ;; \DIGIT -> backref unless \0 4454 ;; \DIGIT -> backref unless \0
4455 ;; \DIGITs -> backref if legal 4455 ;; \DIGITs -> backref if valid
4456 ;; otherwise up to 3 -> octal 4456 ;; otherwise up to 3 -> octal
4457 ;; Do not try to distinguish, we guess 4457 ;; Do not try to distinguish, we guess
4458 ((or (and (memq qtag (append "01234567" nil)) 4458 ((or (and (memq qtag (append "01234567" nil))
4459 (re-search-forward 4459 (re-search-forward
4460 "\\=[01234567]?[01234567]?" 4460 "\\=[01234567]?[01234567]?"
4461 (1- e) 'to-end)) 4461 (1- e) 'to-end))
4462 (and (memq qtag (append "89" nil)) 4462 (and (memq qtag (append "89" nil))
4463 (re-search-forward 4463 (re-search-forward
4464 "\\=[0123456789]*" (1- e) 'to-end)) 4464 "\\=[0123456789]*" (1- e) 'to-end))
4465 (and (eq qtag ?x) 4465 (and (eq qtag ?x)
4466 (re-search-forward 4466 (re-search-forward
4467 "\\=[0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}" 4467 "\\=[0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}"
4468 (1- e) 'to-end)) 4468 (1- e) 'to-end))
4496 (forward-char 1))) 4496 (forward-char 1)))
4497 ;; Apparently, I can't put \] into a charclass 4497 ;; Apparently, I can't put \] into a charclass
4498 ;; in m]]: m][\\\]\]] produces [\\]] 4498 ;; in m]]: m][\\\]\]] produces [\\]]
4499 ;;; POSIX? [:word:] [:^word:] only inside [] 4499 ;;; POSIX? [:word:] [:^word:] only inside []
4500 ;;; "\\=\\(\\\\.\\|[^][\\\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]") 4500 ;;; "\\=\\(\\\\.\\|[^][\\\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]")
4501 (while 4501 (while
4502 (and argument 4502 (and argument
4503 (re-search-forward 4503 (re-search-forward
4504 (if (eq (char-after b) ?\] ) 4504 (if (eq (char-after b) ?\] )
4505 "\\=\\(\\\\[^]]\\|[^]\\\\]\\)*\\\\]" 4505 "\\=\\(\\\\[^]]\\|[^]\\\\]\\)*\\\\]"
4506 "\\=\\(\\\\.\\|[^]\\\\]\\)*]") 4506 "\\=\\(\\\\.\\|[^]\\\\]\\)*]")
5813 (,(concat "\\=" 5813 (,(concat "\\="
5814 cperl-maybe-white-and-comment-rex 5814 cperl-maybe-white-and-comment-rex
5815 "," 5815 ","
5816 cperl-maybe-white-and-comment-rex 5816 cperl-maybe-white-and-comment-rex
5817 "\\([$@%*]\\([a-zA-Z0-9_:]+\\|[^a-zA-Z0-9_]\\)\\)") 5817 "\\([$@%*]\\([a-zA-Z0-9_:]+\\|[^a-zA-Z0-9_]\\)\\)")
5818 ;; Bug in font-lock: limit is used not only to limit 5818 ;; Bug in font-lock: limit is used not only to limit
5819 ;; searches, but to set the "extend window for 5819 ;; searches, but to set the "extend window for
5820 ;; facification" property. Thus we need to minimize. 5820 ;; facification" property. Thus we need to minimize.
5821 ,(if cperl-font-lock-multiline 5821 ,(if cperl-font-lock-multiline
5822 '(if (match-beginning 3) 5822 '(if (match-beginning 3)
5823 (save-excursion 5823 (save-excursion
6782 for correct operation it should start and end outside any special syntactic 6782 for correct operation it should start and end outside any special syntactic
6783 construct. DONE-TO and STATEPOS indicate changes to internal caches maintained 6783 construct. DONE-TO and STATEPOS indicate changes to internal caches maintained
6784 by CPerl." 6784 by CPerl."
6785 (interactive "P") 6785 (interactive "P")
6786 (or arg 6786 (or arg
6787 (setq arg (if (eq cperl-syntaxify-by-font-lock 6787 (setq arg (if (eq cperl-syntaxify-by-font-lock
6788 (if backtrace 'backtrace 'message)) 0 1))) 6788 (if backtrace 'backtrace 'message)) 0 1)))
6789 (setq arg (if (> arg 0) (if backtrace 'backtrace 'message) t)) 6789 (setq arg (if (> arg 0) (if backtrace 'backtrace 'message) t))
6790 (setq cperl-syntaxify-by-font-lock arg) 6790 (setq cperl-syntaxify-by-font-lock arg)
6791 (message "Debugging messages of syntax unwind %sabled." 6791 (message "Debugging messages of syntax unwind %sabled."
6792 (if (eq arg t) "dis" "en"))) 6792 (if (eq arg t) "dis" "en")))
8243 (cperl-beautify-regexp-piece b e nil deep)))) 8243 (cperl-beautify-regexp-piece b e nil deep))))
8244 8244
8245 (defun cperl-invert-if-unless-modifiers () 8245 (defun cperl-invert-if-unless-modifiers ()
8246 "Change `B if A;' into `if (A) {B}' etc if possible. 8246 "Change `B if A;' into `if (A) {B}' etc if possible.
8247 \(Unfinished.)" 8247 \(Unfinished.)"
8248 (interactive) ; 8248 (interactive) ;
8249 (let (A B pre-B post-B pre-if post-if pre-A post-A if-string 8249 (let (A B pre-B post-B pre-if post-if pre-A post-A if-string
8250 (w-rex "\\<\\(if\\|unless\\|while\\|until\\|for\\|foreach\\)\\>")) 8250 (w-rex "\\<\\(if\\|unless\\|while\\|until\\|for\\|foreach\\)\\>"))
8251 (and (= (char-syntax (preceding-char)) ?w) 8251 (and (= (char-syntax (preceding-char)) ?w)
8252 (forward-sexp -1)) 8252 (forward-sexp -1))
8253 (setq pre-if (point)) 8253 (setq pre-if (point))