annotate lisp/modes/cperl-mode.el @ 44:8d2a9b52c682 r19-15prefinal

Import from CVS: tag r19-15prefinal
author cvs
date Mon, 13 Aug 2007 08:55:10 +0200
parents e04119814345
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; This code started from the following message of long time ago (IZ):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; From: olson@mcs.anl.gov (Bob Olson)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Newsgroups: comp.lang.perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; Subject: cperl-mode: Another perl mode for Gnuemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Date: 14 Aug 91 15:20:01 GMT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Perl code editing commands for Emacs
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
9 ;; Copyright (C) 1985-1996 Bob Olson, Ilya Zakharevich
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
10
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
11 ;; This file is not (yet) part of GNU Emacs. It may be distributed
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
12 ;; either under the same terms as GNU Emacs, or under the same terms
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
13 ;; as Perl. You should have received a copy of Perl Artistic license
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
14 ;; along with the Perl distribution.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
29 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
30
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Corrections made by Ilya Zakharevich ilya@math.mps.ohio-state.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; XEmacs changes by Peter Arius arius@informatik.uni-erlangen.de
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
35 ;; $Id: cperl-mode.el,v 1.4 1997/03/16 05:55:19 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; To use this mode put the following into your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; (autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; You can either fine-tune the bells and whistles of this mode or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; bulk enable them by putting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; (setq cperl-hairy t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; in your .emacs file. (Emacs rulers do not consider it politically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; correct to make whistles enabled by default.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
49 ;;; DO NOT FORGET to read micro-docs. (available from `Perl' menu). <<<<<<
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
50 ;;; or as help on variables `cperl-tips', `cperl-problems', <<<<<<
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
51 ;;; `cperl-non-problems'. <<<<<<
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
52
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; Additional useful commands to put into your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; (append '(("\\.[pP][Llm]$" . perl-mode)) auto-mode-alist ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; (setq interpreter-mode-alist (append interpreter-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; '(("miniperl" . perl-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; The mode information (on C-h m) provides customization help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; If you use font-lock feature of this mode, it is advisable to use
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
62 ;;; either lazy-lock-mode or fast-lock-mode (available on ELisp
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; archive in files lazy-lock.el and fast-lock.el). I prefer lazy-lock.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; Faces used now: three faces for first-class and second-class keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; and control flow words, one for each: comments, string, labels,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; functions definitions and packages, arrays, hashes, and variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; definitions. If you do not see all these faces, your font-lock does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; not define them, so you need to define them manually. Maybe you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; an obsolete font-lock from 19.28 or earlier. Upgrade.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
72 ;;; If you have a grayscale monitor, and do not have the variable
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; font-lock-display-type bound to 'grayscale, insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; (setq font-lock-display-type 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
77 ;;; into your .emacs file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;;; This mode supports font-lock, imenu and mode-compile. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;;; hairy version font-lock is on, but you should activate imenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;;; yourself (note that mode-compile is not standard yet). Well, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;;; can use imenu from keyboard anyway (M-x imenu), but it is better
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;;; to bind it like that:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; (define-key global-map [M-S-down-mouse-3] 'imenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; In fact the version of font-lock that this version supports can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; much newer than the version you actually have. This means that a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; lot of faces can be set up, but are not visible on your screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; since the coloring rules for this faces are not defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; Updates: ========================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; Made less hairy by default: parentheses not electric,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; linefeed not magic. Bug with abbrev-mode corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;;; After 1.4:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; Better indentation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; subs inside braces should work now,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; Toplevel braces obey customization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; indent-for-comment knows about bad cases, cperl-indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; moves cursor to a correct place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; cperl-indent-exp written from the scratch! Slow... (quadratic!) :-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; (50 secs on DB::DB (sub of 430 lines), 486/66)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; Minor documentation fixes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; Imenu understands packages as prefixes (including nested).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; Hairy options can be switched off one-by-one by setting to null.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; Names of functions and variables changed to conform to `cperl-' style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;;; After 1.5:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; Some bugs with indentation of labels (and embedded subs) corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; `cperl-indent-region' done (slow :-()).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; `cperl-fill-paragraph' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; Better package support for `imenu'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; Progress indicator for indentation (with `imenu' loaded).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; `Cperl-set' was busted, now setting the individual hairy option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; should be better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;;; After 1.6:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;; `cperl-set-style' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; `cperl-check-syntax' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; Menu done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; New config variables `cperl-close-paren-offset' and `cperl-comment-column'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; Bugs with `cperl-auto-newline' corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;; `cperl-electric-lbrace' can work with `cperl-auto-newline' in situation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; like $hash{.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;;; 1.7 XEmacs (arius@informatik.uni-erlangen.de):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; - use `next-command-event', if `next-command-events' does not exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; - use `find-face' as def. of `is-face'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; - corrected def. of `x-color-defined-p'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; - added const defs for font-lock-comment-face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; font-lock-keyword-face and font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; - added def. of font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; - added (require 'easymenu) inside an `eval-when-compile'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; - replaced 4-argument `substitute-key-definition' with ordinary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;; `define-key's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; - replaced `mark-active' in menu definition by `cperl-use-region-p'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; Todo (at least):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; - use emacs-vers.el (http://www.cs.utah.edu/~eeide/emacs/emacs-vers.el.gz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;; for portable code?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; - should `cperl-mode' do a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; (if (featurep 'easymenu) (easy-menu-add cperl-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;; or should this be left to the user's `cperl-mode-hook'?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; Some bugs introduced by the above fix corrected (IZ ;-).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;; Some bugs under XEmacs introduced by the correction corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; Some more can remain since there are two many different variants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;; Please feedback!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;; We do not support fontification of arrays and hashes under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; obsolete font-lock any more. Upgrade.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;;; after 1.8 Minor bug with parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;;; after 1.9 Improvements from Joe Marzot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;;; after 1.10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; Does not need easymenu to compile under XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; `vc-insert-headers' should work better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;; Should work with 19.29 and 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; Small improvements to fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;; Expansion of keywords does not depend on C-? being backspace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; after 1.10+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;; 19.29 and 19.12 supported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;; `cperl-font-lock-enhanced' deprecated. Use font-lock-extra.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; Support for font-lock-extra.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;; After 1.11:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; Tools submenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; Support for perl5-info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; `imenu-go-find-at-position' in Tools requires imenu-go.el (see hints above)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; Imenu entries do not work with stock imenu.el. Patch sent to maintainers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; Fontifies `require a if b;', __DATA__.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; Arglist for auto-fill-mode was incorrect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;;; After 1.12:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; `cperl-lineup-step' and `cperl-lineup' added: lineup constructions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;; vertically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; `cperl-do-auto-fill' updated for 19.29 style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; `cperl-info-on-command' now has a default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; Workaround for broken C-h on XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; VC strings escaped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; C-h f now may prompt for function name instead of going on,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; controlled by `cperl-info-on-command-no-prompt'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;;; After 1.13:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;; Msb buffer list includes perl files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; Indent-for-comment uses indent-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; Can write tag files using etags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;;; After 1.14:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;; Recognizes (tries to ;-) {...} which are not blocks during indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; `cperl-close-paren-offset' affects ?\] too (and ?\} if not block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;; Bug with auto-filling comments started with "##" corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;; Very slow now: on DB::DB 0.91, 486/66:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;Function Name Call Count Elapsed Time Average Time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;;======================================== ========== ============ ============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;cperl-block-p 469 3.7799999999 0.0080597014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;;cperl-get-state 505 163.39000000 0.3235445544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;;cperl-comment-indent 12 0.0299999999 0.0024999999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;cperl-backward-to-noncomment 939 4.4599999999 0.0047497337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;;cperl-calculate-indent 505 172.22000000 0.3410297029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;;cperl-indent-line 505 172.88000000 0.3423366336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;;cperl-use-region-p 40 0.0299999999 0.0007499999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;;cperl-indent-exp 1 177.97000000 177.97000000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;cperl-to-comment-or-eol 1453 3.9800000000 0.0027391603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;;cperl-backward-to-start-of-continued-exp 9 0.0300000000 0.0033333333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;;cperl-indent-region 1 177.94000000 177.94000000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;;; After 1.15:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; Takes into account white space after opening parentheses during indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;; May highlight pods and here-documents: see `cperl-pod-here-scan',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;; `cperl-pod-here-fontify', `cperl-pod-face'. Does not use this info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;; for indentation so far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;; Fontification updated to 19.30 style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;; The change 19.29->30 did not add all the required functionality,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; but broke "font-lock-extra.el". Get "choose-color.el" from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;; ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;;; After 1.16:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;; else # comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;; recognized as a start of a block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;; Two different font-lock-levels provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; `cperl-pod-head-face' introduced. Used for highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; `imenu' marks pods, +Packages moved to the head.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;;; After 1.17:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; Scan for pods highlights here-docs too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; Note that the tag of here-doc may be rehighlighted later by lazy-lock.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;; Only one here-doc-tag per line is supported, and one in comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; or a string may break fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;; POD headers were supposed to fill one line only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;;; After 1.18:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; `font-lock-keywords' were set in 19.30 style _always_. Current scheme
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;; may break under XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;; `cperl-calculate-indent' dis suppose that `parse-start' was defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;; `fontified' tag is added to fontified text as well as `lazy-lock' (for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; compatibility with older lazy-lock.el) (older one overfontifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;; something nevertheless :-().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;; Will not indent something inside pod and here-documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; Fontifies the package name after import/no/bootstrap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; Added new entry to menu with meta-info about the mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;;; After 1.19:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;;; Prefontification works much better with 19.29. Should be checked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;;; with 19.30 as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;; Some misprints in docs corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;; Now $a{-text} and -text => "blah" are fontified as strings too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;; Now the pod search is much stricter, so it can help you to find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;; pod sections which are broken because of whitespace before =blah
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; - just observe the fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;;; After 1.20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;; Anonymous subs are indented with respect to the level of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; indentation of `sub' now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;; {} is recognized as hash after `bless' and `return'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;; Anonymous subs are split by `cperl-linefeed' as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;;; Electric parens embrace a region if present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;; To make `cperl-auto-newline' useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;; `cperl-auto-newline-after-colon' is introduced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;; `cperl-electric-parens' is now t or nul. The old meaning is moved to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;; `cperl-electric-parens-string'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;; `cperl-toggle-auto-newline' introduced, put on C-c C-a.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;; `cperl-toggle-abbrev' introduced, put on C-c C-k.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;; `cperl-toggle-electric' introduced, put on C-c C-e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;; Beginning-of-defun-regexp was not anchored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;;; After 1.21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;;; Auto-newline grants `cperl-extra-newline-before-brace' if "{" is typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;; after ")".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;; {} is recognized as expression after `tr' and friends.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
276
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
277 ;;;; After 1.22
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
278 ;;; Entry Hierarchy added to imenu. Very primitive so far.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
279 ;;; One needs newer `imenu-go'.el. A patch to `imenu' is needed as well.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
280 ;;; Writes its own TAGS files.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
281 ;;; Class viewer based on TAGS files. Does not trace @ISA so far.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
282 ;;; 19.31: Problems with scan for PODs corrected.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
283 ;;; First POD header correctly fontified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
284 ;;; I needed (setq imenu-use-keymap-menu t) to get good imenu in 19.31.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
285 ;;; Apparently it makes a lot of hierarchy code obsolete...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
286
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
287 ;;;; After 1.23
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
288 ;;; Tags filler now scans *.xs as well.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
289 ;;; The info from *.xs scan is used by the hierarchy viewer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
290 ;;; Hierarchy viewer documented.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
291 ;;; Bug in 19.31 imenu documented.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
292
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
293 ;;;; After 1.24
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
294 ;;; New location for info-files mentioned,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
295 ;;; Electric-; should work better.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
296 ;;; Minor bugs with POD marking.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
297
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
298 ;;;; After 1.25 (probably not...)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
299 ;;; `cperl-info-page' introduced.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
300 ;;; To make `uncomment-region' working, `comment-region' would
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
301 ;;; not insert extra space.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
302 ;;; Here documents delimiters better recognized
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
303 ;;; (empty one, and non-alphanums in quotes handled). May be wrong with 1<<14?
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
304 ;;; `cperl-db' added, used in menu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
305 ;;; imenu scan removes text-properties, for better debugging
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
306 ;;; - but the bug is in 19.31 imenu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
307 ;;; formats highlighted by font-lock and prescan, embedded comments
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
308 ;;; are not treated.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
309 ;;; POD/friends scan merged in one pass.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
310 ;;; Syntax class is not used for analyzing the code, only char-syntax
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
311 ;;; may be checked against _ or'ed with w.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
312 ;;; Syntax class of `:' changed to be _.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
313 ;;; `cperl-find-bad-style' added.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
314
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
315 ;;;; After 1.25
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
316 ;;; When search for here-documents, we ignore commented << in simplest cases.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
317 ;;; `cperl-get-help' added, available on C-h v and from menu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
318 ;;; Auto-help added. Default with `cperl-hairy', switchable on/off
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
319 ;;; with startup variable `cperl-lazy-help-time' and from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
320 ;;; menu. Requires `run-with-idle-timer'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
321 ;;; Highlighting of @abc{@efg} was wrong - interchanged two regexps.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
322
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
323 ;;;; After 1.27
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
324 ;;; Indentation: At toplevel after a label - fixed.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
325 ;;; 1.27 was put to archives in binary mode ===> DOSish :-(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
326
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
327 ;;;; After 1.28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
328 ;;; Thanks to Martin Buchholz <mrb@Eng.Sun.COM>: misprints in
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
329 ;;; comments and docstrings corrected, XEmacs support cleaned up.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
330 ;;; The closing parenths would enclose the region into matching
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
331 ;;; parens under the same conditions as the opening ones.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
332 ;;; Minor updates to `cperl-short-docs'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
333 ;;; Will not consider <<= as start of here-doc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
335 ;;;; After 1.29
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
336 ;;; Added an extra advice to look into Micro-docs. ;-).
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
337 ;;; Enclosing of region when you press a closing parenth is regulated by
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
338 ;;; `cperl-electric-parens-string'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
339 ;;; Minor updates to `cperl-short-docs'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
340 ;;; `initialize-new-tags-table' called only if present (Does this help
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
341 ;;; with generation of tags under XEmacs?).
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
342 ;;; When creating/updating tag files, new info is written at the old place,
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
343 ;;; or at the end (is this a wanted behaviour? I need this in perl build directory).
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
344
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
345 ;;;; After 1.30
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
346 ;;; All the keywords from keywords.pl included (maybe with dummy explanation).
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
347 ;;; No auto-help inside strings, comment, here-docs, formats, and pods.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
348 ;;; Shrinkwrapping of info, regulated by `cperl-max-help-size'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
349 ;;; Info on variables as well.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
350 ;;; Recognision of HERE-DOCS improved yet more.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
351 ;;; Autonewline works on `}' without warnings.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
352 ;;; Autohelp works again on $_[0].
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
353
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
354 ;;;; After 1.31
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
355 ;;; perl-descr.el found its author - hi, Johan!
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
356
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defvar cperl-extra-newline-before-brace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "*Non-nil means that if, elsif, while, until, else, for, foreach
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 and do constructs look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 instead of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 if () {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (defvar cperl-indent-level 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "*Indentation of CPerl statements with respect to containing block.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defvar cperl-lineup-step nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "*`cperl-lineup' will always lineup at multiple of this number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 If `nil', the value of `cperl-indent-level' will be used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defvar cperl-brace-imaginary-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "*Imagined indentation of a Perl open brace that actually follows a statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 An open brace following other text is treated as if it were this far
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 to the right of the start of its line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defvar cperl-brace-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "*Extra indentation for braces, compared with other text in same context.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defvar cperl-label-offset -2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "*Offset of CPerl label lines relative to usual indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar cperl-min-label-indent 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "*Minimal offset of CPerl label lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (defvar cperl-continued-statement-offset 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "*Extra indent for lines not starting new statements.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defvar cperl-continued-brace-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "*Extra indent for substatements that start with open-braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 This is in addition to cperl-continued-statement-offset.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defvar cperl-close-paren-offset -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "*Extra indent for substatements that start with close-parenthesis.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defvar cperl-auto-newline nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "*Non-nil means automatically newline before and after braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 and after colons and semicolons, inserted in CPerl code. The following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 \\[cperl-electric-backspace] will remove the inserted whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 Insertion after colons requires both this variable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 `cperl-auto-newline-after-colon' set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (defvar cperl-auto-newline-after-colon nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 "*Non-nil means automatically newline even after colons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 Subject to `cperl-auto-newline' setting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defvar cperl-tab-always-indent t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "*Non-nil means TAB in CPerl mode should always reindent the current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 regardless of where in the line point is when the TAB command is used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defvar cperl-font-lock nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "*Non-nil (and non-null) means CPerl buffers will use font-lock-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defvar cperl-electric-lbrace-space nil
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
414 "*Non-nil (and non-null) means { after $ in CPerl buffers should be preceeded by ` '.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
417 (defvar cperl-electric-parens-string "({[]})<"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "*String of parentheses that should be electric in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defvar cperl-electric-parens nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "*Non-nil (and non-null) means parentheses should be electric in CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 Can be overwritten by `cperl-hairy' if nil.")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
423 (defvar cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
424 (and window-system
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
425 (or (and (boundp 'transient-mark-mode) ; For Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
426 transient-mark-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
427 (and (boundp 'zmacs-regions) ; For XEmacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
428 zmacs-regions)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
429 "*Not-nil means that electric parens look for active mark.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
430 Default is yes if there is visual feedback on mark.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
431
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
432 (defvar cperl-electric-parens-mark (and window-system transient-mark-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 "*Not-nil means that electric parens look for active mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 Default is yes if there is visual feedback on mark.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (defvar cperl-electric-linefeed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 "*If true, LFD should be hairy in CPerl, otherwise C-c LFD is hairy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 In any case these two mean plain and hairy linefeeds together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (defvar cperl-electric-keywords nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 "*Not-nil (and non-null) means keywords are electric in CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defvar cperl-hairy nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 "*Not-nil means all the bells and whistles are enabled in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defvar cperl-comment-column 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "*Column to put comments in CPerl (use \\[cperl-indent]' to lineup with code).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (defvar cperl-vc-header-alist '((SCCS "$sccs = '%W\%' ;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (RCS "$rcs = ' $Id\$ ' ;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 "*What to use as `vc-header-alist' in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defvar cperl-info-on-command-no-prompt nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "*Not-nil (and non-null) means not to prompt on C-h f.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 The opposite behaviour is always available if prefixed with C-c.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
460 (defvar cperl-lazy-help-time nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
461 "*Not-nil (and non-null) means to show lazy help after given idle time.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
462
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defvar cperl-pod-face 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "*The result of evaluation of this expression is used for pod highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defvar cperl-pod-head-face 'font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 "*The result of evaluation of this expression is used for pod highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 Font for POD headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defvar cperl-here-face 'font-lock-string-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 "*The result of evaluation of this expression is used for here-docs highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (defvar cperl-pod-here-fontify '(featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 "*Not-nil after evaluation means to highlight pod and here-docs sections.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defvar cperl-pod-here-scan t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "*Not-nil means look for pod and here-docs sections during startup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 You can always make lookup from menu or using \\[cperl-find-pods-heres].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
480 (defvar cperl-imenu-addback nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
481 "*Not-nil means add backreferences to generated `imenu's.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
482 May require patched `imenu' and `imenu-go'.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
483
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
484 (defvar cperl-max-help-size 66
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
485 "*Non-nil means shrink-wrapping of info-buffer allowed up to these percents.")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
486
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
487 (defvar cperl-shrink-wrap-info-frame t
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
488 "*Non-nil means shrink-wrapping of info-buffer-frame allowed.")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
489
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
490 (defvar cperl-info-page "perl"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
491 "Name of the info page containing perl docs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
492 Older version of this page was called `perl5', newer `perl'.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
493
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;; Short extra-docs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defvar cperl-tips 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 "Get newest version of this package from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
504 Get support packages choose-color.el (or font-lock-extra.el before
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
505 19.30), imenu-go.el from the same place. \(Look for other files there
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
506 too... ;-) Get a patch for imenu.el in 19.29. Note that for 19.30 and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
507 later you should use choose-color.el *instead* of font-lock-extra.el
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
508 \(and you will not get smart highlighting in C :-().
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 Note that to enable Compile choices in the menu you need to install
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 mode-compile.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 Get perl5-info from
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
514 $CPAN/doc/manual/info/perl-info.tar.gz
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
515 older version was on
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 http://www.metronet.com:70/9/perlinfo/perl5/manual/perl5-info.tar.gz
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
517
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
518 If you use imenu-go, run imenu on perl5-info buffer (you can do it
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
519 from CPerl menu). If many files are related, generate TAGS files from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
520 Tools/Tags submenu in CPerl menu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
521
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
522 If some class structure is too complicated, use Tools/Hierarchy-view
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
523 from CPerl menu, or hierarchic view of imenu. The second one uses the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
524 current buffer only, the first one requires generation of TAGS from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
525 CPerl/Tools/Tags menu beforehand.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
526
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
527 Run CPerl/Tools/Insert-spaces-if-needed to fix your lazy typing.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
528
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
529 Switch auto-help on/off with CPerl/Tools/Auto-help.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 Before reporting (non-)problems look in the problem section on what I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 know about them.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defvar cperl-problems 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Emacs has a _very_ restricted syntax parsing engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 It may be corrected on the level of C code, please look in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 `non-problems' section if you want to volunteer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 CPerl mode tries to corrects some Emacs misunderstandings, however,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
541 for efficiency reasons the degree of correction is different for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 different operations. The partially corrected problems are: POD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 sections, here-documents, regexps. The operations are: highlighting,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 indentation, electric keywords, electric braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 This may be confusing, since the regexp s#//#/#\; may be highlighted
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
547 as a comment, but it will be recognized as a regexp by the indentation
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 code. Or the opposite case, when a pod section is highlighted, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 breaks the indentation of the following code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 The main trick (to make $ a \"backslash\") makes constructions like
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
552 ${aaa} look like unbalanced braces. The only trick I can think of is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 to insert it as $ {aaa} (legal in perl5, not in perl4).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 Similar problems arise in regexps, when /(\\s|$)/ should be rewritten
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
556 as /($|\\s)/. Note that such a transposition is not always possible
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 :-(. " )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defvar cperl-non-problems 'please-ignore-this-line
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
560 "As you know from `problems' section, Perl syntax is too hard for CPerl.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 Most the time, if you write your own code, you may find an equivalent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 \(and almost as readable) expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Try to help it: add comments with embedded quotes to fix CPerl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 misunderstandings about the end of quotation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 $a='500$'; # ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 You won't need it too often. The reason: $ \"quotes\" the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 character (this saves a life a lot of times in CPerl), thus due to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 Emacs parsing rules it does not consider tick after the dollar as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 closing one, but as a usual character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 Now the indentation code is pretty wise. The only drawback is that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 relies on Emacs parsing to find matching parentheses. And Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 *cannot* match parentheses in Perl 100% correctly. So
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 1 if s#//#/#;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 will not break indentation, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 1 if ( s#//#/# );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 will.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
583 By similar reasons
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
584 s\"abc\"def\";
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
585 will confuse CPerl a lot.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
586
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 If you still get wrong indentation in situation that you think the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 code should be able to parse, try:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 a) Check what Emacs thinks about balance of your parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 b) Supply the code to me (IZ).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 Pods are treated _very_ rudimentally. Here-documents are not treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 at all (except highlighting and inhibiting indentation). (This may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 change some time. RMS approved making syntax lookup recognize text
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
596 attributes, but volunteers are needed to change Emacs C code.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 To speed up coloring the following compromises exist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 a) sub in $mypackage::sub may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 b) -z in [a-z] may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 c) if your regexp contains a keyword (like \"s\"), it may be highlighted.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
602
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
603
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
604 Imenu in 19.31 is broken. Set `imenu-use-keymap-menu' to t, and remove
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
605 `car' before `imenu-choose-buffer-index' in `imenu'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;;; Portability stuff:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
612 (defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
613 (defmacro cperl-define-key (fsf-key definition &optional xemacs-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
614 `(define-key cperl-mode-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
615 ,(if xemacs-key
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
616 `(if cperl-xemacs-p ,xemacs-key ,fsf-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
617 fsf-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
618 ,definition))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defvar del-back-ch (car (append (where-is-internal 'delete-backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (where-is-internal 'backward-delete-char-untabify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 "Character generated by key bound to delete-backward-char.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (and (vectorp del-back-ch) (= (length del-back-ch) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (setq del-back-ch (aref del-back-ch 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
627 (if cperl-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; "Active regions" are on: use region only if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; "Active regions" are off: use region unconditionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (defun cperl-use-region-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (if zmacs-regions (mark) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defun cperl-mark-active () (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (defun cperl-use-region-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (if transient-mark-mode mark-active t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (defun cperl-mark-active () mark-active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (defsubst cperl-enable-font-lock ()
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
639 (or cperl-xemacs-p window-system))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (if (boundp 'unread-command-events)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
642 (if cperl-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (defun cperl-putback-char (c) ; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (setq unread-command-events (list (character-to-event c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (defun cperl-putback-char (c) ; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (setq unread-command-events (list c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (defun cperl-putback-char (c) ; XEmacs <= 19.11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (setq unread-command-event (character-to-event c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (or (fboundp 'uncomment-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (defun uncomment-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (comment-region beg end -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (defvar cperl-do-not-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (if (string< emacs-version "19.30")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 'fontified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 'lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 "Text property which inhibits refontification.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
661 (defsubst cperl-put-do-not-fontify (from to)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
662 (put-text-property (max (point-min) (1- from))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
663 to cperl-do-not-fontify t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
664
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ;;; Probably it is too late to set these guys already, but it can help later:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (append '(("\\.[pP][Llm]$" . perl-mode)) auto-mode-alist ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (and (boundp 'interpreter-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (setq interpreter-mode-alist (append interpreter-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 '(("miniperl" . perl-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (if (fboundp 'eval-when-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (require 'imenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ;; macros instead of defsubsts don't work on Emacs, so we do the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;; expansion manually. Any other suggestions?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (if (or (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 window-system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (require 'font-lock))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (defvar cperl-mode-abbrev-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 "Abbrev table in use in Cperl-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (add-hook 'edit-var-mode-alist '(perl-mode (regexp . "^cperl-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (defvar cperl-mode-map () "Keymap used in CPerl mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (if cperl-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (setq cperl-mode-map (make-sparse-keymap))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
699 (cperl-define-key "{" 'cperl-electric-lbrace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
700 (cperl-define-key "[" 'cperl-electric-paren)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
701 (cperl-define-key "(" 'cperl-electric-paren)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
702 (cperl-define-key "<" 'cperl-electric-paren)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
703 (cperl-define-key "}" 'cperl-electric-brace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
704 (cperl-define-key "]" 'cperl-electric-rparen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
705 (cperl-define-key ")" 'cperl-electric-rparen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
706 (cperl-define-key ";" 'cperl-electric-semi)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
707 (cperl-define-key ":" 'cperl-electric-terminator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
708 (cperl-define-key "\C-j" 'newline-and-indent)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
709 (cperl-define-key "\C-c\C-j" 'cperl-linefeed)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
710 (cperl-define-key "\C-c\C-a" 'cperl-toggle-auto-newline)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
711 (cperl-define-key "\C-c\C-k" 'cperl-toggle-abbrev)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
712 (cperl-define-key "\C-c\C-e" 'cperl-toggle-electric)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
713 (cperl-define-key "\e\C-q" 'cperl-indent-exp) ; Usually not bound
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
714 ;;(cperl-define-key "\M-q" 'cperl-fill-paragraph)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
715 ;;(cperl-define-key "\e;" 'cperl-indent-for-comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
716 (cperl-define-key "\177" 'cperl-electric-backspace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
717 (cperl-define-key "\t" 'cperl-indent-command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
718 ;; don't clobber the backspace binding:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
719 (cperl-define-key "\C-hf" 'cperl-info-on-command [(control h) f])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
720 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-current-command
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
721 [(control c) (control h) f])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
722 (cperl-define-key "\C-hv" 'cperl-get-help [(control h) v])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
723 (if (and cperl-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (<= emacs-minor-version 11) (<= emacs-major-version 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ;; substitute-key-definition is usefulness-deenhanced...
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
727 (cperl-define-key "\M-q" 'cperl-fill-paragraph)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
728 (cperl-define-key "\e;" 'cperl-indent-for-comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
729 (cperl-define-key "\e\C-\\" 'cperl-indent-region))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 'indent-sexp 'cperl-indent-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 'fill-paragraph 'cperl-fill-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 'indent-region 'cperl-indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 'indent-for-comment 'cperl-indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 cperl-mode-map global-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (easy-menu-define cperl-menu cperl-mode-map "Menu for CPerl mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 '("Perl"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ["Beginning of function" beginning-of-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ["End of function" end-of-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ["Mark function" mark-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ["Indent expression" cperl-indent-exp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ["Fill paragraph/comment" cperl-fill-paragraph t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ["Line up a construction" cperl-lineup (cperl-use-region-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ["Indent region" cperl-indent-region (cperl-use-region-p)]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
756 ["Comment region" cperl-comment-region (cperl-use-region-p)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
757 ["Uncomment region" cperl-uncomment-region (cperl-use-region-p)]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ["Run" mode-compile (fboundp 'mode-compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ["Kill" mode-compile-kill (and (fboundp 'mode-compile-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (get-buffer "*compilation*"))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ["Next error" next-error (get-buffer "*compilation*")]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ["Check syntax" cperl-check-syntax (fboundp 'mode-compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 "----"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
765 ["Debugger" cperl-db t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ("Tools"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ["Imenu" imenu (fboundp 'imenu)]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
769 ["Insert spaces if needed" cperl-find-bad-style t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
770 ["Class Hierarchy from TAGS" cperl-tags-hier-init t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
771 ;;["Update classes" (cperl-tags-hier-init t) tags-table-list]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ["Imenu on info" cperl-imenu-on-info (featurep 'imenu)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ("Tags"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
774 ;;; ["Create tags for current file" cperl-etags t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
775 ;;; ["Add tags for current file" (cperl-etags t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
776 ;;; ["Create tags for Perl files in directory" (cperl-etags nil t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
777 ;;; ["Add tags for Perl files in directory" (cperl-etags t t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
778 ;;; ["Create tags for Perl files in (sub)directories"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
779 ;;; (cperl-etags nil 'recursive) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
780 ;;; ["Add tags for Perl files in (sub)directories"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
781 ;;; (cperl-etags t 'recursive) t])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
782 ;;;; cperl-write-tags (&optional file erase recurse dir inbuffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
783 ["Create tags for current file" (cperl-write-tags nil t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
784 ["Add tags for current file" (cperl-write-tags) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
785 ["Create tags for Perl files in directory"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
786 (cperl-write-tags nil t nil t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
787 ["Add tags for Perl files in directory"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
788 (cperl-write-tags nil nil nil t) t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ["Create tags for Perl files in (sub)directories"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
790 (cperl-write-tags nil t t t) t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ["Add tags for Perl files in (sub)directories"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
792 (cperl-write-tags nil nil t t) t])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
793 ["Recalculate PODs and HEREs" cperl-find-pods-heres t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ["Define word at point" imenu-go-find-at-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (fboundp 'imenu-go-find-at-position)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ["Help on function" cperl-info-on-command t]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
797 ["Help on function at point" cperl-info-on-current-command t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
798 ["Help on symbol at point" cperl-get-help t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
799 ["Auto-help on" cperl-lazy-install (fboundp 'run-with-idle-timer)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
800 ["Auto-help off" cperl-lazy-unstall
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
801 (fboundp 'run-with-idle-timer)])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ("Toggle..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 ["Auto newline" cperl-toggle-auto-newline t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ["Electric parens" cperl-toggle-electric t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ["Electric keywords" cperl-toggle-abbrev t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ("Indent styles..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ["GNU" (cperl-set-style "GNU") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ["C++" (cperl-set-style "C++") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ["FSF" (cperl-set-style "FSF") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ["BSD" (cperl-set-style "BSD") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ["Whitesmith" (cperl-set-style "Whitesmith") t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ("Micro-docs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ["Tips" (describe-variable 'cperl-tips) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ["Problems" (describe-variable 'cperl-problems) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ["Non-problems" (describe-variable 'cperl-non-problems) t]))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (autoload 'c-macro-expand "cmacexp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 "Display the result of expanding all C macros occurring in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 The expansion is entirely correct because it uses the C preprocessor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (defvar cperl-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 "Syntax table in use in Cperl-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (if cperl-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (setq cperl-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (modify-syntax-entry ?\\ "\\" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (modify-syntax-entry ?/ "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (modify-syntax-entry ?* "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (modify-syntax-entry ?+ "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (modify-syntax-entry ?- "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (modify-syntax-entry ?= "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (modify-syntax-entry ?% "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (modify-syntax-entry ?< "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (modify-syntax-entry ?> "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (modify-syntax-entry ?& "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (modify-syntax-entry ?$ "\\" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (modify-syntax-entry ?\n ">" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (modify-syntax-entry ?# "<" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (modify-syntax-entry ?' "\"" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (modify-syntax-entry ?` "\"" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (modify-syntax-entry ?_ "w" cperl-mode-syntax-table)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
846 (modify-syntax-entry ?: "_" cperl-mode-syntax-table)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (modify-syntax-entry ?| "." cperl-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; Make customization possible "in reverse"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ;;(defun cperl-set (symbol to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; (or (eq (symbol-value symbol) 'null) (set symbol to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (defsubst cperl-val (symbol &optional default hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ((eq (symbol-value symbol) 'null) default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (cperl-hairy (or hairy t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (t (symbol-value symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; provide an alias for working with emacs 19. the perl-mode that comes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; with it is really bad, and this lets us seamlessly replace it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (fset 'perl-mode 'cperl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (defun cperl-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 "Major mode for editing Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 Expression and list commands understand all C brackets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 Tab indents for Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 Paragraphs are separated by blank lines only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 Delete converts tabs to spaces as it moves back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 Various characters in Perl almost always come in pairs: {}, (), [],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 sometimes <>. When the user types the first, she gets the second as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 well, with optional special formatting done on {}. (Disabled by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 default.) You can always quote (with \\[quoted-insert]) the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 \"paren\" to avoid the expansion. The processing of < is special,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 since most the time you mean \"less\". Cperl mode tries to guess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 whether you want to type pair <>, and inserts is if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 appropriate. You can set `cperl-electric-parens-string' to the string that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 contains the parenths from the above list you want to be electrical.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 Electricity of parenths is controlled by `cperl-electric-parens'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 You may also set `cperl-electric-parens-mark' to have electric parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 look for active mark and \"embrace\" a region if possible.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 CPerl mode provides expansion of the Perl control constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 if, else, elsif, unless, while, until, for, and foreach.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 =========(Disabled by default, see `cperl-electric-keywords'.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 The user types the keyword immediately followed by a space, which causes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 the construct to be expanded, and the user is positioned where she is most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 likely to want to be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 eg. when the user types a space following \"if\" the following appears in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 the buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 if () { or if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 } {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 and the cursor is between the parentheses. The user can then type some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 boolean expression within the parens. Having done that, typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 \\[cperl-linefeed] places you, appropriately indented on a new line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 between the braces. If CPerl decides that you want to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 \"English\" style construct like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 bite if angry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 it will not do any expansion. See also help on variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 `cperl-extra-newline-before-brace'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
903 \\[cperl-linefeed] is a convenience replacement for typing carriage
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 return. It places you in the next line with proper indentation, or if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 you type it inside the inline block of control construct, like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 foreach (@lines) {print; print}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 and you are on a boundary of a statement inside braces, it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 transform the construct into a multiline and will place you into an
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
909 appropriately indented blank line. If you need a usual
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 `newline-and-indent' behaviour, it is on \\[newline-and-indent],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 see documentation on `cperl-electric-linefeed'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 \\{cperl-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 Setting the variable `cperl-font-lock' to t switches on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 font-lock-mode, `cperl-electric-lbrace-space' to t switches on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 electric space between $ and {, `cperl-electric-parens-string' is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 string that contains parentheses that should be electric in CPerl (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 also `cperl-electric-parens-mark' and `cperl-electric-parens'),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 setting `cperl-electric-keywords' enables electric expansion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 control structures in CPerl. `cperl-electric-linefeed' governs which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 one of two linefeed behavior is preferable. You can enable all these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 options simultaneously (recommended mode of use) by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 `cperl-hairy' to t. In this case you can switch separate options off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 by setting them to `null'. Note that one may undo the extra whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 inserted by semis and braces in `auto-newline'-mode by consequent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 \\[cperl-electric-backspace].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 If your site has perl5 documentation in info format, you can use commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 \\[cperl-info-on-current-command] and \\[cperl-info-on-command] to access it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 These keys run commands `cperl-info-on-current-command' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 `cperl-info-on-command', which one is which is controlled by variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 `cperl-info-on-command-no-prompt' (in turn affected by `cperl-hairy').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
935 Even if you have no info-format documentation, short one-liner-style
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
936 help is available on \\[cperl-get-help].
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
937
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
938 It is possible to show this help automatically after some idle
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
939 time. This is regulated by variable `cperl-lazy-help-time'. Default
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
940 with `cperl-hairy' is 5 secs idle time if the value of this variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
941 is nil. It is also possible to switch this on/off from the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
942 menu. Requires `run-with-idle-timer'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
943
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 Variables `cperl-pod-here-scan', `cperl-pod-here-fontify',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 `cperl-pod-face', `cperl-pod-head-face' control processing of pod and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 here-docs sections. In a future version results of scan may be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 for indentation too, currently they are used for highlighting only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 Variables controlling indentation style:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 `cperl-tab-always-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 Non-nil means TAB in CPerl mode should always reindent the current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 regardless of where in the line point is when the TAB command is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 `cperl-auto-newline'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 Non-nil means automatically newline before and after braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 and after colons and semicolons, inserted in Perl code. The following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 \\[cperl-electric-backspace] will remove the inserted whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 Insertion after colons requires both this variable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 `cperl-auto-newline-after-colon' set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 `cperl-auto-newline-after-colon'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 Non-nil means automatically newline even after colons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 Subject to `cperl-auto-newline' setting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 `cperl-indent-level'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 Indentation of Perl statements within surrounding block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 The surrounding block's indentation is the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 of the line on which the open-brace appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 `cperl-continued-statement-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 Extra indentation given to a substatement, such as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 then-clause of an if, or body of a while, or just a statement continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 `cperl-continued-brace-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 Extra indentation given to a brace that starts a substatement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 This is in addition to `cperl-continued-statement-offset'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 `cperl-brace-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 Extra indentation for line if it starts with an open brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 `cperl-brace-imaginary-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 An open brace following other text is treated as if it the line started
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 this far to the right of the actual line indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 `cperl-label-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 Extra indentation for line that is a label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 `cperl-min-label-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 Minimal indentation for line that is a label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 Settings for K&R and BSD indentation styles are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 `cperl-indent-level' 5 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 `cperl-continued-statement-offset' 5 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 `cperl-brace-offset' -5 -8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 `cperl-label-offset' -5 -8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 If `cperl-indent-level' is 0, the statement after opening brace in column 0 is indented on `cperl-brace-offset'+`cperl-continued-statement-offset'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 Turning on CPerl mode calls the hooks in the variable `cperl-mode-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 with no args."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;;(if cperl-hairy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; (cperl-set 'cperl-font-lock cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; (cperl-set 'cperl-electric-lbrace-space cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;; (cperl-set 'cperl-electric-parens "{[(<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; (cperl-set 'cperl-electric-keywords cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; (cperl-set 'cperl-electric-linefeed cperl-hairy)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (use-local-map cperl-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (if (cperl-val 'cperl-electric-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (local-set-key "\C-J" 'cperl-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (local-set-key "\C-C\C-J" 'newline-and-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (if (cperl-val 'cperl-info-on-command-no-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (progn
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1008 ;; don't clobber the backspace binding:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1009 (cperl-define-key "\C-hf" 'cperl-info-on-current-command [(control h) f])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1010 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-command
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1011 [(control c) (control h) f])))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (setq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (setq mode-name "CPerl")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (if (not cperl-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (let ((prev-a-c abbrevs-changed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (define-abbrev-table 'cperl-mode-abbrev-table '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ("if" "if" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ("elsif" "elsif" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ("while" "while" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ("until" "until" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ("unless" "unless" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 ("else" "else" cperl-electric-else 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 ("for" "for" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ("foreach" "foreach" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ("do" "do" cperl-electric-keyword 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (setq abbrevs-changed prev-a-c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (setq local-abbrev-table cperl-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (abbrev-mode (if (cperl-val 'cperl-electric-keywords) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (set-syntax-table cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (setq paragraph-start (concat "^$\\|" page-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (setq paragraph-separate paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (make-local-variable 'paragraph-ignore-fill-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (setq paragraph-ignore-fill-prefix t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (make-local-variable 'indent-line-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (setq indent-line-function 'cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (setq require-final-newline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setq comment-start "# ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (make-local-variable 'comment-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (setq comment-end "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (make-local-variable 'comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (setq comment-column cperl-comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (make-local-variable 'comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (setq comment-start-skip "#+ *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (make-local-variable 'defun-prompt-regexp)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1049 (setq defun-prompt-regexp "^[ \t]*sub[ \t]+\\([^ \t\n{;]+\\)[ \t]*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (make-local-variable 'comment-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (setq comment-indent-function 'cperl-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (make-local-variable 'parse-sexp-ignore-comments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (setq parse-sexp-ignore-comments t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (make-local-variable 'indent-region-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (setq indent-region-function 'cperl-indent-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ;;(setq auto-fill-function 'cperl-do-auto-fill) ; Need to switch on and off!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (make-local-variable 'imenu-create-index-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (setq imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (function imenu-example--create-perl-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (make-local-variable 'imenu-sort-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (setq imenu-sort-function nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (make-local-variable 'vc-header-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (setq vc-header-alist cperl-vc-header-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (setq font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (if (string< emacs-version "19.30")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 '(perl-font-lock-keywords-2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 '((perl-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 perl-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 perl-font-lock-keywords-2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (or (fboundp 'cperl-old-auto-fill-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (fset 'cperl-old-auto-fill-mode (symbol-function 'auto-fill-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (defun auto-fill-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (cperl-old-auto-fill-mode arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (and auto-fill-function (eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (setq auto-fill-function 'cperl-do-auto-fill)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (if (cperl-enable-font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (if (cperl-val 'cperl-font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (progn (or cperl-faces-init (cperl-init-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (font-lock-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (and (boundp 'msb-menu-cond)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (not cperl-msb-fixed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (cperl-msb-fix))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1086 (if (featurep 'easymenu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1087 (easy-menu-add cperl-menu)) ; A NOP under FSF Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (run-hooks 'cperl-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; After hooks since fontification will break this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (if cperl-pod-here-scan (cperl-find-pods-heres)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1092 ;; Fix for perldb - make default reasonable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1093 (defun cperl-db ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1094 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1095 (require 'gud)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1096 (perldb (read-from-minibuffer "Run perldb (like this): "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1097 (if (consp gud-perldb-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1098 (car gud-perldb-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1099 (concat "perl " ;;(file-name-nondirectory
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1100 ;; I have problems
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1101 ;; in OS/2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1102 ;; otherwise
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1103 (buffer-file-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1104 nil nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1105 '(gud-perldb-history . 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1106
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; Fix for msb.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (defvar cperl-msb-fixed nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (defun cperl-msb-fix ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;; Adds perl files to msb menu, supposes that msb is already loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (setq cperl-msb-fixed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (let* ((l (length msb-menu-cond))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (last (nth (1- l) msb-menu-cond))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (handle (1- (nth 1 last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (setcdr precdr (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 '(eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 "Perl Files (%d)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ;; This is used by indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 ;; to decide how much to indent a comment in CPerl code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 ;; based on its context. Do fallback if comment is found wrong.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (defvar cperl-wrong-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (defun cperl-comment-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (let ((p (point)) (c (current-column)) was)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (if (looking-at "^#") 0 ; Existing comment at bol stays there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 ;; Wrong comment found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (setq was (cperl-to-comment-or-eol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (if (= (point) p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (max (1+ (current-column)) ; Else indent at comment column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (if was nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (insert comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (backward-char (length comment-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (setq cperl-wrong-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (indent-to comment-column 1) ; Indent minimum 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 c))))) ; except leave at least one space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 ;;;(defun cperl-comment-indent-fallback ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;;; "Is called if the standard comment-search procedure fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 ;;;Point is at start of real comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ;;; (let ((c (current-column)) target cnt prevc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;;; (if (= c comment-column) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;;; (setq cnt (skip-chars-backward "[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;;; (setq target (max (1+ (setq prevc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 ;;; (current-column))) ; Else indent at comment column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;;; comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;;; (if (= c comment-column) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 ;;; (delete-backward-char cnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;;; (while (< prevc target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;;; (insert "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;;; (setq prevc (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 ;;; (if (> prevc target) (progn (delete-char -1) (setq prevc (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;;; (while (< prevc target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ;;; (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 ;;; (setq prevc (current-column)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (defun cperl-indent-for-comment ()
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1168 "Substitute for `indent-for-comment' in CPerl."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (let (cperl-wrong-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (if cperl-wrong-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (progn (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (forward-char (length comment-start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1176 (defun cperl-comment-region (b e arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1177 "Comment or uncomment each line in the region in CPerl mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1178 See `comment-region'."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1179 (interactive "r\np")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1180 (let ((comment-start "#"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1181 (comment-region b e arg)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1182
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1183 (defun cperl-uncomment-region (b e arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1184 "Uncomment or comment each line in the region in CPerl mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1185 See `comment-region'."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1186 (interactive "r\np")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1187 (let ((comment-start "#"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1188 (comment-region b e (- arg))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1189
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1190 (defvar cperl-brace-recursing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1191
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (defun cperl-electric-brace (arg &optional only-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 "Insert character and correct line's indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 If ONLY-BEFORE and `cperl-auto-newline', will insert newline before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 place (even in empty line), but not after. If after \")\" and the inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 char is \"{\", insert extra newline before only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 `cperl-extra-newline-before-brace'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (interactive "P")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1199 (let (insertpos
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1200 (other-end (if (and cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1201 (cperl-mark-active)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1202 (< (mark) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1203 (mark)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1204 nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1205 (if (and other-end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1206 (not cperl-brace-recursing)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1207 (cperl-val 'cperl-electric-parens)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1208 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1209 ;; Need to insert a matching pair
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1212 (setq insertpos (point-marker))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1213 (goto-char other-end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1214 (setq last-command-char ?\{)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1215 (cperl-electric-lbrace arg insertpos))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1216 (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1217 (if (and (not arg) ; No args, end (of empty line or auto)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1218 (eolp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1219 (or (and (null only-before)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1220 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1221 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1222 (bolp)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1223 (and (eq last-command-char ?\{) ; Do not insert newline
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1224 ;; if after ")" and `cperl-extra-newline-before-brace'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1225 ;; is nil, do not insert extra newline.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1226 (not cperl-extra-newline-before-brace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1227 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1228 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1229 (eq (preceding-char) ?\))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1230 (if cperl-auto-newline
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1231 (progn (cperl-indent-line) (newline) t) nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1232 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1233 (insert last-command-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1234 (cperl-indent-line)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1235 (if cperl-auto-newline
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1236 (setq insertpos (1- (point))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1237 (if (and cperl-auto-newline (null only-before))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1238 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1239 (newline)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1240 (cperl-indent-line)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1241 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1242 (if insertpos (progn (goto-char insertpos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1243 (search-forward (make-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1244 1 last-command-char))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1245 (setq insertpos (1- (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1246 (delete-char -1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1247 (if insertpos
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1248 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1249 (goto-char insertpos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1250 (self-insert-command (prefix-numeric-value arg)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1251 (self-insert-command (prefix-numeric-value arg))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1252
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1253 (defun cperl-electric-lbrace (arg &optional end)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 "Insert character, correct line's indentation, correct quoting by space."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (let (pos after
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1257 (cperl-brace-recursing t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (cperl-auto-newline cperl-auto-newline)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1259 (other-end (or end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1260 (if (and cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1261 (cperl-mark-active)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1262 (> (mark) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1263 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1264 (goto-char (mark))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1265 (point-marker))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1266 nil))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (and (cperl-val 'cperl-electric-lbrace-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (eq (preceding-char) ?$)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (skip-chars-backward "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (insert ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (if (cperl-after-expr-p nil "{};)") nil (setq cperl-auto-newline nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (cperl-electric-brace arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (and (cperl-val 'cperl-electric-parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (eq last-command-char ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (memq last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (append cperl-electric-parens-string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (or (if other-end (goto-char (marker-position other-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (setq last-command-char ?} pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (progn (cperl-electric-brace arg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (goto-char pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (defun cperl-electric-paren (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 "Insert a matching pair of parentheses."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (other-end (if (and cperl-electric-parens-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (cperl-mark-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (> (mark) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (goto-char (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (if (and (cperl-val 'cperl-electric-parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (memq last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (append cperl-electric-parens-string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;;(not (save-excursion (search-backward "#" beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (if (eq last-command-char ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (cperl-after-expr-p nil "{};(,:=")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (if other-end (goto-char (marker-position other-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (insert (cdr (assoc last-command-char '((?{ .?})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (?[ . ?])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (?( . ?))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (?< . ?>)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1315 (defun cperl-electric-rparen (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1316 "Insert a matching pair of parentheses if marking is active.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1317 If not, or if we are not at the end of marking range, would self-insert."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1318 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1319 (let ((beg (save-excursion (beginning-of-line) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1320 (other-end (if (and cperl-electric-parens-mark
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1321 (cperl-val 'cperl-electric-parens)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1322 (memq last-command-char
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
1323 (append cperl-electric-parens-string nil))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1324 (cperl-mark-active)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1325 (< (mark) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1326 (mark)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1327 nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1328 p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1329 (if (and other-end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1330 (cperl-val 'cperl-electric-parens)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1331 (memq last-command-char '( ?\) ?\] ?\} ?\> ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1332 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1333 ;;(not (save-excursion (search-backward "#" beg t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1334 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1335 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1336 (insert last-command-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1337 (setq p (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1338 (if other-end (goto-char other-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1339 (insert (cdr (assoc last-command-char '((?\} . ?\{)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1340 (?\] . ?\[)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1341 (?\) . ?\()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1342 (?\> . ?\<)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1343 (goto-char (1+ p)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1344 (call-interactively 'self-insert-command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1345 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1346
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (defun cperl-electric-keyword ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 "Insert a construction appropriate after a keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (let ((beg (save-excursion (beginning-of-line) (point)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1350 (dollar (eq last-command-char ?$)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (cperl-after-expr-p nil "{};:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (save-excursion (or (not (re-search-backward "^=" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (looking-at "=cut")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (and dollar (insert " $"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ;;(insert " () {\n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (cperl-extra-newline-before-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (insert " ()\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (insert "{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (insert "\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (insert " () {\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (or (looking-at "[ \t]\\|$") (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (if dollar (progn (search-backward "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (search-backward ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (cperl-putback-char del-back-ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (defun cperl-electric-else ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 "Insert a construction appropriate after a keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (let ((beg (save-excursion (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (cperl-after-expr-p nil "{};:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (save-excursion (or (not (re-search-backward "^=" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (looking-at "=cut")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 ;;(insert " {\n\n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (cperl-extra-newline-before-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (insert "{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (insert "\n\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (insert " {\n\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (or (looking-at "[ \t]\\|$") (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (cperl-putback-char del-back-ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (defun cperl-linefeed ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 "Go to end of line, open a new line and indent appropriately."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (end (save-excursion (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (pos (point)) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (if (and ; Check if we need to split:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 ; i.e., on a boundary and inside "{...}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (save-excursion (cperl-to-comment-or-eol)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1423 (>= (point) pos)) ; Not in a comment
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (skip-chars-backward " \t" beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (forward-char -1)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1427 (looking-at "[;{]")) ; After { or ; + spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1428 (looking-at "[ \t]*}") ; Before }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1429 (re-search-forward "\\=[ \t]*;" end t)) ; Before spaces + ;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (and
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1432 (eq (car (parse-partial-sexp pos end -1)) -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1433 ; Leave the level of parens
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (looking-at "[,; \t]*\\($\\|#\\)") ; Comma to allow anon subr
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1435 ; Are at end
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (setq start (point-marker))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1439 (<= start pos))))) ; Redundant? Are after the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1440 ; start of parens group.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (or (memq (preceding-char) (append ";{" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (insert ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (or (looking-at "{[ \t]*$") ; If there is a statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ; before, move it to separate line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (forward-line 1) ; We are on the target line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (or (looking-at "[ \t]*}[,; \t]*$") ; If there is a statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ; after, move it to separate line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (search-backward "}" beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (or (memq (preceding-char) (append ";{" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (insert ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (forward-line -1) ; We are on the line before target
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (end-of-line) ; else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1473 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1474 ((and (looking-at "\n[ \t]*{$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1475 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1476 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1477 (eq (preceding-char) ?\)))) ; Probably if () {} group
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1478 ; with an extra newline.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1479 (forward-line 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1480 (cperl-indent-line))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1481 ((looking-at "\n[ \t]*$") ; Next line is empty - use it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1482 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1483 (cperl-indent-line))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1484 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1485 (newline-and-indent))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (defun cperl-electric-semi (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 "Insert character and correct line's indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (if cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (cperl-electric-terminator arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (self-insert-command (prefix-numeric-value arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (defun cperl-electric-terminator (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 "Insert character and correct line's indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (let (insertpos (end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (auto (and cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (or (not (eq last-command-char ?:))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 cperl-auto-newline-after-colon))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1501 (if (and ;;(not arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1502 (eolp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;; Ignore in comment lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (= (following-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; Colon is special only after a label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;; So quickly rule out most other uses of colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;; and do no indentation for them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (and (eq last-command-char ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (progn (goto-char (- end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (not (looking-at ":"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (let ((pps (parse-partial-sexp (point) end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (insert last-command-char)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1525 ;;(forward-char -1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (if auto (setq insertpos (point-marker)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1527 ;;(forward-char 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (if auto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; (if insertpos (progn (goto-char (marker-position insertpos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ;; (search-forward (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; 1 last-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ;; (setq insertpos (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ;; (delete-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1540 (if insertpos (goto-char (1- (marker-position insertpos)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (delete-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (if insertpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (goto-char insertpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (self-insert-command (prefix-numeric-value arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (self-insert-command (prefix-numeric-value arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (defun cperl-electric-backspace (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 "Backspace-untabify, or remove the whitespace inserted by an electric key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (if (and cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (memq last-command '(cperl-electric-semi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 cperl-electric-terminator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 cperl-electric-lbrace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (memq (preceding-char) '(? ?\t ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (let (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (if (eq last-command 'cperl-electric-lbrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (skip-chars-forward " \t\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (delete-region (point) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (backward-delete-char-untabify arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (defun cperl-inside-parens-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (progn (beginning-of-defun) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (= (char-after (or (scan-lists (point) -1 1) (point-min))) ?\()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (defun cperl-indent-command (&optional whole-exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 "Indent current line as Perl code, or in some cases insert a tab character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 If `cperl-tab-always-indent' is non-nil (the default), always indent current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 Otherwise, indent the current line only if point is at the left margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 or in the line's indentation; otherwise insert a tab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 A numeric argument, regardless of its value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 means indent rigidly all the lines of the expression starting after point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 so that this line becomes properly indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 The relative indentation among the lines of the expression are preserved."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1585 (interactive "P")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (if whole-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 ;; If arg, always indent this line as Perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 ;; and shift remaining lines of expression the same amount.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (let ((shift-amt (cperl-indent-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (if cperl-tab-always-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (setq beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (if (> end beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (indent-code-rigidly beg end shift-amt "#")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (if (and (not cperl-tab-always-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (not (bolp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (insert-tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (cperl-indent-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (defun cperl-indent-line (&optional symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 "Indent current line as Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 Return the amount the indentation changed by."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (let (indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 beg shift-amt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (pos (- (point-max) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (setq indent (cperl-calculate-indent nil symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (cond ((eq indent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (setq indent (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ;;((eq indent t) ; Never?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 ;; (setq indent (cperl-calculate-indent-within-comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 ;;((looking-at "[ \t]*#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ;; (setq indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (if (listp indent) (setq indent (car indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (cond ((looking-at "[A-Za-z]+:[^:]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (and (> indent 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (setq indent (max cperl-min-label-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (+ indent cperl-label-offset)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 ((= (following-char) ?})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (setq indent (- indent cperl-indent-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ((memq (following-char) '(?\) ?\])) ; To line up with opening paren.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (setq indent (+ indent cperl-close-paren-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 ((= (following-char) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (setq indent (+ indent cperl-brace-offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (setq shift-amt (- indent (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (if (zerop shift-amt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (if (> (- (point-max) pos) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (goto-char (- (point-max) pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (indent-to indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 ;; If initial point was within line's indentation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 ;; position after the indentation. Else stay at same point in text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (if (> (- (point-max) pos) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (goto-char (- (point-max) pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 shift-amt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (defun cperl-after-label ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 ;; Returns true if the point is after label. Does not do save-excursion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (and (eq (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (memq (char-syntax (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 '(?w ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (backward-sexp)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1658 (looking-at "[a-zA-Z_][a-zA-Z0-9_]*:[^:]"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (defun cperl-get-state (&optional parse-start start-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 ;; returns list (START STATE DEPTH PRESTART), START is a good place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 ;; to start parsing, STATE is what is returned by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ;; `parse-partial-sexp'. DEPTH is true is we are immediately after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ;; end of block which contains START. PRESTART is the position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 ;; basing on which START was found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (let ((start-point (point)) depth state start prestart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (beginning-of-defun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (setq prestart (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (if start-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ;; Try to go out, if sub is not on the outermost level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (while (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (setq start (point) parse-start start depth nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 state (parse-partial-sexp start start-point -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (if (> (car state) -1) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; The current line could start like }}}, so the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 ;; corresponds to a different level than what we reached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (setq depth t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (beginning-of-line 2))) ; Go to the next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (if start (goto-char start))) ; Not at the start of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (if (< start start-point) (setq parse-start start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (or state (setq state (parse-partial-sexp start start-point -1 nil start-state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (list start state depth prestart))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (defun cperl-block-p () ; Do not C-M-q ! One string contains ";" !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 ;; Positions is before ?\{. Checks whether it starts a block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 ;; No save-excursion!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (cperl-backward-to-noncomment (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;;(skip-chars-backward " \t\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (or (memq (preceding-char) (append ";){}$@&%\C-@" nil)) ; Or label! \C-@ at bobp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 ; Label may be mixed up with `$blah :'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (save-excursion (cperl-after-label))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1696 (and (memq (char-syntax (preceding-char)) '(?w ?_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;; Need take into account `bless', `return', `tr',...
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1700 (or (and (looking-at "[a-zA-Z0-9_:]+[ \t\n\f]*[{#]") ; Method call syntax
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (not (looking-at "\\(bless\\|return\\|qw\\|tr\\|[smy]\\)\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (skip-chars-backward " \t\n\f")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1704 (and (memq (char-syntax (preceding-char)) '(?w ?_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (looking-at
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1708 "sub[ \t]+[a-zA-Z0-9_:]+[ \t\n\f]*[#{]")))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (defun cperl-calculate-indent (&optional parse-start symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 "Return appropriate indentation for current line as Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 In usual case returns an integer: the column to indent to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 Returns nil if line starts inside a string, t if in a comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (if (memq (get-text-property (point) 'syntax-type) '(pod here-doc)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (let* ((indent-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (s-s (cperl-get-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (start (nth 0 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (state (nth 1 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (containing-sexp (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (char-after (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (start-indent (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (- (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (if (nth 2 s-s) cperl-indent-level 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 old-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 ;; (or parse-start (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 ;; (setq parse-start (symbol-value symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 ;; start-indent (nth 2 parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ;; parse-start (car parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ;; (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ;; (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ;; (beginning-of-defun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ;; ;; Try to go out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ;; (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 ;; (setq start (point) parse-start start moved nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 ;; state (parse-partial-sexp start indent-point -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; (if (> (car state) -1) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; ;; The current line could start like }}}, so the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ;; ;; corresponds to a different level than what we reached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;; (setq moved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; (beginning-of-line 2))) ; Go to the next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; (if start ; Not at the start of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ;; (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; (setq start-indent (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 ;; (if moved ; Should correct...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ;; (setq start-indent (- start-indent cperl-indent-level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 ;; (setq start-indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ;; (if (< (point) indent-point) (setq parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 ;; (or state (setq state (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 ;; (point) indent-point -1 nil start-state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 ;; (setq containing-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;; (or (car (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 ;; (and (>= (nth 6 state) 0) old-containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 ;; old-containing-sexp nil start-state nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 ;;;; (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ;;;; (setq parse-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ;;;; (setq state (parse-partial-sexp (point) indent-point -1 nil start-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 ;;;; (setq containing-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ;;;; (or (car (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 ;;;; (and (>= (nth 6 state) 0) old-containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ;;;; old-containing-sexp nil start-state nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; (if symbol (set symbol (list indent-point state start-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ;; (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (cond ((or (nth 3 state) (nth 4 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 ;; return nil or t if should not change this line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (nth 4 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ((null containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ;; Line is at top level. May be data or function definition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ;; or may be function argument declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ;; Indent like the previous top level line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ;; unless that ends in a closeparen without semicolon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ;; in which case this line is the first argument decl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (+ start-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (if (= (following-char) ?{) cperl-continued-brace-offset 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (cperl-backward-to-noncomment (or parse-start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 ;;(skip-chars-backward " \t\f\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;; Look at previous line that's at column 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ;; to determine whether we are in top-level decls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; or function's arg decls. Set basic-indent accordingly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 ;; Now add a little if this is a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (if (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (memq (preceding-char) (append " ;}" nil)) ; Was ?\)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1791 (memq char-after (append ")]}" nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1792 (and (eq (preceding-char) ?\:) ; label
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1793 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1794 (forward-sexp -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1795 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1796 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 cperl-continued-statement-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ((/= (char-after containing-sexp) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ;; line is expression, not statement:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ;; indent to just after the surrounding open,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ;; skip blanks if we do not close the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (or (memq char-after (append ")]}" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 ;; Containing-expr starts with \{. Check whether it is a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (not (cperl-block-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (or (eq char-after ?\})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (+ (current-column) ; Correct indentation of trailing ?\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (if (eq char-after ?\}) (+ cperl-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 cperl-close-paren-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ;; Statement level. Is it a continuation or a new statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; Find previous non-comment character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (cperl-backward-to-noncomment containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; Back up over label lines, since they don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 ;; affect whether our line is a continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (while (or (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (and (eq (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (or;;(eq (char-after (- (point) 2)) ?\') ; ????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (memq (char-syntax (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 '(?w ?_)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (if (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 ;; Will go to beginning of line, essentially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 ;; Will ignore embedded sexpr XXXX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (cperl-backward-to-start-of-continued-exp containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (cperl-backward-to-noncomment containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 ;; Now we get the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (if (not (memq (preceding-char) (append ", ;}{" '(nil)))) ; Was ?\,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 ;; This line is continuation of preceding line's statement;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ;; indent `cperl-continued-statement-offset' more than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 ;; previous line of the statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (cperl-backward-to-start-of-continued-exp containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (+ (if (memq char-after (append "}])" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 0 ; Closing parenth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (if (eq char-after ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 cperl-continued-brace-offset 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ;; This line starts a new statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 ;; Is line first statement after an open-brace?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 ;; If no, find that first statement and indent like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ;; it. If the first statement begins with label, do
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1858 ;; not believe when the indentation of the label is too
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ;; small.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (setq old-indent (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (let ((colon-line-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (while (progn (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (looking-at "#\\|[a-zA-Z0-9_$]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ;; Skip over comments and labels following openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (cond ((= (following-char) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ;; label:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (setq colon-line-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (search-forward ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ;; The first following code counts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 ;; if it is before the line we want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (and (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (if (> colon-line-end (point)) ; After label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (if (> (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (- (current-indentation) cperl-label-offset)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1881 ;; Do not believe: `max' is involved
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (+ old-indent cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (current-column)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 ;; If no previous statement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 ;; indent it relative to line brace is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;; For open brace in column zero, don't let statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 ;; start there too. If cperl-indent-level is zero,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 ;; For open-braces not the first thing in a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 ;; add in cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 ;; If first thing on a line: ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (+ (if (and (bolp) (zerop cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (+ cperl-brace-offset cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 cperl-indent-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 ;; Move back over whitespace before the openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 ;; If openbrace is not first nonwhite thing on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 ;; add the cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (if (bolp) 0 cperl-brace-imaginary-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 ;; If the openbrace is preceded by a parenthesized exp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 ;; move to the beginning of that;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; possibly a different line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (if (eq (preceding-char) ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 ;; In the case it starts a subroutine, indent with
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1908 ;; respect to `sub', not with respect to the the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 ;; first thing on the line, say in the case of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 ;; anonymous sub in a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (if (and (eq (preceding-char) ?b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (looking-at "sub\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (setq old-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (nth 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (save-excursion (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (progn (goto-char (1+ old-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 ;; Get initial indentation of the line we are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 ;; If line starts with label, calculate label indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (if (> (current-indentation) cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (cperl-calculate-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (if (and parse-start (<= parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (current-indentation)))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (defvar cperl-indent-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 '((string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (comment nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (toplevel 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (toplevel-after-parenth 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (toplevel-continued 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (expression 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 "Alist of indentation rules for CPerl mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 The values mean:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 nil: do not indent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 number: add this amount of indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (defun cperl-where-am-i (&optional parse-start start-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 ;; Unfinished
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 "Return a list of lists ((TYPE POS)...) of good points before the point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 POS may be nil if it is hard to find, say, when TYPE is `string' or `comment'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (let* ((start-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (s-s (cperl-get-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (start (nth 0 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (state (nth 1 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (prestart (nth 3 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (containing-sexp (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (res (list (list 'parse-start start) (list 'parse-prestart prestart))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (cond ((nth 3 state) ; In string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (setq res (cons (list 'string nil (nth 3 state)) res))) ; What started string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 ((nth 4 state) ; In comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (setq res (cons '(comment) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 ((null containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 ;; Line is at top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 ;; Indent like the previous top level line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 ;; unless that ends in a closeparen without semicolon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 ;; in which case this line is the first argument decl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (cperl-backward-to-noncomment (or parse-start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 ;;(skip-chars-backward " \t\f\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 ((or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (memq (preceding-char) (append ";}" nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (setq res (cons (list 'toplevel start) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 ((eq (preceding-char) ?\) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (setq res (cons (list 'toplevel-after-parenth start) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (setq res (cons (list 'toplevel-continued start) res)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 ((/= (char-after containing-sexp) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 ;; line is expression, not statement:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 ;; indent to just after the surrounding open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 ;; skip blanks if we do not close the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (setq res (cons (list 'expression-blanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (or (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (cons (list 'expression containing-sexp) res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 ;; Containing-expr starts with \{. Check whether it is a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (not (cperl-block-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (setq res (cons (list 'expression-blanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (or (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (cons (list 'expression containing-sexp) res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 ;; Statement level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (setq res (cons (list 'in-block containing-sexp) res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 ;; Is it a continuation or a new statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 ;; Find previous non-comment character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (cperl-backward-to-noncomment containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 ;; Back up over label lines, since they don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 ;; affect whether our line is a continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ;; Back up comma-delimited lines too ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (while (or (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (save-excursion (cperl-after-label)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (if (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 ;; Will go to beginning of line, essentially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 ;; Will ignore embedded sexpr XXXX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (cperl-backward-to-start-of-continued-exp containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (cperl-backward-to-noncomment containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 ;; Now we get the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (if (not (memq (preceding-char) (append ";}{" '(nil)))) ; Was ?\,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 ;; This line is continuation of preceding line's statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (list (list 'statement-continued containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 ;; This line starts a new statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 ;; Is line first statement after an open-brace?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 ;; If no, find that first statement and indent like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 ;; it. If the first statement begins with label, do
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2031 ;; not believe when the indentation of the label is too
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 ;; small.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (let ((colon-line-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (while (progn (skip-chars-forward " \t\n" start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (and (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 "#\\|[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;; Skip over comments and labels following openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (cond ((= (following-char) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ;;(forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 ;; label:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (setq colon-line-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (search-forward ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;; Now at the point, after label, or at start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 ;; of first statement in the block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (and (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (if (> colon-line-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 ;; Before statement after label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (if (> (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (list (list 'label-in-block (point)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2057 ;; Do not believe: `max' is involved
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (list 'label-in-block-min-indent (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 ;; Before statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (list 'statement-in-block (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 ;; If no previous statement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 ;; indent it relative to line brace is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 ;; For open brace in column zero, don't let statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 ;; start there too. If cperl-indent-level is zero,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 ;; For open-braces not the first thing in a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 ;; add in cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 ;; If first thing on a line: ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (+ (if (and (bolp) (zerop cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (+ cperl-brace-offset cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 cperl-indent-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 ;; Move back over whitespace before the openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 ;; If openbrace is not first nonwhite thing on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 ;; add the cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (if (bolp) 0 cperl-brace-imaginary-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 ;; If the openbrace is preceded by a parenthesized exp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 ;; move to the beginning of that;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 ;; possibly a different line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (if (eq (preceding-char) ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ;; Get initial indentation of the line we are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 ;; If line starts with label, calculate label indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (if (> (current-indentation) cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (cperl-calculate-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (if (and parse-start (<= parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (current-indentation))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (defun cperl-calculate-indent-within-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 "Return the indentation amount for line, assuming that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 the current line is to be regarded as part of a block comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (let (end star-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (and (= (following-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (setq end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (defun cperl-to-comment-or-eol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 "Goes to position before comment on the current line, or to end of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 Returns true if comment is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (let (state stop-in cpoint (lim (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (if (re-search-forward "\\=[ \t]*\\(#\\|$\\)" lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (if (eq (preceding-char) ?\#) (progn (backward-char 1) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (while (not stop-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (setq state (parse-partial-sexp (point) lim nil nil nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 ; stop at comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 ;; If fails (beginning-of-line inside sexp), then contains not-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 ;; Do simplified processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;;(if (re-search-forward "[^$]#" lim 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 ;; (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; (skip-chars-backward " \t\n\f" lim))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 ;; (goto-char lim)) ; No `#' at all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ;;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (if (nth 4 state) ; After `#';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ; (nth 2 state) can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 ; beginning of m,s,qq and so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 ; on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (if (nth 2 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (setq cpoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (goto-char (nth 2 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 ((looking-at "\\(s\\|tr\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 lim 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (setq stop-in t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 ((looking-at "\\(m\\|q\\([qxw]\\)?\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 lim 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (setq stop-in t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (t ; It was fair comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (setq stop-in t) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (goto-char (1- cpoint)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (setq stop-in t) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (setq stop-in t)) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (nth 4 state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (defun cperl-find-pods-heres (&optional min max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 "Scans the buffer for POD sections and here-documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 If `cperl-pod-here-fontify' is not-nil after evaluation, will fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 the sections using `cperl-pod-head-face', `cperl-pod-face',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 `cperl-here-face'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (or min (setq min (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (or max (setq max (point-max)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2169 (let (face head-face here-face b e bb tag qtag err b1 e1 argument
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (cperl-pod-here-fontify (eval cperl-pod-here-fontify))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (case-fold-search nil) (inhibit-read-only t) (buffer-undo-list t)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2172 (modified (buffer-modified-p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2173 (after-change-functions nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2174 (search
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2175 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2176 "\\(\\`\n?\\|\n\n\\)="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2177 "\\|"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2178 ;; One extra () before this:
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2179 "<<"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2180 "\\("
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2181 ;; First variant "BLAH" or just ``.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2182 "\\([\"'`]\\)"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2183 "\\([^\"'`\n]*\\)"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2184 "\\3"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2185 "\\|"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2186 ;; Second variant: Identifier or empty
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2187 "\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2188 ;; Check that we do not have <<= or << 30 or << $blah.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2189 "\\([^= \t$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2190 "\\)"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2191 "\\|"
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2192 ;; 1+6 extra () before this:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2193 "^[ \t]*format[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2197 (message "Scanning for pods, formats and here-docs...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (if cperl-pod-here-fontify
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2199 ;; We had evals here, do not know why...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2200 (setq face cperl-pod-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2201 head-face cperl-pod-head-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2202 here-face cperl-here-face))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (remove-text-properties min max '(syntax-type t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 ;; Need to remove face as well...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (goto-char min)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2206 (while (re-search-forward search max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2207 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2208 ((match-beginning 1) ; POD section
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2209 ;; "\\(\\`\n?\\|\n\n\\)="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2210 (if (looking-at "\n*cut\\>")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2211 (progn
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2212 (message "=cut is not preceeded by a pod section")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2213 (setq err (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (beginning-of-line)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2215
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2216 (setq b (point) bb b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2217 (or (re-search-forward "\n\n=cut\\>" max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2218 (message "Cannot find the end of a pod section"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2219 (beginning-of-line 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2220 (setq e (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2221 (put-text-property b e 'in-pod t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2222 (goto-char b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2223 (while (re-search-forward "\n\n[ \t]" e t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2224 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2225 (put-text-property b (point) 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2226 (cperl-put-do-not-fontify b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2227 ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2228 ;; (point) cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2229 (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2230 (re-search-forward "\n\n[^ \t\f\n]" e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2231 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2232 (setq b (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2233 (put-text-property (point) e 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2234 (cperl-put-do-not-fontify (point) e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2235 ;;(put-text-property (max (point-min) (1- (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2236 ;; e cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2237 (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2238 (progn (put-text-property (point) e 'face face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2239 (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2240 (if (looking-at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2241 "=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2242 (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2243 (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2244 'face head-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2245 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2246 ;; One paragraph
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2247 "\n\n=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2248 e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2249 (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2250 (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2251 'face head-face))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2252 (goto-char e)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2253 ;; Here document
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2254 ;; 1 () ahead
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2255 ;; "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\3\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2256 ((match-beginning 2) ; 1 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2257 ;; Abort in comment (_extremely_ simplified):
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2258 (setq b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2259 (if (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2260 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2261 (search-forward "#" b t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2262 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2263 (if (match-beginning 5) ;4 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2264 (setq b1 (match-beginning 5) ; 4 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2265 e1 (match-end 5)) ; 4 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2266 (setq b1 (match-beginning 4) ; 3 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2267 e1 (match-end 4))) ; 3 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2268 (setq tag (buffer-substring b1 e1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2269 qtag (regexp-quote tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2270 (cond (cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2271 (put-text-property b1 e1 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2272 (cperl-put-do-not-fontify b1 e1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2273 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2274 (setq b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2275 (cond ((re-search-forward (concat "^" qtag "$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2276 (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2277 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2278 (put-text-property (match-beginning 0) (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2279 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2280 (cperl-put-do-not-fontify b (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2281 ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2282 ;; (min (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2283 ;; (1+ (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2284 ;; cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2285 (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2286 'face here-face)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2287 (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2288 'syntax-type 'here-doc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2289 (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2290 (t (message "End of here-document `%s' not found." tag)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2291 ;; format
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2292 (t
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2293 ;; 1+6=7 extra () before this:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2294 ;; "^[ \t]*format[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2295 (setq b (point)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2296 name (if (match-beginning 8) ; 7 + 1
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2297 (buffer-substring (match-beginning 8) ; 7 + 1
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2298 (match-end 8)) ; 7 + 1
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2299 ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2300 (setq argument nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 (if cperl-pod-here-fontify
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2302 (while (and (eq (forward-line) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2303 (not (looking-at "^[.;]$")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2304 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2305 ((looking-at "^#")) ; Skip comments
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2306 ((and argument ; Skip argument multi-lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2307 (looking-at "^[ \t]*{"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2308 (forward-sexp 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2309 (setq argument nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2310 (argument ; Skip argument lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2311 (setq argument nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2312 (t ; Format line
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2313 (setq b1 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2314 (setq argument (looking-at "^[^\n]*[@^]"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2315 (end-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2316 (put-text-property b1 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2317 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2318 (cperl-put-do-not-fontify b1 (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2319 (re-search-forward (concat "^[.;]$") max 'toend))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2320 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2321 (if (looking-at "^[.;]$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2322 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2323 (put-text-property (point) (+ (point) 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2324 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2325 (cperl-put-do-not-fontify (point) (+ (point) 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2326 (message "End of format `%s' not found." name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2327 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2328 (put-text-property b (point) 'syntax-type 'format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2329 ;;; (cond ((re-search-forward (concat "^[.;]$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2330 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2331 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2332 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2333 ;;; 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2334 ;;; (cperl-put-do-not-fontify b (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2335 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2336 ;;; 'syntax-type 'format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2337 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2338 ;;; (t (message "End of format `%s' not found." name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2339 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2340 ;;; (while (re-search-forward "\\(\\`\n?\\|\n\n\\)=" max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2341 ;;; (if (looking-at "\n*cut\\>")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2342 ;;; (progn
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
2343 ;;; (message "=cut is not preceeded by a pod section")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2344 ;;; (setq err (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2345 ;;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2346
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2347 ;;; (setq b (point) bb b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2348 ;;; (or (re-search-forward "\n\n=cut\\>" max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2349 ;;; (message "Cannot find the end of a pod section"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2350 ;;; (beginning-of-line 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2351 ;;; (setq e (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2352 ;;; (put-text-property b e 'in-pod t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2353 ;;; (goto-char b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2354 ;;; (while (re-search-forward "\n\n[ \t]" e t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2355 ;;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2356 ;;; (put-text-property b (point) 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2357 ;;; (cperl-put-do-not-fontify b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2358 ;;; ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2359 ;;; ;; (point) cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2360 ;;; (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2361 ;;; (re-search-forward "\n\n[^ \t\f\n]" e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2362 ;;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2363 ;;; (setq b (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2364 ;;; (put-text-property (point) e 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2365 ;;; (cperl-put-do-not-fontify (point) e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2366 ;;; ;;(put-text-property (max (point-min) (1- (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2367 ;;; ;; e cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2368 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2369 ;;; (progn (put-text-property (point) e 'face face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2370 ;;; (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2371 ;;; (if (looking-at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2372 ;;; "=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2373 ;;; (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2374 ;;; (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2375 ;;; 'face head-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2376 ;;; (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2377 ;;; ;; One paragraph
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2378 ;;; "\n\n=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2379 ;;; e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2380 ;;; (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2381 ;;; (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2382 ;;; 'face head-face))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2383 ;;; (goto-char e)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2384 ;;; (goto-char min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2385 ;;; (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2386 ;;; ;; We exclude \n to avoid misrecognition inside quotes.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2387 ;;; "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\2\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2388 ;;; max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2389 ;;; (if (match-beginning 4)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2390 ;;; (setq b1 (match-beginning 4)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2391 ;;; e1 (match-end 4))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2392 ;;; (setq b1 (match-beginning 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2393 ;;; e1 (match-end 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2394 ;;; (setq tag (buffer-substring b1 e1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2395 ;;; qtag (regexp-quote tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2396 ;;; (cond (cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2397 ;;; (put-text-property b1 e1 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2398 ;;; (cperl-put-do-not-fontify b1 e1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2399 ;;; (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2400 ;;; (setq b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2401 ;;; (cond ((re-search-forward (concat "^" qtag "$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2402 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2403 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2404 ;;; (put-text-property (match-beginning 0) (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2405 ;;; 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2406 ;;; (cperl-put-do-not-fontify b (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2407 ;;; ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2408 ;;; ;; (min (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2409 ;;; ;; (1+ (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2410 ;;; ;; cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2411 ;;; (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2412 ;;; 'face here-face)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2413 ;;; (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2414 ;;; 'syntax-type 'here-doc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2415 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2416 ;;; (t (message "End of here-document `%s' not found." tag))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2417 ;;; (goto-char min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2418 ;;; (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2419 ;;; "^[ \t]*format[ \t]*\\(\\([a-zA-Z0-9_]+[ \t]*\\)?\\)=[ \t]*$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2420 ;;; max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2421 ;;; (setq b (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2422 ;;; name (buffer-substring (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2423 ;;; (match-end 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2424 ;;; (cond ((re-search-forward (concat "^[.;]$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2425 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2426 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2427 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2428 ;;; 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2429 ;;; (cperl-put-do-not-fontify b (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2430 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2431 ;;; 'syntax-type 'format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2432 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2433 ;;; (t (message "End of format `%s' not found." name))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2434 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 (if err (goto-char err)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2436 (message "Scan for pods, formats and here-docs completed.")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 (not modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (set-buffer-modified-p nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (defun cperl-backward-to-noncomment (lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 ;; Stops at lim or after non-whitespace that is not in comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (let (stop p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (while (and (not stop) (> (point) (or lim 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (skip-chars-backward " \t\n\f" lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (if (< p (point)) (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (setq stop t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (defun cperl-after-expr-p (&optional lim chars test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 "Returns true if the position is good for start of expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 TEST is the expression to evaluate at the found position. If absent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 CHARS is a string that contains good characters to have before us."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (let (stop p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (while (and (not stop) (> (point) (or lim 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (skip-chars-backward " \t\n\f" lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 ;; Else: last iteration (What to do with labels?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (if (< p (point)) (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (setq stop t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (if test (eval test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (memq (following-char) (append (or chars "{};") nil))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (defun cperl-backward-to-start-of-continued-exp (lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (if (memq (preceding-char) (append ")]}\"'`" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (if (<= (point) lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 (goto-char (1+ lim)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (defvar innerloop-done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 (defvar last-depth nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (defun cperl-indent-exp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 "Simple variant of indentation of continued-sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 Should be slow. Will not indent comment if it starts at `comment-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 or looks like continuation of the comment on the previous line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (let ((tmp-end (progn (end-of-line) (point))) top done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (while (null done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (setq top (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (while (= (nth 0 (parse-partial-sexp (point) tmp-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 -1)) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (setq top (point))) ; Get the outermost parenths in line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (goto-char top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (while (< (point) tmp-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (parse-partial-sexp (point) tmp-end nil t) ; To start-sexp or eol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (or (eolp) (forward-sexp 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (if (> (point) tmp-end) (progn (end-of-line) (setq tmp-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (setq done t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (goto-char tmp-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 (setq tmp-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (cperl-indent-region (point) tmp-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (defun cperl-indent-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 "Simple variant of indentation of region in CPerl mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 Should be slow. Will not indent comment if it starts at `comment-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 or looks like continuation of the comment on the previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 Indents all the lines whose first character is between START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 inclusive."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (let (st comm indent-info old-comm-indent new-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (pm 0) (imenu-scanning-message "Indenting... (%3d%%)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (setq old-comm-indent (and (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 new-comm-indent old-comm-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 (or (bolp) (beginning-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (or (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (message "Indenting... For feedback load `imenu'..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (while (and (<= (point) end) (not (eobp))) ; bol to check start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (and (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (imenu-progress-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 pm (/ (* 100 (- (point) start)) (- end start -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 (setq st (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 indent-info nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ) ; Believe indentation of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (if (and (setq comm (looking-at "[ \t]*#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (or (eq (current-indentation) (or old-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (setq old-comm-indent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (if (and old-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (= (current-indentation) old-comm-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (let ((comment-column new-comm-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (indent-for-comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (cperl-indent-line 'indent-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (or comm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 (if (setq old-comm-indent (and (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (progn (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (skip-chars-backward "#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (setq new-comm-indent (current-column))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (beginning-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 (if (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 (imenu-progress-message pm 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (message nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 (defun cperl-slash-is-regexp (&optional pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 (goto-char (if pos pos (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (not (memq (get-text-property (point) 'face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 '(font-lock-string-face font-lock-comment-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (cperl-after-expr-p nil nil '
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (or (looking-at "[^]a-zA-Z0-9_)}]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (eq (get-text-property (point) 'face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 'font-lock-keyword-face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 ;; Stolen from lisp-mode with a lot of improvements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (defun cperl-fill-paragraph (&optional justify iteration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 "Like \\[fill-paragraph], but handle CPerl comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 If any of the current line is a comment, fill the comment or the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 block of it that point is in, preserving the comment's initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 indentation and initial hashes. Behaves usually outside of comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 ;; Non-nil if the current line contains a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 has-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 ;; If has-comment, the appropriate fill-prefix for the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 comment-fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 ;; Line that contains code and comment (or nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 c spaces len dc (comment-column comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ;; Figure out what kind of comment we are looking at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 ;; A line with nothing but a comment on it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 ((looking-at "[ \t]*#[# \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (setq has-comment t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 comment-fill-prefix (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ;; A line with some code, followed by a comment? Remember that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 ;; semi which starts the comment shouldn't be part of a string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 ;; character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 ((cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (setq has-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (looking-at "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (setq start (point) c (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 comment-fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (concat (make-string (current-column) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (buffer-substring (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 spaces (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (buffer-substring (point) start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 dc (- c (current-column)) len (- start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 start (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (delete-char len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (insert (make-string dc ?-)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (if (not has-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (fill-paragraph justify) ; Do the usual thing outside of comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ;; Narrow to include only the comment, and then fill the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 ;; Find the first line we should include in the region to fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (if start (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (while (and (zerop (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 ;; We may have gone to far. Go forward again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (or (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 ;; Find the beginning of the first line past the region to fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (while (progn (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 ;; Remove existing hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 (while (progn (forward-line 1) (< (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 (and (looking-at "#+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (delete-char (- (match-end 0) (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 ;; Lines with only hashes on them can be paragraph boundaries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 (let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 (paragraph-separate (concat paragraph-start "\\|^[ \t#]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 (fill-prefix comment-fill-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (fill-paragraph justify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 (if (and start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (if (> dc 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 (progn (delete-char dc) (insert spaces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 (if (or (= (current-column) c) iteration) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 (setq comment-column c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 ;; Repeat once more, flagging as iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 (cperl-fill-paragraph justify t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 (defun cperl-do-auto-fill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 ;; Break out if the line is short enough
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (if (> (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 (let ((c (save-excursion (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (cperl-to-comment-or-eol) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (s (memq (following-char) '(?\ ?\t))) marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (if (>= c (point)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (setq marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (cperl-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (goto-char marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 ;; Is not enough, sometimes marker is a start of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (if (bolp) (progn (re-search-forward "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (goto-char (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 ;; Following space could have gone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (if (or (not s) (memq (following-char) '(?\ ?\t))) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 ;; Previous space could have gone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 (or (memq (preceding-char) '(?\ ?\t)) (insert " "))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (defvar imenu-example--function-name-regexp-perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 "^\\([ \t]*\\(sub\\|package\\)[ \t\n]+\\([a-zA-Z_0-9:']+\\)[ \t]*\\|=head\\([12]\\)[ \t]+\\([^\n]+\\)$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2684 (defun cperl-imenu-addback (lst &optional isback name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2685 ;; We suppose that the lst is a DAG, unless the first element only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2686 ;; loops back, and ISBACK is set. Thus this function cannot be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2687 ;; applied twice without ISBACK set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2688 (cond ((not cperl-imenu-addback) lst)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2689 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2690 (or name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2691 (setq name "+++BACK+++"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2692 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2693 (if (and (listp elt) (listp (cdr elt)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2694 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2695 ;; In the other order it goes up
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2696 ;; one level only ;-(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2697 (setcdr elt (cons (cons name lst)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2698 (cdr elt)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2699 (cperl-imenu-addback (cdr elt) t name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2700 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2701 (if isback (cdr lst) lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2702 lst)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2703
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 (defun imenu-example--create-perl-index (&optional regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2708 (index-meth-alist '()) meth
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 packages ends-ranges p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 (prev-pos 0) char fchar index index1 name (end-range 0) package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (imenu-progress-message prev-pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 ;; Search for the function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2714 (progn ;;save-match-data
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 (or regexp imenu-example--function-name-regexp-perl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (imenu-progress-message prev-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 ;;(backward-up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 ((match-beginning 2) ; package or sub
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 (goto-char (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (setq fchar (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2726 (setq char (following-char) meth nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 (while (and ends-ranges (>= p (car ends-ranges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 ;; delete obsolete entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 (setq ends-ranges (cdr ends-ranges) packages (cdr packages)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (setq package (or (car packages) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 end-range (or (car ends-ranges) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (if (eq fchar ?p)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2734 (setq name (buffer-substring (match-beginning 3) (match-end 3))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2735 name (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2736 (set-text-properties 0 (length name) nil name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2737 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2738 package (concat name "::")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2739 name (concat "package " name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2740 end-range
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2741 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2742 (parse-partial-sexp (point) (point-max) -1) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2743 ends-ranges (cons end-range ends-ranges)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2744 packages (cons package packages)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;; Skip this function name if it is a prototype declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 (if (and (eq fchar ?s) (eq char ?\;)) nil
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2748 (setq index (imenu-example--name-and-position))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 (if (eq fchar ?p) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2751 (set-text-properties 0 (length name) nil name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2752 (cond ((string-match "[:']" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2753 (setq meth t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2754 ((> p end-range) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2755 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2756 (setq name (concat package name) meth t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 (setcar index name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 (if (eq fchar ?p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (push index index-pack-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (push index index-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2761 (if meth (push index index-meth-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 (push index index-unsorted-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 (t ; Pod section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 ;; (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (setq index (imenu-example--name-and-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 name (buffer-substring (match-beginning 5) (match-end 5)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2767 (set-text-properties 0 (length name) nil name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 (if (eq (char-after (match-beginning 4)) ?2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 (setq name (concat " " name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (setcar index name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 (setq index1 (cons (concat "=" name) (cdr index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (push index index-pod-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 (push index1 index-unsorted-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 (imenu-progress-message prev-pos 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 (setq index-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 (if (default-value 'imenu-sort-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 (sort index-alist (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 (nreverse index-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 (and index-pod-alist
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2780 (push (cons "+POD headers+..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 (nreverse index-pod-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 index-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2783 (and (or index-pack-alist index-meth-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2784 (let ((lst index-pack-alist) hier-list pack elt group name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2785 ;; Remove "package ", reverse and uniquify.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2786 (while lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2787 (setq elt (car lst) lst (cdr lst) name (substring (car elt) 8))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2788 (if (assoc name hier-list) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2789 (setq hier-list (cons (cons name (cdr elt)) hier-list))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2790 (setq lst index-meth-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2791 (while lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2792 (setq elt (car lst) lst (cdr lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2793 (cond ((string-match "\\(::\\|'\\)[_a-zA-Z0-9]+$" (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2794 (setq pack (substring (car elt) 0 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2795 (if (setq group (assoc pack hier-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2796 (if (listp (cdr group))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2797 ;; Have some functions already
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2798 (setcdr group
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2799 (cons (cons (substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2800 (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2801 (+ 2 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2802 (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2803 (cdr group)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2804 (setcdr group (list (cons (substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2805 (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2806 (+ 2 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2807 (cdr elt)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2808 (setq hier-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2809 (cons (cons pack
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2810 (list (cons (substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2811 (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2812 (+ 2 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2813 (cdr elt))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2814 hier-list))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2815 (push (cons "+Hierarchy+..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2816 hier-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2817 index-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 (and index-pack-alist
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2819 (push (cons "+Packages+..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 (nreverse index-pack-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (and (or index-pack-alist index-pod-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 index-unsorted-alist
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2825 (push (cons "+Unsorted List+..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (nreverse index-unsorted-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 index-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2828 (cperl-imenu-addback index-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 (defvar cperl-compilation-error-regexp-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 ;; This look like a paranoiac regexp: could anybody find a better one? (which WORK).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 2 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 "Alist that specifies how to match errors in perl output.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 (if (fboundp 'eval-after-load)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (eval-after-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 "mode-compile"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 '(setq perl-compilation-error-regexp-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 cperl-compilation-error-regexp-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (defvar cperl-faces-init nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 (defun cperl-windowed-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 "Initialization under windowed version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 (add-hook 'font-lock-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (if (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 (eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 (eq major-mode 'cperl-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (or cperl-faces-init (cperl-init-faces))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (defvar perl-font-lock-keywords-1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 "Additional expressions to highlight in Perl mode. Minimal set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 (defvar perl-font-lock-keywords nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 "Additional expressions to highlight in Perl mode. Default set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 (defvar perl-font-lock-keywords-2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 "Additional expressions to highlight in Perl mode. Maximal set")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 (defun cperl-init-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (require 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (and (fboundp 'font-lock-fontify-anchored-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 (message "You have an obsolete package `font-lock-extra'. Install `choose-color'."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (let (t-font-lock-keywords t-font-lock-keywords-1 font-lock-anchored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 ;;(defvar cperl-font-lock-enhanced nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 ;; "Set to be non-nil if font-lock allows active highlights.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 (if (fboundp 'font-lock-fontify-anchored-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (setq font-lock-anchored t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 "\\(^\\|[^$@%&\\]\\)\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 '("if" "until" "while" "elsif" "else" "unless" "for"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 "foreach" "continue" "exit" "die" "last" "goto" "next"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 "redo" "return" "local" "exec" "sub" "do" "dump" "use"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 "require" "package" "eval" "my" "BEGIN" "END")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 "\\|") ; Flow control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 "\\)\\>") 2) ; was "\\)[ \n\t;():,\|&]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 ; In what follows we use `type' style
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2890 ; for overwritable builtins
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 "\\(^\\|[^$@%&\\]\\)\\<\\("
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2894 ;; "CORE" "__FILE__" "__LINE__" "abs" "accept" "alarm"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2895 ;; "and" "atan2" "bind" "binmode" "bless" "caller"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2896 ;; "chdir" "chmod" "chown" "chr" "chroot" "close"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2897 ;; "closedir" "cmp" "connect" "continue" "cos" "crypt"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2898 ;; "dbmclose" "dbmopen" "die" "dump" "endgrent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2899 ;; "endhostent" "endnetent" "endprotoent" "endpwent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2900 ;; "endservent" "eof" "eq" "exec" "exit" "exp" "fcntl"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2901 ;; "fileno" "flock" "fork" "formline" "ge" "getc"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2902 ;; "getgrent" "getgrgid" "getgrnam" "gethostbyaddr"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2903 ;; "gethostbyname" "gethostent" "getlogin"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2904 ;; "getnetbyaddr" "getnetbyname" "getnetent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2905 ;; "getpeername" "getpgrp" "getppid" "getpriority"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2906 ;; "getprotobyname" "getprotobynumber" "getprotoent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2907 ;; "getpwent" "getpwnam" "getpwuid" "getservbyname"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2908 ;; "getservbyport" "getservent" "getsockname"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2909 ;; "getsockopt" "glob" "gmtime" "gt" "hex" "index" "int"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2910 ;; "ioctl" "join" "kill" "lc" "lcfirst" "le" "length"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2911 ;; "link" "listen" "localtime" "log" "lstat" "lt"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2912 ;; "mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "ne"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2913 ;; "not" "oct" "open" "opendir" "or" "ord" "pack" "pipe"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2914 ;; "quotemeta" "rand" "read" "readdir" "readline"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2915 ;; "readlink" "readpipe" "recv" "ref" "rename" "require"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2916 ;; "reset" "reverse" "rewinddir" "rindex" "rmdir" "seek"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2917 ;; "seekdir" "select" "semctl" "semget" "semop" "send"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2918 ;; "setgrent" "sethostent" "setnetent" "setpgrp"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2919 ;; "setpriority" "setprotoent" "setpwent" "setservent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2920 ;; "setsockopt" "shmctl" "shmget" "shmread" "shmwrite"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2921 ;; "shutdown" "sin" "sleep" "socket" "socketpair"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2922 ;; "sprintf" "sqrt" "srand" "stat" "substr" "symlink"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2923 ;; "syscall" "sysread" "system" "syswrite" "tell"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2924 ;; "telldir" "time" "times" "truncate" "uc" "ucfirst"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2925 ;; "umask" "unlink" "unpack" "utime" "values" "vec"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2926 ;; "wait" "waitpid" "wantarray" "warn" "write" "x" "xor"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 "a\\(bs\\|ccept\\|tan2\\|larm\\|nd\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 "b\\(in\\(d\\|mode\\)\\|less\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 "c\\(h\\(r\\(\\|oot\\)\\|dir\\|mod\\|own\\)\\|aller\\|rypt\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 "lose\\(\\|dir\\)\\|mp\\|o\\(s\\|n\\(tinue\\|nect\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 "CORE\\|d\\(ie\\|bm\\(close\\|open\\)\\|ump\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 "e\\(x\\(p\\|it\\|ec\\)\\|q\\|nd\\(p\\(rotoent\\|went\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 "hostent\\|servent\\|netent\\|grent\\)\\|of\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 "f\\(ileno\\|cntl\\|lock\\|or\\(k\\|mline\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 "g\\(t\\|lob\\|mtime\\|e\\(\\|t\\(p\\(pid\\|r\\(iority\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 "oto\\(byn\\(ame\\|umber\\)\\|ent\\)\\)\\|eername\\|w"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 "\\(uid\\|ent\\|nam\\)\\|grp\\)\\|host\\(by\\(addr\\|name\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 "ent\\)\\|s\\(erv\\(by\\(port\\|name\\)\\|ent\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 "ock\\(name\\|opt\\)\\)\\|c\\|login\\|net\\(by\\(addr\\|name\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 "ent\\)\\|gr\\(ent\\|nam\\|gid\\)\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 "hex\\|i\\(n\\(t\\|dex\\)\\|octl\\)\\|join\\|kill\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 "l\\(i\\(sten\\|nk\\)\\|stat\\|c\\(\\|first\\)\\|t\\|e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 "\\(\\|ngth\\)\\|o\\(caltime\\|g\\)\\)\\|m\\(sg\\(rcv\\|snd\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 "ctl\\|get\\)\\|kdir\\)\\|n\\(e\\|ot\\)\\|o\\(pen\\(\\|dir\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 "r\\(\\|d\\)\\|ct\\)\\|p\\(ipe\\|ack\\)\\|quotemeta\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 "r\\(index\\|and\\|mdir\\|e\\(quire\\|ad\\(pipe\\|\\|lin"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 "\\(k\\|e\\)\\|dir\\)\\|set\\|cv\\|verse\\|f\\|winddir\\|name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 "\\)\\)\\|s\\(printf\\|qrt\\|rand\\|tat\\|ubstr\\|e\\(t\\(p\\(r"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 "\\(iority\\|otoent\\)\\|went\\|grp\\)\\|hostent\\|s\\(ervent\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 "ockopt\\)\\|netent\\|grent\\)\\|ek\\(\\|dir\\)\\|lect\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 "m\\(ctl\\|op\\|get\\)\\|nd\\)\\|h\\(utdown\\|m\\(read\\|ctl\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 "write\\|get\\)\\)\\|y\\(s\\(read\\|call\\|tem\\|write\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 "mlink\\)\\|in\\|leep\\|ocket\\(pair\\|\\)\\)\\|t\\(runcate\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 "ell\\(\\|dir\\)\\|ime\\(\\|s\\)\\)\\|u\\(c\\(\\|first\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 "time\\|mask\\|n\\(pack\\|link\\)\\)\\|v\\(alues\\|ec\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 "w\\(a\\(rn\\|it\\(pid\\|\\)\\|ntarray\\)\\|rite\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 "x\\(\\|or\\)\\|__\\(FILE__\\|LINE__\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 "\\)\\>") 2 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 ;; In what follows we use `other' style
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2960 ;; for nonoverwritable builtins
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2961 ;; Somehow 's', 'm' are not auto-generated???
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 "\\(^\\|[^$@%&\\]\\)\\<\\("
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2965 ;; "AUTOLOAD" "BEGIN" "DESTROY" "END" "__END__" "chomp"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2966 ;; "chop" "defined" "delete" "do" "each" "else" "elsif"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2967 ;; "eval" "exists" "for" "foreach" "format" "goto"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2968 ;; "grep" "if" "keys" "last" "local" "map" "my" "next"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2969 ;; "no" "package" "pop" "pos" "print" "printf" "push"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2970 ;; "q" "qq" "qw" "qx" "redo" "return" "scalar" "shift"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2971 ;; "sort" "splice" "split" "study" "sub" "tie" "tr"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2972 ;; "undef" "unless" "unshift" "untie" "until" "use"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2973 ;; "while" "y"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 "AUTOLOAD\\|BEGIN\\|cho\\(p\\|mp\\)\\|d\\(e\\(fined\\|lete\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 "o\\)\\|DESTROY\\|e\\(ach\\|val\\|xists\\|ls\\(e\\|if\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 "END\\|for\\(\\|each\\|mat\\)\\|g\\(rep\\|oto\\)\\|if\\|keys\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 "l\\(ast\\|ocal\\)\\|m\\(ap\\|y\\)\\|n\\(ext\\|o\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 "p\\(ackage\\|rint\\(\\|f\\)\\|ush\\|o\\(p\\|s\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 "q\\(\\|q\\|w\\|x\\)\\|re\\(turn\\|do\\)\\|s\\(pli\\(ce\\|t\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 "calar\\|tudy\\|ub\\|hift\\|ort\\)\\|t\\(r\\|ie\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 "u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 "while\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 "\\|[sm]" ; Added manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 "\\)\\>") 2 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 ;; (mapconcat 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 ;; "#include" "#define" "#undef")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 ;; "\\|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 '("-[rwxoRWXOezsfdlpSbctugkTBMAC]\\>\\([ \t]+_\\>\\)?" 0
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2990 font-lock-function-name-face keep) ; Not very good, triggers at "[a-z]"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 '("\\<sub[ \t]+\\([^ \t{;]+\\)[ \t]*[{\n]" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t;]" ; require A if B;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 2 font-lock-function-name-face)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2995 '("^[ \t]*format[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t]*=[ \t]*$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2996 1 font-lock-function-name-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 (cond ((featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (2 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (0 '(restart 2 t)))) ; To highlight $a{bc}{ef}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 (font-lock-anchored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 (2 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 (1 font-lock-string-face t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 (t '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 2 font-lock-string-face t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 '("[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 '("^[ \t]*\\([a-zA-Z0-9_]+[ \t]*:\\)[ \t]*\\($\\|{\\|\\<\\(until\\|while\\|for\\(each\\)?\\|do\\)\\>\\)" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 font-lock-reference-face) ; labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 '("\\<\\(continue\\|next\\|last\\|redo\\|goto\\)\\>[ \t]+\\([a-zA-Z0-9_:]+\\)" ; labels as targets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 2 font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 (cond ((featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 (3 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 (4 '(another 4 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 (1 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 (2 '(restart 2 nil) nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 nil t))) ; local variables, multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 (font-lock-anchored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (3 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 (1 font-lock-variable-name-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 (t '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 3 font-lock-variable-name-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 '("\\<for\\(each\\)?[ \t]*\\(\\$[a-zA-Z_][a-zA-Z_0-9]*\\)[ \t]*("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 2 font-lock-variable-name-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 t-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 (and (fboundp 'turn-on-font-lock) ; Check for newer font-lock
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3036 (not cperl-xemacs-p) ; not yet as of XEmacs 19.12
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3037 '(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3038 ("\\(\\([@%]\\|\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3039 (if (eq (char-after (match-beginning 2)) ?%)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3040 font-lock-other-emphasized-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3041 font-lock-emphasized-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3042 t) ; arrays and hashes
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3043 ("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 (if (= (- (match-end 2) (match-beginning 2)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (if (eq (char-after (match-beginning 3)) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 font-lock-emphasized-face) ; arrays and hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 font-lock-variable-name-face) ; Just to put something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 ;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 ;;; Too much noise from \s* @s[ and friends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 ;;(3 font-lock-function-name-face t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 ;;(4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 ;; (if (cperl-slash-is-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 ;; font-lock-function-name-face 'default) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 (setq perl-font-lock-keywords-1 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 perl-font-lock-keywords perl-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 perl-font-lock-keywords-2 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 t-font-lock-keywords-1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 (if (fboundp 'ps-print-buffer) (cperl-ps-print-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 (if (or (featurep 'choose-color) (featurep 'font-lock-extra))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 (font-lock-require-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 ;; Color-light Color-dark Gray-light Gray-dark Mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (list 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 ["Firebrick" "OrangeRed" "DimGray" "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (list 'font-lock-string-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 ["RosyBrown" "LightSalmon" "Gray50" "LightGray"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 (list 'font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 ["Purple" "LightSteelBlue" "DimGray" "Gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 (list 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 "Blue" "LightSkyBlue" "Gray50" "LightGray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 (cdr (assq 'background-color ; if mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (frame-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 nil nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (cdr (assq 'foreground-color ; if mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 (frame-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (list 'font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 ["DarkGoldenrod" "LightGoldenrod" "DimGray" "Gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (list 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 ["DarkOliveGreen" "PaleGreen" "DimGray" "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 (list 'font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 ["CadetBlue" "Aquamarine" "Gray50" "LightGray"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (list 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 ["chartreuse3" ("orchid1" "orange")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 [nil nil "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 [nil nil nil t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 [nil nil t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 (list 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 ["blue" "yellow" nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 ["lightyellow2" ("navy" "os2blue" "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 (list 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 ["red" "red" nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 ["lightyellow2" ("navy" "os2blue" "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (defvar cperl-guessed-background nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 "Display characteristics as guessed by cperl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 (or (fboundp 'x-color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (defalias 'x-color-defined-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (cond ((fboundp 'color-defined-p) 'color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 ;; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 ((fboundp 'valid-color-name-p) 'valid-color-name-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 ;; XEmacs 19.11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 (t 'x-valid-color-name-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 (defvar font-lock-reference-face 'font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 (defvar font-lock-variable-name-face 'font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 (or (boundp 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 "Face to use for data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 (or (boundp 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 (defconst font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 "Face to use for data types from another group.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3162 (if (not cperl-xemacs-p) nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 (or (boundp 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 (defconst font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 "Face to use for comments.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 (or (boundp 'font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (defconst font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 'font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 "Face to use for keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 (or (boundp 'font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 (defconst font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 "Face to use for function names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 ;;(if (featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (if (face-equal font-lock-type-face font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 "Face to use for basic data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 ;;; (if (fboundp 'eval-after-load)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 ;;; (eval-after-load "font-lock"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 ;;; '(if (face-equal font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 ;;; font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 ;;; (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 ;;; 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 ;;; "Face to use for basic data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 ;;; ))) ; This does not work :-( Why?!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 ;;; ; Workaround: added to font-lock-m-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 ;;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 (or (boundp 'font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 (defconst font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 "Face to use for another type of emphasizing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (or (boundp 'font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 (defconst font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 "Face to use for emphasizing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 ;; Here we try to guess background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (let ((background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 (if (boundp 'font-lock-background-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 font-lock-background-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 'light))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 (face-list (and (fboundp 'face-list) (face-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 is-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 (fset 'is-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (cond ((fboundp 'find-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (symbol-function 'find-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (face-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (function (lambda (face) (member face face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (function (lambda (face) (boundp face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 (defvar cperl-guessed-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (if (and (boundp 'font-lock-display-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (eq font-lock-display-type 'grayscale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 'gray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 background)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 "Background as guessed by CPerl mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (if (is-face 'font-lock-type-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (copy-face 'default 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 (set-face-foreground 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 (if (x-color-defined-p "seagreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 "seagreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 "sea green")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 (set-face-foreground 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 (if (x-color-defined-p "os2pink")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 "os2pink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 "pink")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 (set-face-background 'font-lock-type-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 (if (is-face 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (copy-face 'font-lock-type-face 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 (set-face-foreground 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 (if (x-color-defined-p "chartreuse3")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 "chartreuse3"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 "chartreuse")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 (set-face-foreground 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 (if (x-color-defined-p "orchid1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 "orchid1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 "orange")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 (if (is-face 'font-lock-other-emphasized-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (copy-face 'bold-italic 'font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (set-face-background 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 (if (x-color-defined-p "lightyellow2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 "lightyellow2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 (if (x-color-defined-p "lightyellow")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 "lightyellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 "light yellow"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 (set-face-background 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 (if (x-color-defined-p "navy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 (if (x-color-defined-p "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 "darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 "dark green"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 (t (set-face-background 'font-lock-other-emphasized-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 (if (is-face 'font-lock-emphasized-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 (copy-face 'bold 'font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 (set-face-background 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 (if (x-color-defined-p "lightyellow2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 "lightyellow2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 "lightyellow")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 (set-face-background 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (if (x-color-defined-p "navy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 (if (x-color-defined-p "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 "darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 "dark green"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 (t (set-face-background 'font-lock-emphasized-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (if (is-face 'font-lock-variable-name-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 (copy-face 'italic 'font-lock-variable-name-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 (if (is-face 'font-lock-reference-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 (copy-face 'italic 'font-lock-reference-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 (setq cperl-faces-init t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 (defun cperl-ps-print-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 "Initialization of `ps-print' components for faces used in CPerl."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 ;; Guard against old versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 (defvar ps-underlined-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 (defvar ps-bold-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 (defvar ps-italic-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 (setq ps-bold-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 (append '(font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 ps-bold-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 (setq ps-italic-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (append '(font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 ps-italic-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 (setq ps-underlined-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 (append '(font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 font-lock-other-type-face font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 ps-underlined-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 (cons 'font-lock-type-face ps-underlined-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 (if (cperl-enable-font-lock) (cperl-windowed-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 (defun cperl-set-style (style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 "Set CPerl-mode variables to use one of several different indentation styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 The arguments are a string representing the desired style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 Available styles are GNU, K&R, BSD and Whitesmith."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 (let ((list (mapcar (function (lambda (elt) (list (car elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 c-style-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 (list (completing-read "Enter style: " list nil 'insist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 (let ((style (cdr (assoc style c-style-alist))) setting str sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 (while style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 (setq setting (car style) style (cdr style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 (setq str (symbol-name (car setting)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 (and (string-match "^c-" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 (setq str (concat "cperl-" (substring str 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 (setq sym (intern-soft str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 (set sym (cdr setting))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 (defun cperl-check-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 (require 'mode-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 (let ((perl-dbg-flags "-wc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 (mode-compile)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3348 (defun cperl-info-buffer (type)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3349 ;; Returns buffer with documentation. Creates if missing.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3350 ;; If TYPE, this vars buffer.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3351 ;; Special care is taken to not stomp over an existing info buffer
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3352 (let* ((bname (if type "*info-perl-var*" "*info-perl*"))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3353 (info (get-buffer bname))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3354 (oldbuf (get-buffer "*info*")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 (if info info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 ;; Get Info running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 (require 'info)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3359 (cond (oldbuf
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3360 (set-buffer oldbuf)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3361 (rename-buffer "*info-perl-tmp*")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 (info))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3364 (Info-find-node cperl-info-page (if type "perlvar" "perlfunc"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 (set-buffer "*info*")
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3366 (rename-buffer bname)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3367 (cond (oldbuf
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3368 (set-buffer "*info-perl-tmp*")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3369 (rename-buffer "*info*")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3370 (set-buffer bname)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3371 (make-variable-buffer-local 'window-min-height)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3372 (setq window-min-height 2)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 (defun cperl-word-at-point (&optional p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 ;; Returns the word at point or at P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 (if p (goto-char p))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3379 (or (cperl-word-at-point-hard)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3380 (progn
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3381 (require 'etags)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3382 (funcall (or (and (boundp 'find-tag-default-function)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3383 find-tag-default-function)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3384 (get major-mode 'find-tag-default-function)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3385 ;; XEmacs 19.12 has `find-tag-default-hook'; it is
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3386 ;; automatically used within `find-tag-default':
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3387 'find-tag-default))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 (defun cperl-info-on-command (command)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3390 "Shows documentation for Perl command in other window.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3391 If perl-info buffer is shown in some frame, uses this frame.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3392 Customized by setting variables `cperl-shrink-wrap-info-frame',
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3393 `cperl-max-help-size'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 (let* ((default (cperl-word-at-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 (read (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 (format "Find doc for Perl function (default %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 (list (if (equal read "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 read))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 (let ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 (cmd-desc (concat "^" (regexp-quote command) "[^a-zA-Z_0-9]")) ; "tr///"
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3405 pos isvar height iniheight frheight buf win fr1 fr2 iniwin not-loner
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3406 max-height char-height buf-list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 (if (string-match "^-[a-zA-Z]$" command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 (setq cmd-desc "^-X[ \t\n]"))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3409 (setq isvar (string-match "^[$@%]" command)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3410 buf (cperl-info-buffer isvar)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3411 iniwin (selected-window)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3412 fr1 (window-frame iniwin))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3413 (set-buffer buf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 (beginning-of-buffer)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3415 (or isvar
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3416 (progn (re-search-forward "^-X[ \t\n]")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3417 (forward-line -1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 (if (re-search-forward cmd-desc nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 (progn
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3420 ;; Go back to beginning of the group (ex, for qq)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3421 (if (re-search-backward "^[ \t\n\f]")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3422 (forward-line 1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3423 (beginning-of-line)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3424 ;; Get some of
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3425 (setq pos (point)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3426 buf-list (list buf "*info-perl-var*" "*info-perl*"))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3427 (while (and (not win) buf-list)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3428 (setq win (get-buffer-window (car buf-list) t))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3429 (setq buf-list (cdr buf-list)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3430 (or (not win)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3431 (eq (window-buffer win) buf)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3432 (set-window-buffer win buf))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3433 (and win (setq fr2 (window-frame win)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3434 (if (or (not fr2) (eq fr1 fr2))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3435 (pop-to-buffer buf)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3436 (special-display-popup-frame buf) ; Make it visible
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3437 (select-window win))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3438 (goto-char pos) ; Needed (?!).
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3439 ;; Resize
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3440 (setq iniheight (window-height)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3441 frheight (frame-height)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3442 not-loner (< iniheight (1- frheight))) ; Are not alone
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3443 (cond ((if not-loner cperl-max-help-size
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3444 cperl-shrink-wrap-info-frame)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3445 (setq height
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3446 (+ 2
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3447 (count-lines
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3448 pos
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3449 (save-excursion
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3450 (if (re-search-forward
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3451 "^[ \t][^\n]*\n+\\([^ \t\n\f]\\|\\'\\)" nil t)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3452 (match-beginning 0) (point-max)))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3453 max-height
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3454 (if not-loner
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3455 (/ (* (- frheight 3) cperl-max-help-size) 100)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3456 (setq char-height (frame-char-height))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3457 ;; Non-functioning under OS/2:
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3458 (if (eq char-height 1) (setq char-height 18))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3459 ;; Title, menubar, + 2 for slack
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3460 (- (/ (x-display-pixel-height) char-height) 4)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3461 ))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3462 (if (> height max-height) (setq height max-height))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3463 ;;(message "was %s doing %s" iniheight height)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3464 (if not-loner
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3465 (enlarge-window (- height iniheight))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3466 (set-frame-height (window-frame win) (1+ height)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 (set-window-start (selected-window) pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 (message "No entry for %s found." command))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3469 ;;(pop-to-buffer buffer)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3470 (select-window iniwin)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 (defun cperl-info-on-current-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 "Shows documentation for Perl command at point in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 (cperl-info-on-command (cperl-word-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 (defun cperl-imenu-info-imenu-search ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 (if (looking-at "^-X[ \t\n]") nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 "^\n\\([-a-zA-Z]+\\)[ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 (defun cperl-imenu-info-imenu-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 (defun cperl-imenu-on-info ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 (let* ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 imenu-prev-index-position-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 imenu-extract-index-name-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 (index-item (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 (save-window-excursion
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3495 (set-buffer (cperl-info-buffer nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 (setq imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 'imenu-default-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 imenu-prev-index-position-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499 'cperl-imenu-info-imenu-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 imenu-extract-index-name-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 'cperl-imenu-info-imenu-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 (imenu-choose-buffer-index)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 (and index-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 (pop-to-buffer "*info-perl*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 ((markerp (cdr index-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 (goto-char (marker-position (cdr index-item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511 (goto-char (cdr index-item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512 (set-window-start (selected-window) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513 (pop-to-buffer buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515 (defun cperl-lineup (beg end &optional step minshift)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516 "Lineup construction in a region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 Beginning of region should be at the start of a construction.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3518 All first occurrences of this construction in the lines that are
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519 partially contained in the region are lined up at the same column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 MINSHIFT is the minimal amount of space to insert before the construction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 STEP is the tabwidth to position constructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 If STEP is `nil', `cperl-lineup-step' will be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 \(or `cperl-indent-level', if `cperl-lineup-step' is `nil').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525 Will not move the position at the start to the left."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 (let (search col tcol seen b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 (setq end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 (skip-chars-forward " \t\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 (setq beg (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 (indent-region beg end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 (setq col (current-column))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3538 (if (looking-at "[a-zA-Z0-9_]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3539 (if (looking-at "\\<[a-zA-Z0-9_]+\\>")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 (setq search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541 (concat "\\<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544 (match-end 0))) "\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 (error "Cannot line up in a middle of the word"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546 (if (looking-at "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 (error "Cannot line up end of line"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548 (setq search (regexp-quote (char-to-string (following-char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 (setq step (or step cperl-lineup-step cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 (or minshift (setq minshift 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 (re-search-forward search end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 (goto-char (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 (setq tcol (current-column) seen t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 (if (> tcol col) (setq col tcol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 (or seen
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3559 (error "The construction to line up occurred only once"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 (setq col (+ col minshift))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 (if (/= (% col step) 0) (setq step (* step (1+ (/ col step)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 (setq e (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 (delete-region (point) e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 (indent-to-column col); (make-string (- col (current-column)) ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 (re-search-forward search end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 (goto-char (match-beginning 0)))))))) ; No body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 (defun cperl-etags (&optional add all files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 "Run etags with appropriate options for Perl files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 If optional argument ALL is `recursive', will process Perl files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 in subdirectories too."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 (let ((cmd "etags")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 (args '("-l" "none" "-r" "/\\<\\(package\\|sub\\)[ \\t]+\\(\\([a-zA-Z0-9:_]*::\\)?\\([a-zA-Z0-9_]+\\)[ \\t]*\\([{#]\\|$\\)\\)/\\4/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 res)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 (if add (setq args (cons "-a" args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 (or files (setq files (list buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585 ((eq all 'recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 ;;(error "Not implemented: recursive")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 (setq args (append (list "-e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 "sub wanted {push @ARGV, $File::Find::name if /\\.[Pp][Llm]$/}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 use File::Find;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 find(\\&wanted, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 exec @ARGV;"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 cmd) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 cmd "perl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 (all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 ;;(error "Not implemented: all")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 (setq args (append (list "-e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597 "push @ARGV, <*.PL *.pl *.pm>;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 exec @ARGV;"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 cmd) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 cmd "perl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 (setq args (append args files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 (setq res (apply 'call-process cmd nil nil nil args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 (or (eq res 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 (message "etags returned \"%s\"" res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 (defun cperl-toggle-auto-newline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 "Toggle the state of `cperl-auto-newline'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610 (setq cperl-auto-newline (not cperl-auto-newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 (message "Newlines will %sbe auto-inserted now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 (if cperl-auto-newline "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 (defun cperl-toggle-abbrev ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 "Toggle the state of automatic keyword expansion in CPerl mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 (abbrev-mode (if abbrev-mode 0 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 (message "Perl control structure will %sbe auto-inserted now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 (if abbrev-mode "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 (defun cperl-toggle-electric ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 "Toggle the state of parentheses doubling in CPerl mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 (setq cperl-electric-parens (if (cperl-val 'cperl-electric-parens) 'null t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 (message "Parentheses will %sbe auto-doubled now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627 (if (cperl-val 'cperl-electric-parens) "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3629 ;;;; Tags file creation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3630
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3631 (defvar cperl-tmp-buffer " *cperl-tmp*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3632
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3633 (defun cperl-setup-tmp-buf ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3634 (set-buffer (get-buffer-create cperl-tmp-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3635 (set-syntax-table cperl-mode-syntax-table)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3636 (buffer-disable-undo)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3637 (auto-fill-mode 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3638
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3639 (defun cperl-xsub-scan ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3640 (require 'cl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3641 (require 'imenu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3642 (let ((index-alist '())
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3643 (prev-pos 0) index index1 name package prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3644 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3645 (imenu-progress-message prev-pos 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3646 ;; Search for the function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3647 (progn ;;save-match-data
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3648 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3649 "^\\([ \t]*MODULE\\>[^\n]*\\<PACKAGE[ \t]*=[ \t]*\\([a-zA-Z_][a-zA-Z_0-9:]*\\)\\>\\|\\([a-zA-Z_][a-zA-Z_0-9]*\\)(\\|[ \t]*BOOT:\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3650 nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3651 (imenu-progress-message prev-pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3652 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3653 ((match-beginning 2) ; SECTION
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3654 (setq package (buffer-substring (match-beginning 2) (match-end 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3655 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3656 (skip-chars-forward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3657 (forward-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3658 (if (looking-at "[^\n]*\\<PREFIX[ \t]*=[ \t]*\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\>")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3659 (setq prefix (buffer-substring (match-beginning 1) (match-end 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3660 (setq prefix nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3661 ((not package) nil) ; C language section
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3662 ((match-beginning 3) ; XSUB
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3663 (goto-char (1+ (match-beginning 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3664 (setq index (imenu-example--name-and-position))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3665 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3666 (if (and prefix (string-match (concat "^" prefix) name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3667 (setq name (substring name (length prefix))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3668 (cond ((string-match "::" name) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3669 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3670 (setq index1 (cons (concat package "::" name) (cdr index)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3671 (push index1 index-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3672 (setcar index name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3673 (push index index-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3674 (t ; BOOT: section
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3675 ;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3676 (setq index (imenu-example--name-and-position))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3677 (setcar index (concat package "::BOOT:"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3678 (push index index-alist)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3679 (imenu-progress-message prev-pos 100)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3680 ;;(setq index-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3681 ;; (if (default-value 'imenu-sort-function)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3682 ;; (sort index-alist (default-value 'imenu-sort-function))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3683 ;; (nreverse index-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3684 index-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3685
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3686 (defun cperl-find-tags (file xs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3687 (let (ind (b (get-buffer cperl-tmp-buffer)) lst elt pos ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3688 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3689 (if b (set-buffer b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3690 (cperl-setup-tmp-buf))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3691 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3692 (setq file (car (insert-file-contents file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3693 (message "Scanning file %s..." file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3694 (if xs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3695 (setq lst (cperl-xsub-scan))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3696 (setq ind (imenu-example--create-perl-index))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3697 (setq lst (cdr (assoc "+Unsorted List+..." ind))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3698 (setq lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3699 (mapcar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3700 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3701 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3702 (cond ((string-match "^[_a-zA-Z]" (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3703 (goto-char (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3704 (list (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3705 (point) (count-lines 1 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3706 (buffer-substring (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3707 (skip-chars-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3708 ":_a-zA-Z0-9")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3709 (or (eolp) (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3710 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3711 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3712 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3713 (point))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3714 lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3715 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3716 (while lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3717 (setq elt (car lst) lst (cdr lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3718 (if elt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3719 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3720 (insert (elt elt 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3721 127
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3722 (if (string-match "^package " (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3723 (substring (car elt) 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3724 (car elt) )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3725 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3726 (number-to-string (elt elt 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3727 ","
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3728 (number-to-string (elt elt 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3729 "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3730 (if (and (string-match "^[_a-zA-Z]+::" (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3731 (string-match "^sub[ \t]+\\([_a-zA-Z]+\\)[^:_a-zA-Z]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3732 (elt elt 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3733 ;; Need to insert the name without package as well
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3734 (setq lst (cons (cons (substring (elt elt 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3735 (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3736 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3737 (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3738 lst))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3739 (setq pos (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3740 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3741 (insert "\f\n" file "," (number-to-string (1- pos)) "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3742 (setq ret (buffer-substring 1 (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3743 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3744 (message "Scanning file %s finished" file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3745 ret)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3746
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3747 (defun cperl-write-tags (&optional file erase recurse dir inbuffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3748 ;; If INBUFFER, do not select buffer, and do not save
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3749 ;; If ERASE is `ignore', do not erase, and do not try to delete old info.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3750 (require 'etags)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3751 (if file nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3752 (setq file (if dir default-directory (buffer-file-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3753 (if (and (not dir) (buffer-modified-p)) (error "Save buffer first!")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3754 (let ((tags-file-name "TAGS")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3755 (case-fold-search (eq system-type 'emx))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3756 xs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3757 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3758 (cond (inbuffer nil) ; Already there
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3759 ((file-exists-p tags-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3760 (visit-tags-table-buffer tags-file-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3761 (t (set-buffer (find-file-noselect tags-file-name))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3762 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3763 (dir
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3764 (cond ((eq erase 'ignore))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3765 (erase
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3766 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3767 (setq erase 'ignore)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3768 (let ((files
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3769 (directory-files file t (if recurse nil "\\.[Pp][Llm]$") t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3770 (mapcar (function (lambda (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3771 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3772 ((string-match "/\\.\\.?$" file) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3773 ((not (file-directory-p file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3774 (if (string-match "\\.\\([Pp][Llm]\\|xs\\)$" file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3775 (cperl-write-tags file erase recurse nil t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3776 ((not recurse) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3777 (t (cperl-write-tags file erase recurse t t)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3778 files))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3779 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3780 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3781 (setq xs (string-match "\\.xs$" file))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3782 (cond ((eq erase 'ignore) (goto-char (point-max)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3783 (erase (erase-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3784 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3785 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3786 (if (search-forward (concat "\f\n" file ",") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3787 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3788 (search-backward "\f\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3789 (delete-region (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3790 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3791 (forward-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3792 (search-forward "\f\n" nil 'toend)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3793 (point))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3794 (goto-char (point-max)))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3795 (insert (cperl-find-tags file xs))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3796 (if inbuffer nil ; Delegate to the caller
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3797 (save-buffer 0) ; No backup
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3798 (if (fboundp 'initialize-new-tags-table) ; Do we need something special in XEmacs?
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
3799 (initialize-new-tags-table))))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3800
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3801 (defvar cperl-tags-hier-regexp-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3802 "^\\(\\(package\\)\\>\\|sub\\>[^\n]+::\\|[a-zA-Z_][a-zA-Z_0-9:]*(\C-?[^\n]+::\\|[ \t]*BOOT:\C-?[^\n]+::\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3803
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3804 (defvar cperl-hierarchy '(() ())
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3805 "Global hierarchy of classes")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3806
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3807 (defun cperl-tags-hier-fill ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3808 ;; Suppose we are in a tag table cooked by cperl.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3809 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3810 (let (type pack name pos line chunk ord cons1 file str info fileind)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3811 (while (re-search-forward cperl-tags-hier-regexp-list nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3812 (setq pos (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3813 pack (match-beginning 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3814 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3815 (if (looking-at "\\([^\n]+\\)\C-?\\([^\n]+\\)\C-a\\([0-9]+\\),\\([0-9]+\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3816 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3817 (setq ;;str (buffer-substring (match-beginning 1) (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3818 name (buffer-substring (match-beginning 2) (match-end 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3819 ;;pos (buffer-substring (match-beginning 3) (match-end 3))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3820 line (buffer-substring (match-beginning 4) (match-end 4))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3821 ord (if pack 1 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3822 info (etags-snarf-tag) ; Moves to beginning of the next line
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3823 file (file-of-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3824 fileind (format "%s:%s" file line))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3825 ;; Move back
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3826 (forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3827 ;; Make new member of hierarchy name ==> file ==> pos if needed
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3828 (if (setq cons1 (assoc name (nth ord cperl-hierarchy)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3829 ;; Name known
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3830 (setcdr cons1 (cons (cons fileind (vector file info))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3831 (cdr cons1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3832 ;; First occurrence of the name, start alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3833 (setq cons1 (cons name (list (cons fileind (vector file info)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3834 (if pack
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3835 (setcar (cdr cperl-hierarchy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3836 (cons cons1 (nth 1 cperl-hierarchy)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3837 (setcar cperl-hierarchy
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3838 (cons cons1 (car cperl-hierarchy)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3839 (end-of-line))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3840
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3841 (defun cperl-tags-hier-init (&optional update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3842 "Show hierarchical menu of classes and methods.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3843 Finds info about classes by a scan of loaded TAGS files.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3844 Supposes that the TAGS files contain fully qualified function names.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3845 One may build such TAGS files from CPerl mode menu."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3846 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3847 (require 'etags)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3848 (require 'imenu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3849 (if (or update (null (nth 2 cperl-hierarchy)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3850 (let (pack name cons1 to l1 l2 l3 l4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3851 (remover (function (lambda (elt) ; (name (file1...) (file2..))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3852 (or (nthcdr 2 elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3853 ;; Only in one file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3854 (setcdr elt (cdr (nth 1 elt))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3855 ;; (setq cperl-hierarchy '(() () ())) ; Would write into '() later!
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3856 (setq cperl-hierarchy (list l1 l2 l3))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3857 (or tags-table-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3858 (call-interactively 'visit-tags-table))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3859 (message "Updating list of classes...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3860 (mapcar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3861 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3862 (lambda (tagsfile)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3863 (set-buffer (get-file-buffer tagsfile))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3864 (cperl-tags-hier-fill)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3865 tags-table-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3866 (mapcar remover (car cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3867 (mapcar remover (nth 1 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3868 (setq to (list nil (cons "Packages: " (nth 1 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3869 (cons "Methods: " (car cperl-hierarchy))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3870 (cperl-tags-treeify to 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3871 (setcar (nthcdr 2 cperl-hierarchy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3872 (cperl-menu-to-keymap (cons '("+++UPDATE+++" . -999) (cdr to))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3873 (message "Updating list of classes: done, requesting display...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3874 ;;(cperl-imenu-addback (nth 2 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3875 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3876 (or (nth 2 cperl-hierarchy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3877 (error "No items found"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3878 (setq update
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3879 ;;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3880 (if window-system
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3881 (x-popup-menu t (nth 2 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3882 (require 'tmm)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3883 (tmm-prompt t (nth 2 cperl-hierarchy))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3884 (if (and update (listp update))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3885 (progn (while (cdr update) (setq update (cdr update)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3886 (setq update (car update)))) ; Get the last from the list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3887 (if (vectorp update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3888 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3889 (find-file (elt update 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3890 (etags-goto-tag-location (elt update 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3891 (if (eq update -999) (cperl-tags-hier-init t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3892
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3893 (defun cperl-tags-treeify (to level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3894 ;; cadr of to is read-write. On start it is a cons
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3895 (let* ((regexp (concat "^\\(" (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3896 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3897 (make-list level "[_a-zA-Z0-9]+")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3898 "::")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3899 "\\)\\(::\\)?"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3900 (packages (cdr (nth 1 to)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3901 (methods (cdr (nth 2 to)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3902 l1 head tail cons1 cons2 ord writeto packs recurse
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3903 root-packages root-functions ms many_ms same_name ps
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3904 (move-deeper
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3905 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3906 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3907 (cond ((and (string-match regexp (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3908 (or (eq ord 1) (match-end 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3909 (setq head (substring (car elt) 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3910 tail (if (match-end 2) (substring (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3911 (match-end 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3912 recurse t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3913 (if (setq cons1 (assoc head writeto)) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3914 ;; Need to init new head
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3915 (setcdr writeto (cons (list head (list "Packages: ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3916 (list "Methods: "))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3917 (cdr writeto)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3918 (setq cons1 (nth 1 writeto)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3919 (setq cons2 (nth ord cons1)) ; Either packs or meths
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3920 (setcdr cons2 (cons elt (cdr cons2))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3921 ((eq ord 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3922 (setq root-functions (cons elt root-functions)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3923 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3924 (setq root-packages (cons elt root-packages))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3925 (setcdr to l1) ; Init to dynamic space
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3926 (setq writeto to)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3927 (setq ord 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3928 (mapcar move-deeper packages)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3929 (setq ord 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3930 (mapcar move-deeper methods)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3931 (if recurse
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3932 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3933 (cperl-tags-treeify elt (1+ level))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3934 (cdr to)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3935 ;; Now add back functions removed from display
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3936 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3937 (setcdr to (cons elt (cdr to)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3938 root-functions)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3939 ;; Now add back packages removed from display
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3940 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3941 (setcdr to (cons (cons (concat "package " (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3942 (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3943 (cdr to)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3944 root-packages)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3945 ;;Now clean up leaders with one child only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3946 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3947 (if (not (and (listp (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3948 (eq (length elt) 2))) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3949 (setcar elt (car (nth 1 elt)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3950 (setcdr elt (cdr (nth 1 elt))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3951 (cdr to))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3952 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3953
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3954 ;;;(x-popup-menu t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3955 ;;; '(keymap "Name1"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3956 ;;; ("Ret1" "aa")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3957 ;;; ("Head1" "ab"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3958 ;;; keymap "Name2"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3959 ;;; ("Tail1" "x") ("Tail2" "y"))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3960
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3961 (defun cperl-list-fold (list name limit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3962 (let (list1 list2 elt1 (num 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3963 (if (<= (length list) limit) list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3964 (setq list1 nil list2 nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3965 (while list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3966 (setq num (1+ num)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3967 elt1 (car list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3968 list (cdr list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3969 (if (<= num imenu-max-items)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3970 (setq list2 (cons elt1 list2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3971 (setq list1 (cons (cons name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3972 (nreverse list2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3973 list1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3974 list2 (list elt1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3975 num 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3976 (nreverse (cons (cons name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3977 (nreverse list2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3978 list1)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3979
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3980 (defun cperl-menu-to-keymap (menu &optional name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3981 (let (list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3982 (cons 'keymap
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3983 (mapcar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3984 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3985 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3986 (cond ((listp (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3987 (setq list (cperl-list-fold
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3988 (cdr elt) (car elt) imenu-max-items))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3989 (cons nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3990 (cons (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3991 (cperl-menu-to-keymap list))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3992 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3993 (list (cdr elt) (car elt))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3994 (cperl-list-fold menu "Root" imenu-max-items)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3995
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3996
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3997 (defvar cperl-bad-style-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3998 (mapconcat 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3999 '("[^-\n\t <>=+!.&|(*/'`\"#^][-=+<>!|&^]" ; char sign
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4000 "[-<>=+^&|]+[^- \t\n=+<>~]" ; sign+ char
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4001 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4002 "\\|")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4003 "Finds places such that insertion of a whitespace may help a lot.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4004
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4005 (defvar cperl-not-bad-style-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4006 (mapconcat 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4007 '("[^-\t <>=+]\\(--\\|\\+\\+\\)" ; var-- var++
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4008 "[a-zA-Z0-9][|&][a-zA-Z0-9$]" ; abc|def abc&def are often used.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4009 "&[(a-zA-Z0-9$]" ; &subroutine &(var->field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4010 "<\\$?\\sw+\\(\\.\\sw+\\)?>" ; <IN> <stdin.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4011 "-[a-zA-Z][ \t]+[_$\"'`]" ; -f file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4012 "-[0-9]" ; -5
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4013 "\\+\\+" ; ++var
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4014 "--" ; --var
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4015 ".->" ; a->b
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4016 "->" ; a SPACE ->b
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4017 "\\[-" ; a[-1]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4018 "^=" ; =head
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4019 "||"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4020 "&&"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4021 "[CBIXSLFZ]<\\(\\sw\\|\\s \\|\\s_\\|[\n]\\)*>" ; C<code like text>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4022 "-[a-zA-Z0-9]+[ \t]*=>" ; -option => value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4023 ;; Unaddressed trouble spots: = -abc, f(56, -abc) --- specialcased below
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4024 ;;"[*/+-|&<.]+="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4025 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4026 "\\|")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4027 "If matches at the start of match found by `my-bad-c-style-regexp',
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4028 insertion of a whitespace will not help.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4029
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4030 (defvar found-bad)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4031
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4032 (defun cperl-find-bad-style ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4033 "Find places in the buffer where insertion of a whitespace may help.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4034 Prompts user for insertion of spaces.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4035 Currently it is tuned to C and Perl syntax."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4036 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4037 (let (found-bad (p (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4038 (setq last-nonmenu-event 13) ; To disable popup
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4039 (beginning-of-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4040 (map-y-or-n-p "Insert space here? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4041 (function (lambda (arg) (insert " ")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4042 'cperl-next-bad-style
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4043 '("location" "locations" "insert a space into")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4044 '((?\C-r (lambda (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4045 (let ((buffer-quit-function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4046 'exit-recursive-edit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4047 (message "Exit with Esc Esc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4048 (recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4049 t)) ; Consider acted upon
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4050 "edit, exit with Esc Esc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4051 (?e (lambda (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4052 (let ((buffer-quit-function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4053 'exit-recursive-edit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4054 (message "Exit with Esc Esc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4055 (recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4056 t)) ; Consider acted upon
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4057 "edit, exit with Esc Esc"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4058 t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4059 (if found-bad (goto-char found-bad)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4060 (goto-char p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4061 (message "No appropriate place found"))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4062
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4063 (defun cperl-next-bad-style ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4064 (let (p (not-found t) (point (point)) found)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4065 (while (and not-found
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4066 (re-search-forward cperl-bad-style-regexp nil 'to-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4067 (setq p (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4068 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4069 (if (or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4070 (looking-at cperl-not-bad-style-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4071 ;; Check for a < -b and friends
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4072 (and (eq (following-char) ?\-)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4073 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4074 (skip-chars-backward " \t\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4075 (memq (preceding-char) '(?\= ?\> ?\< ?\, ?\(, ?\[, ?\{))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4076 ;; Now check for syntax type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4077 (save-match-data
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4078 (setq found (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4079 (beginning-of-defun)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4080 (let ((pps (parse-partial-sexp (point) found)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4081 (or (nth 3 pps) (nth 4 pps) (nth 5 pps)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4082 (goto-char (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4083 (goto-char (1- p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4084 (setq not-found nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4085 found-bad found)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4086 (not not-found)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4087
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4088 
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4089 ;;; Getting help
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4090 (defvar cperl-have-help-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4091 ;;(concat "\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4092 (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4093 'identity
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4094 '("[$@%*&][0-9a-zA-Z_:]+\\([ \t]*[[{]\\)?" ; Usual variable
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4095 "[$@]\\^[a-zA-Z]" ; Special variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4096 "[$@][^ \n\t]" ; Special variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4097 "-[a-zA-Z]" ; File test
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4098 "\\\\[a-zA-Z0]" ; Special chars
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4099 "^=[a-z][a-zA-Z0-9_]*" ; Pod sections
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4100 "[-!&*+,-./<=>?\\\\^|~]+" ; Operator
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4101 "[a-zA-Z_0-9:]+" ; symbol or number
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4102 "x="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4103 "#!"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4104 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4105 ;;"\\)\\|\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4106 "\\|"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4107 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4108 ;;"\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4109 ;;)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4110 "Matches places in the buffer we can find help for.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4111
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4112 (defvar cperl-message-on-help-error t)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4113 (defvar cperl-help-from-timer nil)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4114
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4115 (defun cperl-word-at-point-hard ()
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4116 ;; Does not save-excursion
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4117 ;; Get to the something meaningful
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4118 (or (eobp) (eolp) (forward-char 1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4119 (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4120 (save-excursion (beginning-of-line) (point))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4121 'to-beg)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4122 ;; (cond
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4123 ;; ((or (eobp) (looking-at "[][ \t\n{}();,]")) ; Not at a symbol
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4124 ;; (skip-chars-backward " \n\t\r({[]});,")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4125 ;; (or (bobp) (backward-char 1))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4126 ;; Try to backtrace
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4127 (cond
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4128 ((looking-at "[a-zA-Z0-9_:]") ; symbol
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4129 (skip-chars-backward "[a-zA-Z0-9_:]")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4130 (cond
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4131 ((and (eq (preceding-char) ?^) ; $^I
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4132 (eq (char-after (- (point) 2)) ?\$))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4133 (forward-char -2))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4134 ((memq (preceding-char) (append "*$@%&\\" nil)) ; *glob
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4135 (forward-char -1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4136 ((and (eq (preceding-char) ?\=)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4137 (eq (current-column) 1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4138 (forward-char -1))) ; =head1
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4139 (if (and (eq (preceding-char) ?\<)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4140 (looking-at "\\$?[a-zA-Z0-9_:]+>")) ; <FH>
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4141 (forward-char -1)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4142 ((and (looking-at "=") (eq (preceding-char) ?x)) ; x=
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4143 (forward-char -1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4144 ((and (looking-at "\\^") (eq (preceding-char) ?\$)) ; $^I
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4145 (forward-char -1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4146 ((looking-at "[-!&*+,-./<=>?\\\\^|~]")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4147 (skip-chars-backward "[-!&*+,-./<=>?\\\\^|~]")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4148 (cond
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4149 ((and (eq (preceding-char) ?\$)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4150 (not (eq (char-after (- (point) 2)) ?\$))) ; $-
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4151 (forward-char -1))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4152 ((and (eq (following-char) ?\>)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4153 (string-match "[a-zA-Z0-9_]" (char-to-string (preceding-char)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4154 (save-excursion
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4155 (forward-sexp -1)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4156 (and (eq (preceding-char) ?\<)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4157 (looking-at "\\$?[a-zA-Z0-9_:]+>")))) ; <FH>
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4158 (search-backward "<"))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4159 ((and (eq (following-char) ?\$)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4160 (eq (preceding-char) ?\<)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4161 (looking-at "\\$?[a-zA-Z0-9_:]+>")) ; <$fh>
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4162 (forward-char -1)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4163 (if (looking-at cperl-have-help-regexp)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4164 (buffer-substring (match-beginning 0) (match-end 0))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4165
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4166 (defun cperl-get-help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4167 "Get one-line docs on the symbol at the point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4168 The data for these docs is a little bit obsolete and may be in fact longer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4169 than a line. Your contribution to update/shorten it is appreciated."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4170 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4171 (save-excursion
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4172 (let ((word (cperl-word-at-point-hard)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4173 (if word
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4174 (if (and cperl-help-from-timer ; Bail out if not in mainland
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4175 (not (string-match "^#!\\|\\\\\\|^=" word)) ; Show help even in comments/strings.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4176 (or (memq (get-text-property (point) 'face)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4177 '(font-lock-comment-face font-lock-string-face))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4178 (memq (get-text-property (point) 'syntax-type)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4179 '(pod here-doc format))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4180 nil
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4181 (cperl-describe-perl-symbol word))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4182 (if cperl-message-on-help-error
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4183 (message "Nothing found for %s..."
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4184 (buffer-substring (point) (+ 5 (point)))))))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4185
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4186 ;;; Stolen from perl-descr.el by Johan Vromans:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4187
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4188 (defvar cperl-doc-buffer " *perl-doc*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4189 "Where the documentation can be found.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4190
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4191 (defun cperl-describe-perl-symbol (val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4192 "Display the documentation of symbol at point, a Perl operator."
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4193 (let ((enable-recursive-minibuffers t)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4194 args-file regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4195 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4196 ((string-match "^[&*][a-zA-Z_]" val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4197 (setq val (concat (substring val 0 1) "NAME")))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4198 ((string-match "^[$@]\\([a-zA-Z_:0-9]+\\)[ \t]*\\[" val)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4199 (setq val (concat "@" (substring val 1 (match-end 1)))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4200 ((string-match "^[$@]\\([a-zA-Z_:0-9]+\\)[ \t]*{" val)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4201 (setq val (concat "%" (substring val 1 (match-end 1)))))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4202 ((and (string= val "x") (string-match "^x=" val))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4203 (setq val "x="))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4204 ((string-match "^\\$[\C-a-\C-z]" val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4205 (setq val (concat "$^" (char-to-string (+ ?A -1 (aref val 1))))))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4206 ((string-match "^CORE::" val)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4207 (setq val "CORE::"))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4208 ((string-match "^SUPER::" val)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4209 (setq val "SUPER::"))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4210 ((and (string= "<" val) (string-match "^<\\$?[a-zA-Z0-9_:]+>" val))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4211 (setq val "<NAME>")))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4212 (setq regexp (concat "^"
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4213 "\\([^a-zA-Z0-9_:]+[ \t]+\\)?"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4214 (regexp-quote val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4215 "\\([ \t([/]\\|$\\)"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4216
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4217 ;; get the buffer with the documentation text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4218 (cperl-switch-to-doc-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4219
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4220 ;; lookup in the doc
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4221 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4222 (let ((case-fold-search nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4223 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4224 (if (re-search-forward regexp (point-max) t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4225 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4226 (beginning-of-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4227 (let ((lnstart (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4228 (end-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4229 (message "%s" (buffer-substring lnstart (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4230 (if cperl-message-on-help-error
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4231 (message "No definition for %s" val)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4232
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4233 (defvar cperl-short-docs "Ignore my value"
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4234 ;; Perl4 version was written by Johan Vromans (jvromans@squirrel.nl)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4235 "# based on '@(#)@ perl-descr.el 1.9 - describe-perl-symbol' [Perl 5]
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4236 ! ... Logical negation.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4237 ... != ... Numeric inequality.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4238 ... !~ ... Search pattern, substitution, or translation (negated).
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4239 $! In numeric context: errno. In a string context: error string.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4240 $\" The separator which joins elements of arrays interpolated in strings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4241 $# The output format for printed numbers. Initial value is %.20g.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4242 $$ Process number of this script. Changes in the fork()ed child process.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4243 $% The current page number of the currently selected output channel.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4244
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4245 The following variables are always local to the current block:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4246
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4247 $1 Match of the 1st set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4248 $2 Match of the 2nd set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4249 $3 Match of the 3rd set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4250 $4 Match of the 4th set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4251 $5 Match of the 5th set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4252 $6 Match of the 6th set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4253 $7 Match of the 7th set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4254 $8 Match of the 8th set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4255 $9 Match of the 9th set of parentheses in the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4256 $& The string matched by the last pattern match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4257 $' The string after what was matched by the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4258 $` The string before what was matched by the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4259
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4260 $( The real gid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4261 $) The effective gid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4262 $* Deprecated: Set to 1 to do multiline matching within a string.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4263 $+ The last bracket matched by the last search pattern.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4264 $, The output field separator for the print operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4265 $- The number of lines left on the page.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4266 $. The current input line number of the last filehandle that was read.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4267 $/ The input record separator, newline by default.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4268 $0 Name of the file containing the perl script being executed. May be set.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4269 $: String may be broken after these characters to fill ^-lines in a format.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4270 $; Subscript separator for multi-dim array emulation. Default \"\\034\".
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4271 $< The real uid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4272 $= The page length of the current output channel. Default is 60 lines.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4273 $> The effective uid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4274 $? The status returned by the last ``, pipe close or `system'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4275 $@ The perl error message from the last eval or do @var{EXPR} command.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4276 $ARGV The name of the current file used with <> .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4277 $[ Deprecated: The index of the first element/char in an array/string.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4278 $\\ The output record separator for the print operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4279 $] The perl version string as displayed with perl -v.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4280 $^ The name of the current top-of-page format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4281 $^A The current value of the write() accumulator for format() lines.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4282 $^D The value of the perl debug (-D) flags.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4283 $^E Information about the last system error other than that provided by $!.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4284 $^F The highest system file descriptor, ordinarily 2.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4285 $^H The current set of syntax checks enabled by `use strict'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4286 $^I The value of the in-place edit extension (perl -i option).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4287 $^L What formats output to perform a formfeed. Default is \f.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4288 $^O The operating system name under which this copy of Perl was built.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4289 $^P Internal debugging flag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4290 $^T The time the script was started. Used by -A/-M/-C file tests.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4291 $^W True if warnings are requested (perl -w flag).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4292 $^X The name under which perl was invoked (argv[0] in C-speech).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4293 $_ The default input and pattern-searching space.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4294 $| Auto-flush after write/print on the current output channel? Default 0.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4295 $~ The name of the current report format.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4296 ... % ... Modulo division.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4297 ... %= ... Modulo division assignment.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4298 %ENV Contains the current environment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4299 %INC List of files that have been require-d or do-ne.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4300 %SIG Used to set signal handlers for various signals.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4301 ... & ... Bitwise and.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4302 ... && ... Logical and.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4303 ... &&= ... Logical and assignment.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4304 ... &= ... Bitwise and assignment.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4305 ... * ... Multiplication.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4306 ... ** ... Exponentiation.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4307 *NAME Glob: all objects refered by NAME. *NAM1 = *NAM2 aliases NAM1 to NAM2.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4308 &NAME(arg0, ...) Subroutine call. Arguments go to @_.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4309 ... + ... Addition. +EXPR Makes EXPR into scalar context.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4310 ++ Auto-increment (magical on strings). ++EXPR EXPR++
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4311 ... += ... Addition assignment.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4312 , Comma operator.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4313 ... - ... Subtraction.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4314 -- Auto-decrement (NOT magical on strings). --EXPR EXPR--
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4315 ... -= ... Subtraction assignment.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4316 -A Access time in days since script started.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4317 -B File is a non-text (binary) file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4318 -C Inode change time in days since script started.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4319 -M Age in days since script started.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4320 -O File is owned by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4321 -R File is readable by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4322 -S File is a socket .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4323 -T File is a text file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4324 -W File is writable by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4325 -X File is executable by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4326 -b File is a block special file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4327 -c File is a character special file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4328 -d File is a directory.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4329 -e File exists .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4330 -f File is a plain file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4331 -g File has setgid bit set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4332 -k File has sticky bit set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4333 -l File is a symbolic link.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4334 -o File is owned by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4335 -p File is a named pipe (FIFO).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4336 -r File is readable by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4337 -s File has non-zero size.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4338 -t Tests if filehandle (STDIN by default) is opened to a tty.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4339 -u File has setuid bit set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4340 -w File is writable by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4341 -x File is executable by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4342 -z File has zero size.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4343 . Concatenate strings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4344 .. Alternation, also range operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4345 .= Concatenate assignment strings
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4346 ... / ... Division. /PATTERN/ioxsmg Pattern match
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4347 ... /= ... Division assignment.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4348 /PATTERN/ioxsmg Pattern match.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4349 ... < ... Numeric less than. <pattern> Glob. See <NAME>, <> as well.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4350 <NAME> Reads line from filehandle NAME. NAME must be bareword/dollar-bareword.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4351 <pattern> Glob. (Unless pattern is bareword/dollar-bareword - see <NAME>)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4352 <> Reads line from union of files in @ARGV (= command line) and STDIN.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4353 ... << ... Bitwise shift left. << start of HERE-DOCUMENT.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4354 ... <= ... Numeric less than or equal to.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4355 ... <=> ... Numeric compare.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4356 ... = ... Assignment.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4357 ... == ... Numeric equality.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4358 ... =~ ... Search pattern, substitution, or translation
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4359 ... > ... Numeric greater than.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4360 ... >= ... Numeric greater than or equal to.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4361 ... >> ... Bitwise shift right.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4362 ... >>= ... Bitwise shift right assignment.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4363 ... ? ... : ... Condition=if-then-else operator. ?PAT? One-time pattern match.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4364 ?PATTERN? One-time pattern match.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4365 @ARGV Command line arguments (not including the command name - see $0).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4366 @INC List of places to look for perl scripts during do/include/use.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4367 @_ Parameter array for subroutines. Also used by split unless in array context.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4368 \\ Creates a reference to whatever follows, like \$var.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4369 \\0 Octal char, e.g. \\033.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4370 \\E Case modification terminator. See \\Q, \\L, and \\U.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4371 \\L Lowercase until \\E . See also \l, lc.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4372 \\U Upcase until \\E . See also \u, uc.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4373 \\Q Quote metacharacters until \\E . See also quotemeta.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4374 \\a Alarm character (octal 007).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4375 \\b Backspace character (octal 010).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4376 \\c Control character, e.g. \\c[ .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4377 \\e Escape character (octal 033).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4378 \\f Formfeed character (octal 014).
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4379 \\l Lowercase the next character. See also \\L and \\u, lcfirst,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4380 \\n Newline character (octal 012).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4381 \\r Return character (octal 015).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4382 \\t Tab character (octal 011).
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4383 \\u Upcase the next character. See also \\U and \\l, ucfirst,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4384 \\x Hex character, e.g. \\x1b.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4385 ^ ... Bitwise exclusive or.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4386 __END__ Ends program source.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4387 __DATA__ Ends program source.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4388 __FILE__ Current (source) filename.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4389 __LINE__ Current line in current source.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4390 ARGV Default multi-file input filehandle. <ARGV> is a synonym for <>.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4391 ARGVOUT Output filehandle with -i flag.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4392 BEGIN { ... } Immediately executed (during compilation) piece of code.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4393 END { ... } Pseudo-subroutine executed after the script finishes.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4394 DATA Input filehandle for what follows after __END__ or __DATA__.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4395 accept(NEWSOCKET,GENERICSOCKET)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4396 alarm(SECONDS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4397 atan2(X,Y)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4398 bind(SOCKET,NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4399 binmode(FILEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4400 caller[(LEVEL)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4401 chdir(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4402 chmod(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4403 chop[(LIST|VAR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4404 chown(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4405 chroot(FILENAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4406 close(FILEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4407 closedir(DIRHANDLE)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4408 ... cmp ... String compare.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4409 connect(SOCKET,NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4410 continue of { block } continue { block }. Is executed after `next' or at end.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4411 cos(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4412 crypt(PLAINTEXT,SALT)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4413 dbmclose(%HASH)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4414 dbmopen(%HASH,DBNAME,MODE)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4415 defined(EXPR)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4416 delete($HASH{KEY})
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4417 die(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4418 do { ... }|SUBR while|until EXPR executes at least once
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4419 do(EXPR|SUBR([LIST]))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4420 dump LABEL
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4421 each(%HASH)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4422 endgrent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4423 endhostent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4424 endnetent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4425 endprotoent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4426 endpwent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4427 endservent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4428 eof[([FILEHANDLE])]
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4429 ... eq ... String equality.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4430 eval(EXPR) or eval { BLOCK }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4431 exec(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4432 exit(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4433 exp(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4434 fcntl(FILEHANDLE,FUNCTION,SCALAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4435 fileno(FILEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4436 flock(FILEHANDLE,OPERATION)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4437 for (EXPR;EXPR;EXPR) { ... }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4438 foreach [VAR] (@ARRAY) { ... }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4439 fork
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4440 ... ge ... String greater than or equal.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4441 getc[(FILEHANDLE)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4442 getgrent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4443 getgrgid(GID)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4444 getgrnam(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4445 gethostbyaddr(ADDR,ADDRTYPE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4446 gethostbyname(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4447 gethostent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4448 getlogin
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4449 getnetbyaddr(ADDR,ADDRTYPE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4450 getnetbyname(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4451 getnetent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4452 getpeername(SOCKET)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4453 getpgrp(PID)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4454 getppid
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4455 getpriority(WHICH,WHO)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4456 getprotobyname(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4457 getprotobynumber(NUMBER)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4458 getprotoent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4459 getpwent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4460 getpwnam(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4461 getpwuid(UID)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4462 getservbyname(NAME,PROTO)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4463 getservbyport(PORT,PROTO)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4464 getservent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4465 getsockname(SOCKET)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4466 getsockopt(SOCKET,LEVEL,OPTNAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4467 gmtime(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4468 goto LABEL
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4469 grep(EXPR,LIST)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4470 ... gt ... String greater than.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4471 hex(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4472 if (EXPR) { ... } [ elsif (EXPR) { ... } ... ] [ else { ... } ] or EXPR if EXPR
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4473 index(STR,SUBSTR[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4474 int(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4475 ioctl(FILEHANDLE,FUNCTION,SCALAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4476 join(EXPR,LIST)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4477 keys(%HASH)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4478 kill(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4479 last [LABEL]
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4480 ... le ... String less than or equal.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4481 length(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4482 link(OLDFILE,NEWFILE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4483 listen(SOCKET,QUEUESIZE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4484 local(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4485 localtime(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4486 log(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4487 lstat(EXPR|FILEHANDLE|VAR)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4488 ... lt ... String less than.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4489 m/PATTERN/iogsmx
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4490 mkdir(FILENAME,MODE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4491 msgctl(ID,CMD,ARG)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4492 msgget(KEY,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4493 msgrcv(ID,VAR,SIZE,TYPE.FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4494 msgsnd(ID,MSG,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4495 my VAR or my (VAR1,...) Introduces a lexical variable ($VAR, @ARR, or %HASH).
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4496 ... ne ... String inequality.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4497 next [LABEL]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4498 oct(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4499 open(FILEHANDLE[,EXPR])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4500 opendir(DIRHANDLE,EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4501 ord(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4502 pack(TEMPLATE,LIST)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4503 package NAME Introduces package context.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4504 pipe(READHANDLE,WRITEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4505 pop(ARRAY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4506 print [FILEHANDLE] [(LIST)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4507 printf [FILEHANDLE] (FORMAT,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4508 push(ARRAY,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4509 q/STRING/ Synonym for 'STRING'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4510 qq/STRING/ Synonym for \"STRING\"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4511 qx/STRING/ Synonym for `STRING`
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4512 rand[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4513 read(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4514 readdir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4515 readlink(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4516 recv(SOCKET,SCALAR,LEN,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4517 redo [LABEL]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4518 rename(OLDNAME,NEWNAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4519 require [FILENAME | PERL_VERSION]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4520 reset[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4521 return(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4522 reverse(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4523 rewinddir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4524 rindex(STR,SUBSTR[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4525 rmdir(FILENAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4526 s/PATTERN/REPLACEMENT/gieoxsm
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4527 scalar(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4528 seek(FILEHANDLE,POSITION,WHENCE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4529 seekdir(DIRHANDLE,POS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4530 select(FILEHANDLE | RBITS,WBITS,EBITS,TIMEOUT)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4531 semctl(ID,SEMNUM,CMD,ARG)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4532 semget(KEY,NSEMS,SIZE,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4533 semop(KEY,...)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4534 send(SOCKET,MSG,FLAGS[,TO])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4535 setgrent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4536 sethostent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4537 setnetent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4538 setpgrp(PID,PGRP)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4539 setpriority(WHICH,WHO,PRIORITY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4540 setprotoent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4541 setpwent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4542 setservent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4543 setsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4544 shift[(ARRAY)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4545 shmctl(ID,CMD,ARG)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4546 shmget(KEY,SIZE,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4547 shmread(ID,VAR,POS,SIZE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4548 shmwrite(ID,STRING,POS,SIZE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4549 shutdown(SOCKET,HOW)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4550 sin(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4551 sleep[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4552 socket(SOCKET,DOMAIN,TYPE,PROTOCOL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4553 socketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4554 sort [SUBROUTINE] (LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4555 splice(ARRAY,OFFSET[,LENGTH[,LIST]])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4556 split[(/PATTERN/[,EXPR[,LIMIT]])]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4557 sprintf(FORMAT,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4558 sqrt(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4559 srand(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4560 stat(EXPR|FILEHANDLE|VAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4561 study[(SCALAR)]
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4562 sub [NAME [(format)]] { BODY } sub NAME [(format)]; sub [(format)] {...}
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4563 substr(EXPR,OFFSET[,LEN])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4564 symlink(OLDFILE,NEWFILE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4565 syscall(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4566 sysread(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4567 system(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4568 syswrite(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4569 tell[(FILEHANDLE)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4570 telldir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4571 time
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4572 times
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4573 tr/SEARCHLIST/REPLACEMENTLIST/cds
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4574 truncate(FILE|EXPR,LENGTH)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4575 umask[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4576 undef[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4577 unless (EXPR) { ... } [ else { ... } ] or EXPR unless EXPR
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4578 unlink(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4579 unpack(TEMPLATE,EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4580 unshift(ARRAY,LIST)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4581 until (EXPR) { ... } EXPR until EXPR
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4582 utime(LIST)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4583 values(%HASH)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4584 vec(EXPR,OFFSET,BITS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4585 wait
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4586 waitpid(PID,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4587 wantarray
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4588 warn(LIST)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4589 while (EXPR) { ... } EXPR while EXPR
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4590 write[(EXPR|FILEHANDLE)]
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4591 ... x ... Repeat string or array.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4592 x= ... Repetition assignment.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4593 y/SEARCHLIST/REPLACEMENTLIST/
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4594 ... | ... Bitwise or.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4595 ... || ... Logical or.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4596 ~ ... Unary bitwise complement.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4597 #! OS interpreter indicator. If contains `perl', used for options, and -x.
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4598 AUTOLOAD {...} Shorthand for `sub AUTOLOAD {...}'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4599 CORE:: Prefix to access builtin function if imported sub obscures it.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4600 SUPER:: Prefix to lookup for a method in @ISA classes.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4601 DESTROY Shorthand for `sub DESTROY {...}'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4602 ... EQ ... Obsolete synonym of `eq'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4603 ... GE ... Obsolete synonym of `ge'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4604 ... GT ... Obsolete synonym of `gt'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4605 ... LE ... Obsolete synonym of `le'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4606 ... LT ... Obsolete synonym of `lt'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4607 ... NE ... Obsolete synonym of `ne'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4608 abs [ EXPR ] absolute value
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4609 ... and ... Low-precedence synonym for &&.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4610 bless REFERENCE [, PACKAGE] Makes reference into an object of a package.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4611 chomp Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4612 chr Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4613 else Part of if/unless {BLOCK} elsif {BLOCK} else {BLOCK}.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4614 elsif Part of if/unless {BLOCK} elsif {BLOCK} else {BLOCK}.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4615 exists $HASH{KEY} True if the key exists.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4616 format Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4617 formline Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4618 glob EXPR Synonym of <EXPR>.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4619 lc [ EXPR ] Returns lowercased EXPR.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4620 lcfirst [ EXPR ] Returns EXPR with lower-cased first letter.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4621 map Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4622 no PACKAGE [SYMBOL1, ...] Partial reverse for `use'. Runs `unimport' method.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4623 ... not ... Low-precedence synonym for ! - negation.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4624 ... or ... Low-precedence synonym for ||.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4625 pos STRING Set/Get end-position of the last match over this string, see \\G.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4626 quotemeta [ EXPR ] Quote metacharacters.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4627 qw Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4628 readline FH Synonym of <FH>.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4629 readpipe CMD Synonym of `CMD`.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4630 ref [ EXPR ] Type of EXPR when dereferenced.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4631 sysopen Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4632 tie Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4633 tied Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4634 uc [ EXPR ] Returns upcased EXPR.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4635 ucfirst [ EXPR ] Returns EXPR with upcased first letter.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4636 untie Docs missing
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4637 use PACKAGE [SYMBOL1, ...] Compile-time `require' with consequent `import'.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4638 ... xor ... Low-precedence synonym for exclusive or.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4639 prototype \&SUB Returns prototype of the function given a reference.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4640 =head1 Top-level heading.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4641 =head2 Second-level heading.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4642 =head3 Third-level heading (is there such?).
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4643 =over [ NUMBER ] Start list.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4644 =item [ TITLE ] Start new item in the list.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4645 =back End list.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4646 =cut Switch from POD to Perl.
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4647 =pod Switch from Perl to POD.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4648 ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4649
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4650 (defun cperl-switch-to-doc-buffer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4651 "Go to the perl documentation buffer and insert the documentation."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4652 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4653 (let ((buf (get-buffer-create cperl-doc-buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4654 (if (interactive-p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4655 (switch-to-buffer-other-window buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4656 (set-buffer buf))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4657 (if (= (buffer-size) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4658 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4659 (insert (documentation-property 'cperl-short-docs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4660 'variable-documentation))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4661 (setq buffer-read-only t)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4662
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4663 (if (fboundp 'run-with-idle-timer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4664 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4665 (defvar cperl-help-shown nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4666 "Non-nil means that the help was already shown now.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4667
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4668 (defvar cperl-help-timer nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4669 "Non-nil means that the help was already shown now.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4670
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4671 (defun cperl-lazy-install ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4672 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4673 (make-variable-buffer-local 'cperl-help-shown)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4674 (if (cperl-val cperl-lazy-help-time)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4675 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4676 (add-hook 'post-command-hook 'cperl-lazy-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4677 (setq cperl-help-timer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4678 (run-with-idle-timer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4679 (cperl-val cperl-lazy-help-time 1000000 5)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4680 t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4681 'cperl-get-help-defer)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4682
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4683 (defun cperl-lazy-unstall ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4684 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4685 (remove-hook 'post-command-hook 'cperl-lazy-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4686 (cancel-timer cperl-help-timer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4687
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4688 (defun cperl-lazy-hook ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4689 (setq cperl-help-shown nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4690
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4691 (defun cperl-get-help-defer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4692 (if (not (eq major-mode 'perl-mode)) nil
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
4693 (let ((cperl-message-on-help-error nil) (cperl-help-from-timer t))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4694 (cperl-get-help)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4695 (setq cperl-help-shown t))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4696 (cperl-lazy-install)))