annotate lisp/modes/cperl-mode.el @ 4:b82b59fe008d r19-15b3

Import from CVS: tag r19-15b3
author cvs
date Mon, 13 Aug 2007 08:46:56 +0200
parents ac2d302a0011
children 859a2309aef8
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
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
35 ;; $Id: cperl-mode.el,v 1.1.1.3 1996/12/18 03:53:13 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; Additional useful commands to put into your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; (append '(("\\.[pP][Llm]$" . perl-mode)) auto-mode-alist ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; (setq interpreter-mode-alist (append interpreter-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; '(("miniperl" . perl-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; The mode information (on C-h m) provides customization help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; 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
58 ;;; either lazy-lock-mode or fast-lock-mode (available on ELisp
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; 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
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; Faces used now: three faces for first-class and second-class keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; and control flow words, one for each: comments, string, labels,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; functions definitions and packages, arrays, hashes, and variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; definitions. If you do not see all these faces, your font-lock does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; not define them, so you need to define them manually. Maybe you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; an obsolete font-lock from 19.28 or earlier. Upgrade.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
68 ;;; If you have a grayscale monitor, and do not have the variable
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; font-lock-display-type bound to 'grayscale, insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; (setq font-lock-display-type 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
73 ;;; into your .emacs file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;; This mode supports font-lock, imenu and mode-compile. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;;; hairy version font-lock is on, but you should activate imenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;;; yourself (note that mode-compile is not standard yet). Well, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;;; can use imenu from keyboard anyway (M-x imenu), but it is better
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;;; to bind it like that:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; (define-key global-map [M-S-down-mouse-3] 'imenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; In fact the version of font-lock that this version supports can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; much newer than the version you actually have. This means that a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; 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
86 ;;; since the coloring rules for this faces are not defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; Updates: ========================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; Made less hairy by default: parentheses not electric,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; linefeed not magic. Bug with abbrev-mode corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;;; After 1.4:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; Better indentation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; subs inside braces should work now,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; Toplevel braces obey customization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; indent-for-comment knows about bad cases, cperl-indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; moves cursor to a correct place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; cperl-indent-exp written from the scratch! Slow... (quadratic!) :-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; (50 secs on DB::DB (sub of 430 lines), 486/66)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; Minor documentation fixes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; Imenu understands packages as prefixes (including nested).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; Hairy options can be switched off one-by-one by setting to null.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; Names of functions and variables changed to conform to `cperl-' style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;;; After 1.5:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; Some bugs with indentation of labels (and embedded subs) corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; `cperl-indent-region' done (slow :-()).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; `cperl-fill-paragraph' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; Better package support for `imenu'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; Progress indicator for indentation (with `imenu' loaded).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; `Cperl-set' was busted, now setting the individual hairy option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; should be better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;;; After 1.6:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; `cperl-set-style' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; `cperl-check-syntax' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; Menu done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; New config variables `cperl-close-paren-offset' and `cperl-comment-column'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;; Bugs with `cperl-auto-newline' corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; `cperl-electric-lbrace' can work with `cperl-auto-newline' in situation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; like $hash{.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;;; 1.7 XEmacs (arius@informatik.uni-erlangen.de):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;; - use `next-command-event', if `next-command-events' does not exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; - use `find-face' as def. of `is-face'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; - corrected def. of `x-color-defined-p'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; - added const defs for font-lock-comment-face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; font-lock-keyword-face and font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; - added def. of font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; - added (require 'easymenu) inside an `eval-when-compile'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; - replaced 4-argument `substitute-key-definition' with ordinary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; `define-key's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; - replaced `mark-active' in menu definition by `cperl-use-region-p'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; Todo (at least):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; - 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
137 ;;; for portable code?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; - should `cperl-mode' do a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; (if (featurep 'easymenu) (easy-menu-add cperl-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; or should this be left to the user's `cperl-mode-hook'?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; Some bugs introduced by the above fix corrected (IZ ;-).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; Some bugs under XEmacs introduced by the correction corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; Some more can remain since there are two many different variants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; Please feedback!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;; We do not support fontification of arrays and hashes under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; obsolete font-lock any more. Upgrade.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;;; after 1.8 Minor bug with parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;;; after 1.9 Improvements from Joe Marzot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;;; after 1.10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;; Does not need easymenu to compile under XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;; `vc-insert-headers' should work better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;; Should work with 19.29 and 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; Small improvements to fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; Expansion of keywords does not depend on C-? being backspace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;; after 1.10+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; 19.29 and 19.12 supported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;; `cperl-font-lock-enhanced' deprecated. Use font-lock-extra.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; Support for font-lock-extra.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;;; After 1.11:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;; Tools submenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; Support for perl5-info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;; `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
169 ;;; Imenu entries do not work with stock imenu.el. Patch sent to maintainers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; Fontifies `require a if b;', __DATA__.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; Arglist for auto-fill-mode was incorrect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;;; After 1.12:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; `cperl-lineup-step' and `cperl-lineup' added: lineup constructions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; vertically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;; `cperl-do-auto-fill' updated for 19.29 style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; `cperl-info-on-command' now has a default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; Workaround for broken C-h on XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;; VC strings escaped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; C-h f now may prompt for function name instead of going on,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; controlled by `cperl-info-on-command-no-prompt'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;;; After 1.13:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; Msb buffer list includes perl files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; Indent-for-comment uses indent-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; Can write tag files using etags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;;; After 1.14:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; Recognizes (tries to ;-) {...} which are not blocks during indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; `cperl-close-paren-offset' affects ?\] too (and ?\} if not block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; Bug with auto-filling comments started with "##" corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;; Very slow now: on DB::DB 0.91, 486/66:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;;Function Name Call Count Elapsed Time Average Time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;;======================================== ========== ============ ============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;cperl-block-p 469 3.7799999999 0.0080597014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;;cperl-get-state 505 163.39000000 0.3235445544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;cperl-comment-indent 12 0.0299999999 0.0024999999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;;cperl-backward-to-noncomment 939 4.4599999999 0.0047497337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;cperl-calculate-indent 505 172.22000000 0.3410297029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;;cperl-indent-line 505 172.88000000 0.3423366336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;;cperl-use-region-p 40 0.0299999999 0.0007499999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;cperl-indent-exp 1 177.97000000 177.97000000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;;cperl-to-comment-or-eol 1453 3.9800000000 0.0027391603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;;cperl-backward-to-start-of-continued-exp 9 0.0300000000 0.0033333333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;;cperl-indent-region 1 177.94000000 177.94000000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;; After 1.15:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; Takes into account white space after opening parentheses during indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; May highlight pods and here-documents: see `cperl-pod-here-scan',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;; `cperl-pod-here-fontify', `cperl-pod-face'. Does not use this info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;; for indentation so far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; Fontification updated to 19.30 style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;; The change 19.29->30 did not add all the required functionality,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;; but broke "font-lock-extra.el". Get "choose-color.el" from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;; ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;;; After 1.16:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; else # comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;; recognized as a start of a block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;;; Two different font-lock-levels provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;; `cperl-pod-head-face' introduced. Used for highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;; `imenu' marks pods, +Packages moved to the head.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;;; After 1.17:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; Scan for pods highlights here-docs too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; 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
229 ;;; Only one here-doc-tag per line is supported, and one in comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; or a string may break fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; POD headers were supposed to fill one line only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;;; After 1.18:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; `font-lock-keywords' were set in 19.30 style _always_. Current scheme
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;; may break under XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; `cperl-calculate-indent' dis suppose that `parse-start' was defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;; `fontified' tag is added to fontified text as well as `lazy-lock' (for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; compatibility with older lazy-lock.el) (older one overfontifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;; something nevertheless :-().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;; Will not indent something inside pod and here-documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;; Fontifies the package name after import/no/bootstrap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; Added new entry to menu with meta-info about the mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;;; After 1.19:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; Prefontification works much better with 19.29. Should be checked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; with 19.30 as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;;; Some misprints in docs corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;; Now $a{-text} and -text => "blah" are fontified as strings too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;;; 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
250 ;;; pod sections which are broken because of whitespace before =blah
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;; - just observe the fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;;; After 1.20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;; Anonymous subs are indented with respect to the level of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; indentation of `sub' now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;; {} is recognized as hash after `bless' and `return'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;; Anonymous subs are split by `cperl-linefeed' as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;; Electric parens embrace a region if present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; To make `cperl-auto-newline' useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;; `cperl-auto-newline-after-colon' is introduced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;; `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
262 ;;; `cperl-electric-parens-string'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;; `cperl-toggle-auto-newline' introduced, put on C-c C-a.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;; `cperl-toggle-abbrev' introduced, put on C-c C-k.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;; `cperl-toggle-electric' introduced, put on C-c C-e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;; Beginning-of-defun-regexp was not anchored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;;; After 1.21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;; Auto-newline grants `cperl-extra-newline-before-brace' if "{" is typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;; after ")".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;;; {} is recognized as expression after `tr' and friends.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
272
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
273 ;;;; After 1.22
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
274 ;;; Entry Hierarchy added to imenu. Very primitive so far.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
275 ;;; 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
276 ;;; Writes its own TAGS files.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
277 ;;; Class viewer based on TAGS files. Does not trace @ISA so far.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
278 ;;; 19.31: Problems with scan for PODs corrected.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
279 ;;; First POD header correctly fontified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
280 ;;; 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
281 ;;; Apparently it makes a lot of hierarchy code obsolete...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
282
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
283 ;;;; After 1.23
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
284 ;;; Tags filler now scans *.xs as well.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
285 ;;; The info from *.xs scan is used by the hierarchy viewer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
286 ;;; Hierarchy viewer documented.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
287 ;;; Bug in 19.31 imenu documented.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
288
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
289 ;;;; After 1.24
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
290 ;;; New location for info-files mentioned,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
291 ;;; Electric-; should work better.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
292 ;;; Minor bugs with POD marking.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
293
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
294 ;;;; After 1.25 (probably not...)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
295 ;;; `cperl-info-page' introduced.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
296 ;;; To make `uncomment-region' working, `comment-region' would
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
297 ;;; not insert extra space.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
298 ;;; Here documents delimiters better recognized
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
299 ;;; (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
300 ;;; `cperl-db' added, used in menu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
301 ;;; imenu scan removes text-properties, for better debugging
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
302 ;;; - but the bug is in 19.31 imenu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
303 ;;; formats highlighted by font-lock and prescan, embedded comments
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
304 ;;; are not treated.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
305 ;;; POD/friends scan merged in one pass.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
306 ;;; Syntax class is not used for analyzing the code, only char-syntax
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
307 ;;; may be checked against _ or'ed with w.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
308 ;;; Syntax class of `:' changed to be _.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
309 ;;; `cperl-find-bad-style' added.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
310
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
311 ;;;; After 1.25
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
312 ;;; When search for here-documents, we ignore commented << in simplest cases.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
313 ;;; `cperl-get-help' added, available on C-h v and from menu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
314 ;;; Auto-help added. Default with `cperl-hairy', switchable on/off
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
315 ;;; with startup variable `cperl-lazy-help-time' and from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
316 ;;; menu. Requires `run-with-idle-timer'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
317 ;;; Highlighting of @abc{@efg} was wrong - interchanged two regexps.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
318
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
319 ;;;; After 1.27
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
320 ;;; Indentation: At toplevel after a label - fixed.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
321 ;;; 1.27 was put to archives in binary mode ===> DOSish :-(
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.28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
324 ;;; Thanks to Martin Buchholz <mrb@Eng.Sun.COM>: misprints in
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
325 ;;; comments and docstrings corrected, XEmacs support cleaned up.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
326 ;;; The closing parenths would enclose the region into matching
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
327 ;;; parens under the same conditions as the opening ones.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
328 ;;; Minor updates to `cperl-short-docs'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
329 ;;; Will not consider <<= as start of here-doc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defvar cperl-extra-newline-before-brace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "*Non-nil means that if, elsif, while, until, else, for, foreach
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 and do constructs look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 instead of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 if () {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defvar cperl-indent-level 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 "*Indentation of CPerl statements with respect to containing block.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defvar cperl-lineup-step nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "*`cperl-lineup' will always lineup at multiple of this number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 If `nil', the value of `cperl-indent-level' will be used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (defvar cperl-brace-imaginary-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 "*Imagined indentation of a Perl open brace that actually follows a statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 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
353 to the right of the start of its line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defvar cperl-brace-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "*Extra indentation for braces, compared with other text in same context.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defvar cperl-label-offset -2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "*Offset of CPerl label lines relative to usual indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defvar cperl-min-label-indent 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "*Minimal offset of CPerl label lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defvar cperl-continued-statement-offset 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 "*Extra indent for lines not starting new statements.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defvar cperl-continued-brace-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "*Extra indent for substatements that start with open-braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 This is in addition to cperl-continued-statement-offset.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defvar cperl-close-paren-offset -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "*Extra indent for substatements that start with close-parenthesis.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defvar cperl-auto-newline nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 "*Non-nil means automatically newline before and after braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 and after colons and semicolons, inserted in CPerl code. The following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 \\[cperl-electric-backspace] will remove the inserted whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Insertion after colons requires both this variable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 `cperl-auto-newline-after-colon' set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defvar cperl-auto-newline-after-colon nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "*Non-nil means automatically newline even after colons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Subject to `cperl-auto-newline' setting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar cperl-tab-always-indent t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "*Non-nil means TAB in CPerl mode should always reindent the current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 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
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defvar cperl-font-lock nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "*Non-nil (and non-null) means CPerl buffers will use font-lock-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defvar cperl-electric-lbrace-space nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "*Non-nil (and non-null) means { after $ in CPerl buffers should be preceeded by ` '.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defvar cperl-electric-parens-string "({[<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "*String of parentheses that should be electric in CPerl.")
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-electric-parens nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "*Non-nil (and non-null) means parentheses should be electric in CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 Can be overwritten by `cperl-hairy' if nil.")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
397 (defvar cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
398 (and window-system
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
399 (or (and (boundp 'transient-mark-mode) ; For Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
400 transient-mark-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
401 (and (boundp 'zmacs-regions) ; For XEmacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
402 zmacs-regions)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
403 "*Not-nil means that electric parens look for active mark.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
404 Default is yes if there is visual feedback on mark.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
405
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
406 (defvar cperl-electric-parens-mark (and window-system transient-mark-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "*Not-nil means that electric parens look for active mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 Default is yes if there is visual feedback on mark.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defvar cperl-electric-linefeed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 "*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
412 In any case these two mean plain and hairy linefeeds together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defvar cperl-electric-keywords nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "*Not-nil (and non-null) means keywords are electric in CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defvar cperl-hairy nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "*Not-nil means all the bells and whistles are enabled in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (defvar cperl-comment-column 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 "*Column to put comments in CPerl (use \\[cperl-indent]' to lineup with code).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (defvar cperl-vc-header-alist '((SCCS "$sccs = '%W\%' ;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (RCS "$rcs = ' $Id\$ ' ;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 "*What to use as `vc-header-alist' in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (defvar cperl-info-on-command-no-prompt nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 "*Not-nil (and non-null) means not to prompt on C-h f.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 The opposite behaviour is always available if prefixed with C-c.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
434 (defvar cperl-lazy-help-time nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
435 "*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
436
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (defvar cperl-pod-face 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 "*The result of evaluation of this expression is used for pod highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (defvar cperl-pod-head-face 'font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 "*The result of evaluation of this expression is used for pod highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 Font for POD headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (defvar cperl-here-face 'font-lock-string-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 "*The result of evaluation of this expression is used for here-docs highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (defvar cperl-pod-here-fontify '(featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 "*Not-nil after evaluation means to highlight pod and here-docs sections.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defvar cperl-pod-here-scan t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "*Not-nil means look for pod and here-docs sections during startup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 You can always make lookup from menu or using \\[cperl-find-pods-heres].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
454 (defvar cperl-imenu-addback nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
455 "*Not-nil means add backreferences to generated `imenu's.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
456 May require patched `imenu' and `imenu-go'.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
457
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
458 (defvar cperl-info-page "perl"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
459 "Name of the info page containing perl docs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
460 Older version of this page was called `perl5', newer `perl'.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
461
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;;; Short extra-docs.
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-tips 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 "Get newest version of this package from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
472 Get support packages choose-color.el (or font-lock-extra.el before
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
473 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
474 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
475 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
476 \(and you will not get smart highlighting in C :-().
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 Note that to enable Compile choices in the menu you need to install
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 mode-compile.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Get perl5-info from
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
482 $CPAN/doc/manual/info/perl-info.tar.gz
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
483 older version was on
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 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
485
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
486 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
487 from CPerl menu). If many files are related, generate TAGS files from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
488 Tools/Tags submenu in CPerl menu.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
489
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
490 If some class structure is too complicated, use Tools/Hierarchy-view
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
491 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
492 current buffer only, the first one requires generation of TAGS from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
493 CPerl/Tools/Tags menu beforehand.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
494
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
495 Run CPerl/Tools/Insert-spaces-if-needed to fix your lazy typing.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
496
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
497 Switch auto-help on/off with CPerl/Tools/Auto-help.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 Before reporting (non-)problems look in the problem section on what I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 know about them.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (defvar cperl-problems 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 "Emacs has a _very_ restricted syntax parsing engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 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
506 `non-problems' section if you want to volunteer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 CPerl mode tries to corrects some Emacs misunderstandings, however,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
509 for efficiency reasons the degree of correction is different for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 different operations. The partially corrected problems are: POD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 sections, here-documents, regexps. The operations are: highlighting,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 indentation, electric keywords, electric braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 This may be confusing, since the regexp s#//#/#\; may be highlighted
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
515 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
516 code. Or the opposite case, when a pod section is highlighted, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 breaks the indentation of the following code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 The main trick (to make $ a \"backslash\") makes constructions like
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
520 ${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
521 to insert it as $ {aaa} (legal in perl5, not in perl4).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 Similar problems arise in regexps, when /(\\s|$)/ should be rewritten
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
524 as /($|\\s)/. Note that such a transposition is not always possible
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 :-(. " )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (defvar cperl-non-problems 'please-ignore-this-line
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
528 "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
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 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
531 \(and almost as readable) expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 Try to help it: add comments with embedded quotes to fix CPerl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 misunderstandings about the end of quotation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 $a='500$'; # ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 You won't need it too often. The reason: $ \"quotes\" the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 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
540 Emacs parsing rules it does not consider tick after the dollar as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 closing one, but as a usual character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 Now the indentation code is pretty wise. The only drawback is that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 relies on Emacs parsing to find matching parentheses. And Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 *cannot* match parentheses in Perl 100% correctly. So
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 1 if s#//#/#;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 will not break indentation, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 1 if ( s#//#/# );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 will.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 If you still get wrong indentation in situation that you think the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 code should be able to parse, try:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 a) Check what Emacs thinks about balance of your parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 b) Supply the code to me (IZ).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 Pods are treated _very_ rudimentally. Here-documents are not treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 at all (except highlighting and inhibiting indentation). (This may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 change some time. RMS approved making syntax lookup recognize text
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
560 attributes, but volunteers are needed to change Emacs C code.)
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 To speed up coloring the following compromises exist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 a) sub in $mypackage::sub may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 b) -z in [a-z] may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 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
566
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
567
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
568 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
569 `car' before `imenu-choose-buffer-index' in `imenu'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;;; Portability stuff:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
576 (defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
577 (defmacro cperl-define-key (fsf-key definition &optional xemacs-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
578 `(define-key cperl-mode-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
579 ,(if xemacs-key
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
580 `(if cperl-xemacs-p ,xemacs-key ,fsf-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
581 fsf-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
582 ,definition))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (defvar del-back-ch (car (append (where-is-internal 'delete-backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (where-is-internal 'backward-delete-char-untabify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 "Character generated by key bound to delete-backward-char.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (and (vectorp del-back-ch) (= (length del-back-ch) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (setq del-back-ch (aref del-back-ch 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
591 (if cperl-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; "Active regions" are on: use region only if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;; "Active regions" are off: use region unconditionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (defun cperl-use-region-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (if zmacs-regions (mark) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun cperl-mark-active () (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defun cperl-use-region-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (if transient-mark-mode mark-active t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (defun cperl-mark-active () mark-active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (defsubst cperl-enable-font-lock ()
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
603 (or cperl-xemacs-p window-system))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (if (boundp 'unread-command-events)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
606 (if cperl-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (defun cperl-putback-char (c) ; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq unread-command-events (list (character-to-event c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (defun cperl-putback-char (c) ; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setq unread-command-events (list c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (defun cperl-putback-char (c) ; XEmacs <= 19.11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (setq unread-command-event (character-to-event c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (or (fboundp 'uncomment-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (defun uncomment-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (comment-region beg end -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defvar cperl-do-not-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (if (string< emacs-version "19.30")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 'fontified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 'lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "Text property which inhibits refontification.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
625 (defsubst cperl-put-do-not-fontify (from to)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
626 (put-text-property (max (point-min) (1- from))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
627 to cperl-do-not-fontify t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
628
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;;; 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
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (append '(("\\.[pP][Llm]$" . perl-mode)) auto-mode-alist ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (and (boundp 'interpreter-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (setq interpreter-mode-alist (append interpreter-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 '(("miniperl" . perl-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (if (fboundp 'eval-when-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (require 'imenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; macros instead of defsubsts don't work on Emacs, so we do the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;; expansion manually. Any other suggestions?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (if (or (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 window-system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (require 'font-lock))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defvar cperl-mode-abbrev-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 "Abbrev table in use in Cperl-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (add-hook 'edit-var-mode-alist '(perl-mode (regexp . "^cperl-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (defvar cperl-mode-map () "Keymap used in CPerl mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (if cperl-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (setq cperl-mode-map (make-sparse-keymap))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
663 (cperl-define-key "{" 'cperl-electric-lbrace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
664 (cperl-define-key "[" 'cperl-electric-paren)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
665 (cperl-define-key "(" 'cperl-electric-paren)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
666 (cperl-define-key "<" 'cperl-electric-paren)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
667 (cperl-define-key "}" 'cperl-electric-brace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
668 (cperl-define-key "]" 'cperl-electric-rparen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
669 (cperl-define-key ")" 'cperl-electric-rparen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
670 (cperl-define-key ";" 'cperl-electric-semi)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
671 (cperl-define-key ":" 'cperl-electric-terminator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
672 (cperl-define-key "\C-j" 'newline-and-indent)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
673 (cperl-define-key "\C-c\C-j" 'cperl-linefeed)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
674 (cperl-define-key "\C-c\C-a" 'cperl-toggle-auto-newline)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
675 (cperl-define-key "\C-c\C-k" 'cperl-toggle-abbrev)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
676 (cperl-define-key "\C-c\C-e" 'cperl-toggle-electric)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
677 (cperl-define-key "\e\C-q" 'cperl-indent-exp) ; Usually not bound
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
678 ;;(cperl-define-key "\M-q" 'cperl-fill-paragraph)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
679 ;;(cperl-define-key "\e;" 'cperl-indent-for-comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
680 (cperl-define-key "\177" 'cperl-electric-backspace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
681 (cperl-define-key "\t" 'cperl-indent-command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
682 ;; don't clobber the backspace binding:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
683 (cperl-define-key "\C-hf" 'cperl-info-on-command [(control h) f])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
684 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-current-command
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
685 [(control c) (control h) f])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
686 (cperl-define-key "\C-hv" 'cperl-get-help [(control h) v])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
687 (if (and cperl-xemacs-p
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (<= emacs-minor-version 11) (<= emacs-major-version 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;; substitute-key-definition is usefulness-deenhanced...
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
691 (cperl-define-key "\M-q" 'cperl-fill-paragraph)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
692 (cperl-define-key "\e;" 'cperl-indent-for-comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
693 (cperl-define-key "\e\C-\\" 'cperl-indent-region))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 'indent-sexp 'cperl-indent-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 'fill-paragraph 'cperl-fill-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 'indent-region 'cperl-indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 'indent-for-comment 'cperl-indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 cperl-mode-map global-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (easy-menu-define cperl-menu cperl-mode-map "Menu for CPerl mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 '("Perl"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ["Beginning of function" beginning-of-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ["End of function" end-of-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ["Mark function" mark-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ["Indent expression" cperl-indent-exp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 ["Fill paragraph/comment" cperl-fill-paragraph t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ["Line up a construction" cperl-lineup (cperl-use-region-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ["Indent region" cperl-indent-region (cperl-use-region-p)]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
720 ["Comment region" cperl-comment-region (cperl-use-region-p)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
721 ["Uncomment region" cperl-uncomment-region (cperl-use-region-p)]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 ["Run" mode-compile (fboundp 'mode-compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ["Kill" mode-compile-kill (and (fboundp 'mode-compile-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (get-buffer "*compilation*"))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ["Next error" next-error (get-buffer "*compilation*")]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ["Check syntax" cperl-check-syntax (fboundp 'mode-compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 "----"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
729 ["Debugger" cperl-db t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 ("Tools"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ["Imenu" imenu (fboundp 'imenu)]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
733 ["Insert spaces if needed" cperl-find-bad-style t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
734 ["Class Hierarchy from TAGS" cperl-tags-hier-init t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
735 ;;["Update classes" (cperl-tags-hier-init t) tags-table-list]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ["Imenu on info" cperl-imenu-on-info (featurep 'imenu)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ("Tags"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
738 ;;; ["Create tags for current file" cperl-etags t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
739 ;;; ["Add tags for current file" (cperl-etags t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
740 ;;; ["Create tags for Perl files in directory" (cperl-etags nil t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
741 ;;; ["Add tags for Perl files in directory" (cperl-etags t t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
742 ;;; ["Create tags for Perl files in (sub)directories"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
743 ;;; (cperl-etags nil 'recursive) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
744 ;;; ["Add tags for Perl files in (sub)directories"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
745 ;;; (cperl-etags t 'recursive) t])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
746 ;;;; cperl-write-tags (&optional file erase recurse dir inbuffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
747 ["Create tags for current file" (cperl-write-tags nil t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
748 ["Add tags for current file" (cperl-write-tags) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
749 ["Create tags for Perl files in directory"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
750 (cperl-write-tags nil t nil t) t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
751 ["Add tags for Perl files in directory"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
752 (cperl-write-tags nil nil nil t) t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ["Create tags for Perl files in (sub)directories"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
754 (cperl-write-tags nil t t t) t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ["Add tags for Perl files in (sub)directories"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
756 (cperl-write-tags nil nil t t) t])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
757 ["Recalculate PODs and HEREs" cperl-find-pods-heres t]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ["Define word at point" imenu-go-find-at-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (fboundp 'imenu-go-find-at-position)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ["Help on function" cperl-info-on-command t]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
761 ["Help on function at point" cperl-info-on-current-command t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
762 ["Help on symbol at point" cperl-get-help t]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
763 ["Auto-help on" cperl-lazy-install (fboundp 'run-with-idle-timer)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
764 ["Auto-help off" cperl-lazy-unstall
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
765 (fboundp 'run-with-idle-timer)])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ("Toggle..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ["Auto newline" cperl-toggle-auto-newline t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ["Electric parens" cperl-toggle-electric t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ["Electric keywords" cperl-toggle-abbrev t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ("Indent styles..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ["GNU" (cperl-set-style "GNU") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ["C++" (cperl-set-style "C++") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ["FSF" (cperl-set-style "FSF") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ["BSD" (cperl-set-style "BSD") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ["Whitesmith" (cperl-set-style "Whitesmith") t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ("Micro-docs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ["Tips" (describe-variable 'cperl-tips) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ["Problems" (describe-variable 'cperl-problems) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ["Non-problems" (describe-variable 'cperl-non-problems) t]))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (autoload 'c-macro-expand "cmacexp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 "Display the result of expanding all C macros occurring in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 The expansion is entirely correct because it uses the C preprocessor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (defvar cperl-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 "Syntax table in use in Cperl-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (if cperl-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (setq cperl-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (modify-syntax-entry ?\\ "\\" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (modify-syntax-entry ?/ "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (modify-syntax-entry ?* "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (modify-syntax-entry ?+ "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (modify-syntax-entry ?- "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (modify-syntax-entry ?= "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (modify-syntax-entry ?% "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (modify-syntax-entry ?< "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (modify-syntax-entry ?> "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (modify-syntax-entry ?& "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (modify-syntax-entry ?$ "\\" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (modify-syntax-entry ?\n ">" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (modify-syntax-entry ?# "<" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (modify-syntax-entry ?' "\"" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (modify-syntax-entry ?` "\"" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (modify-syntax-entry ?_ "w" cperl-mode-syntax-table)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
810 (modify-syntax-entry ?: "_" cperl-mode-syntax-table)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (modify-syntax-entry ?| "." cperl-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; Make customization possible "in reverse"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;;(defun cperl-set (symbol to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;; (or (eq (symbol-value symbol) 'null) (set symbol to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (defsubst cperl-val (symbol &optional default hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ((eq (symbol-value symbol) 'null) default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (cperl-hairy (or hairy t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (t (symbol-value symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; provide an alias for working with emacs 19. the perl-mode that comes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; with it is really bad, and this lets us seamlessly replace it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (fset 'perl-mode 'cperl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (defun cperl-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 "Major mode for editing Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 Expression and list commands understand all C brackets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 Tab indents for Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 Paragraphs are separated by blank lines only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 Delete converts tabs to spaces as it moves back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 Various characters in Perl almost always come in pairs: {}, (), [],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 sometimes <>. When the user types the first, she gets the second as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 well, with optional special formatting done on {}. (Disabled by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 default.) You can always quote (with \\[quoted-insert]) the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 \"paren\" to avoid the expansion. The processing of < is special,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 since most the time you mean \"less\". Cperl mode tries to guess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 whether you want to type pair <>, and inserts is if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 appropriate. You can set `cperl-electric-parens-string' to the string that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 contains the parenths from the above list you want to be electrical.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 Electricity of parenths is controlled by `cperl-electric-parens'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 You may also set `cperl-electric-parens-mark' to have electric parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 look for active mark and \"embrace\" a region if possible.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 CPerl mode provides expansion of the Perl control constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 if, else, elsif, unless, while, until, for, and foreach.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 =========(Disabled by default, see `cperl-electric-keywords'.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 The user types the keyword immediately followed by a space, which causes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 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
852 likely to want to be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 eg. when the user types a space following \"if\" the following appears in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 the buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 if () { or if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 } {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 and the cursor is between the parentheses. The user can then type some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 boolean expression within the parens. Having done that, typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 \\[cperl-linefeed] places you, appropriately indented on a new line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 between the braces. If CPerl decides that you want to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 \"English\" style construct like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 bite if angry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 it will not do any expansion. See also help on variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 `cperl-extra-newline-before-brace'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
867 \\[cperl-linefeed] is a convenience replacement for typing carriage
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 return. It places you in the next line with proper indentation, or if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 you type it inside the inline block of control construct, like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 foreach (@lines) {print; print}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 and you are on a boundary of a statement inside braces, it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 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
873 appropriately indented blank line. If you need a usual
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 `newline-and-indent' behaviour, it is on \\[newline-and-indent],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 see documentation on `cperl-electric-linefeed'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 \\{cperl-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 Setting the variable `cperl-font-lock' to t switches on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 font-lock-mode, `cperl-electric-lbrace-space' to t switches on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 electric space between $ and {, `cperl-electric-parens-string' is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 string that contains parentheses that should be electric in CPerl (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 also `cperl-electric-parens-mark' and `cperl-electric-parens'),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 setting `cperl-electric-keywords' enables electric expansion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 control structures in CPerl. `cperl-electric-linefeed' governs which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 one of two linefeed behavior is preferable. You can enable all these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 options simultaneously (recommended mode of use) by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 `cperl-hairy' to t. In this case you can switch separate options off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 by setting them to `null'. Note that one may undo the extra whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 inserted by semis and braces in `auto-newline'-mode by consequent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 \\[cperl-electric-backspace].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 If your site has perl5 documentation in info format, you can use commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 \\[cperl-info-on-current-command] and \\[cperl-info-on-command] to access it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 These keys run commands `cperl-info-on-current-command' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 `cperl-info-on-command', which one is which is controlled by variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 `cperl-info-on-command-no-prompt' (in turn affected by `cperl-hairy').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
899 Even if you have no info-format documentation, short one-liner-style
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
900 help is available on \\[cperl-get-help].
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
901
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
902 It is possible to show this help automatically after some idle
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
903 time. This is regulated by variable `cperl-lazy-help-time'. Default
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
904 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
905 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
906 menu. Requires `run-with-idle-timer'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
907
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 Variables `cperl-pod-here-scan', `cperl-pod-here-fontify',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 `cperl-pod-face', `cperl-pod-head-face' control processing of pod and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 here-docs sections. In a future version results of scan may be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 for indentation too, currently they are used for highlighting only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 Variables controlling indentation style:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 `cperl-tab-always-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 Non-nil means TAB in CPerl mode should always reindent the current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 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
917 `cperl-auto-newline'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 Non-nil means automatically newline before and after braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 and after colons and semicolons, inserted in Perl code. The following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 \\[cperl-electric-backspace] will remove the inserted whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 Insertion after colons requires both this variable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 `cperl-auto-newline-after-colon' set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 `cperl-auto-newline-after-colon'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 Non-nil means automatically newline even after colons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 Subject to `cperl-auto-newline' setting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 `cperl-indent-level'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 Indentation of Perl statements within surrounding block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 The surrounding block's indentation is the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 of the line on which the open-brace appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 `cperl-continued-statement-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 Extra indentation given to a substatement, such as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 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
933 `cperl-continued-brace-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 Extra indentation given to a brace that starts a substatement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 This is in addition to `cperl-continued-statement-offset'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 `cperl-brace-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 Extra indentation for line if it starts with an open brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 `cperl-brace-imaginary-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 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
940 this far to the right of the actual line indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 `cperl-label-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 Extra indentation for line that is a label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 `cperl-min-label-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 Minimal indentation for line that is a label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 Settings for K&R and BSD indentation styles are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 `cperl-indent-level' 5 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 `cperl-continued-statement-offset' 5 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 `cperl-brace-offset' -5 -8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 `cperl-label-offset' -5 -8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 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
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 Turning on CPerl mode calls the hooks in the variable `cperl-mode-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 with no args."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;;(if cperl-hairy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 ;; (cperl-set 'cperl-font-lock cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;; (cperl-set 'cperl-electric-lbrace-space cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;; (cperl-set 'cperl-electric-parens "{[(<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;; (cperl-set 'cperl-electric-keywords cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 ;; (cperl-set 'cperl-electric-linefeed cperl-hairy)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (use-local-map cperl-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (if (cperl-val 'cperl-electric-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (local-set-key "\C-J" 'cperl-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (local-set-key "\C-C\C-J" 'newline-and-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (if (cperl-val 'cperl-info-on-command-no-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (progn
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
972 ;; don't clobber the backspace binding:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
973 (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
974 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-command
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
975 [(control c) (control h) f])))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (setq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (setq mode-name "CPerl")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (if (not cperl-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (let ((prev-a-c abbrevs-changed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (define-abbrev-table 'cperl-mode-abbrev-table '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ("if" "if" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ("elsif" "elsif" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ("while" "while" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 ("until" "until" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 ("unless" "unless" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ("else" "else" cperl-electric-else 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ("for" "for" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ("foreach" "foreach" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ("do" "do" cperl-electric-keyword 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (setq abbrevs-changed prev-a-c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (setq local-abbrev-table cperl-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (abbrev-mode (if (cperl-val 'cperl-electric-keywords) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (set-syntax-table cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (setq paragraph-start (concat "^$\\|" page-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (setq paragraph-separate paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (make-local-variable 'paragraph-ignore-fill-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (setq paragraph-ignore-fill-prefix t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (make-local-variable 'indent-line-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (setq indent-line-function 'cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (setq require-final-newline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (setq comment-start "# ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (make-local-variable 'comment-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (setq comment-end "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (make-local-variable 'comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (setq comment-column cperl-comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (make-local-variable 'comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (setq comment-start-skip "#+ *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (make-local-variable 'defun-prompt-regexp)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1013 (setq defun-prompt-regexp "^[ \t]*sub[ \t]+\\([^ \t\n{;]+\\)[ \t]*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (make-local-variable 'comment-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (setq comment-indent-function 'cperl-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (make-local-variable 'parse-sexp-ignore-comments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (setq parse-sexp-ignore-comments t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (make-local-variable 'indent-region-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (setq indent-region-function 'cperl-indent-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;;(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
1021 (make-local-variable 'imenu-create-index-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (setq imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (function imenu-example--create-perl-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (make-local-variable 'imenu-sort-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (setq imenu-sort-function nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (make-local-variable 'vc-header-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (setq vc-header-alist cperl-vc-header-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (setq font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (if (string< emacs-version "19.30")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 '(perl-font-lock-keywords-2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 '((perl-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 perl-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 perl-font-lock-keywords-2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (or (fboundp 'cperl-old-auto-fill-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (fset 'cperl-old-auto-fill-mode (symbol-function 'auto-fill-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (defun auto-fill-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (cperl-old-auto-fill-mode arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (and auto-fill-function (eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (setq auto-fill-function 'cperl-do-auto-fill)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (if (cperl-enable-font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (if (cperl-val 'cperl-font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (progn (or cperl-faces-init (cperl-init-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (font-lock-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (and (boundp 'msb-menu-cond)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (not cperl-msb-fixed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (cperl-msb-fix))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1050 (if (featurep 'easymenu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1051 (easy-menu-add cperl-menu)) ; A NOP under FSF Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (run-hooks 'cperl-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 ;; After hooks since fontification will break this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (if cperl-pod-here-scan (cperl-find-pods-heres)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1056 ;; Fix for perldb - make default reasonable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1057 (defun cperl-db ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1058 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1059 (require 'gud)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1060 (perldb (read-from-minibuffer "Run perldb (like this): "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1061 (if (consp gud-perldb-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1062 (car gud-perldb-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1063 (concat "perl " ;;(file-name-nondirectory
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1064 ;; I have problems
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1065 ;; in OS/2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1066 ;; otherwise
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1067 (buffer-file-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1068 nil nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1069 '(gud-perldb-history . 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1070
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 ;; Fix for msb.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (defvar cperl-msb-fixed nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (defun cperl-msb-fix ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ;; Adds perl files to msb menu, supposes that msb is already loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (setq cperl-msb-fixed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (let* ((l (length msb-menu-cond))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (last (nth (1- l) msb-menu-cond))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (handle (1- (nth 1 last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (setcdr precdr (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 '(eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 "Perl Files (%d)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 ;; This is used by indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; to decide how much to indent a comment in CPerl code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ;; based on its context. Do fallback if comment is found wrong.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (defvar cperl-wrong-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (defun cperl-comment-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (let ((p (point)) (c (current-column)) was)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (if (looking-at "^#") 0 ; Existing comment at bol stays there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;; Wrong comment found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (setq was (cperl-to-comment-or-eol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (if (= (point) p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (max (1+ (current-column)) ; Else indent at comment column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (if was nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (insert comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (backward-char (length comment-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (setq cperl-wrong-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (indent-to comment-column 1) ; Indent minimum 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 c))))) ; except leave at least one space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 ;;;(defun cperl-comment-indent-fallback ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 ;;; "Is called if the standard comment-search procedure fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;;;Point is at start of real comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;;; (let ((c (current-column)) target cnt prevc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ;;; (if (= c comment-column) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ;;; (setq cnt (skip-chars-backward "[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;;; (setq target (max (1+ (setq prevc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;;; (current-column))) ; Else indent at comment column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 ;;; comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;;; (if (= c comment-column) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 ;;; (delete-backward-char cnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 ;;; (while (< prevc target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ;;; (insert "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 ;;; (setq prevc (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 ;;; (if (> prevc target) (progn (delete-char -1) (setq prevc (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 ;;; (while (< prevc target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 ;;; (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 ;;; (setq prevc (current-column)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (defun cperl-indent-for-comment ()
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1132 "Substitute for `indent-for-comment' in CPerl."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (let (cperl-wrong-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (if cperl-wrong-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (progn (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (forward-char (length comment-start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1140 (defun cperl-comment-region (b e arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1141 "Comment or uncomment each line in the region in CPerl mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1142 See `comment-region'."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1143 (interactive "r\np")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1144 (let ((comment-start "#"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1145 (comment-region b e arg)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1146
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1147 (defun cperl-uncomment-region (b e arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1148 "Uncomment or comment each line in the region in CPerl mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1149 See `comment-region'."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1150 (interactive "r\np")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1151 (let ((comment-start "#"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1152 (comment-region b e (- arg))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1153
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1154 (defvar cperl-brace-recursing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1155
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (defun cperl-electric-brace (arg &optional only-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 "Insert character and correct line's indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 If ONLY-BEFORE and `cperl-auto-newline', will insert newline before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 place (even in empty line), but not after. If after \")\" and the inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 char is \"{\", insert extra newline before only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 `cperl-extra-newline-before-brace'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (interactive "P")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1163 (let (insertpos
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1164 (other-end (if (and cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1165 (cperl-mark-active)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1166 (< (mark) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1167 (mark)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1168 nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1169 (if (and other-end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1170 (not cperl-brace-recursing)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1171 (cperl-val 'cperl-electric-parens)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1172 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1173 ;; Need to insert a matching pair
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1176 (setq insertpos (point-marker))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1177 (goto-char other-end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1178 (setq last-command-char ?\{)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1179 (cperl-electric-lbrace arg insertpos))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1180 (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1181 (if (and (not arg) ; No args, end (of empty line or auto)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1182 (eolp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1183 (or (and (null only-before)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1184 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1185 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1186 (bolp)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1187 (and (eq last-command-char ?\{) ; Do not insert newline
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1188 ;; if after ")" and `cperl-extra-newline-before-brace'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1189 ;; is nil, do not insert extra newline.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1190 (not cperl-extra-newline-before-brace)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1191 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1192 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1193 (eq (preceding-char) ?\))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1194 (if cperl-auto-newline
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1195 (progn (cperl-indent-line) (newline) t) nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1196 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1197 (if cperl-auto-newline
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1198 (setq insertpos (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1199 (insert last-command-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1200 (cperl-indent-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1201 (if (and cperl-auto-newline (null only-before))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1202 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1203 (newline)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1204 (cperl-indent-line)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1205 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1206 (if insertpos (progn (goto-char insertpos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1207 (search-forward (make-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1208 1 last-command-char))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1209 (setq insertpos (1- (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1210 (delete-char -1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1211 (if insertpos
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1212 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1213 (goto-char insertpos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1214 (self-insert-command (prefix-numeric-value arg)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1215 (self-insert-command (prefix-numeric-value arg))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1216
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1217 (defun cperl-electric-lbrace (arg &optional end)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 "Insert character, correct line's indentation, correct quoting by space."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (let (pos after
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1221 (cperl-brace-recursing t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (cperl-auto-newline cperl-auto-newline)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1223 (other-end (or end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1224 (if (and cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1225 (cperl-mark-active)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1226 (> (mark) (point)))
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 (goto-char (mark))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1229 (point-marker))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1230 nil))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (and (cperl-val 'cperl-electric-lbrace-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (eq (preceding-char) ?$)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (skip-chars-backward "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (insert ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (if (cperl-after-expr-p nil "{};)") nil (setq cperl-auto-newline nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (cperl-electric-brace arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (and (cperl-val 'cperl-electric-parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (eq last-command-char ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (memq last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (append cperl-electric-parens-string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (or (if other-end (goto-char (marker-position other-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (setq last-command-char ?} pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (progn (cperl-electric-brace arg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (goto-char pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (defun cperl-electric-paren (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 "Insert a matching pair of parentheses."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (other-end (if (and cperl-electric-parens-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (cperl-mark-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (> (mark) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (goto-char (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (if (and (cperl-val 'cperl-electric-parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (memq last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (append cperl-electric-parens-string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;;(not (save-excursion (search-backward "#" beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (if (eq last-command-char ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (cperl-after-expr-p nil "{};(,:=")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (if other-end (goto-char (marker-position other-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (insert (cdr (assoc last-command-char '((?{ .?})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (?[ . ?])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (?( . ?))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (?< . ?>)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1279 (defun cperl-electric-rparen (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1280 "Insert a matching pair of parentheses if marking is active.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1281 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
1282 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1283 (let ((beg (save-excursion (beginning-of-line) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1284 (other-end (if (and cperl-electric-parens-mark
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1285 (cperl-mark-active)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1286 (< (mark) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1287 (mark)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1288 nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1289 p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1290 (if (and other-end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1291 (cperl-val 'cperl-electric-parens)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1292 (memq last-command-char '( ?\) ?\] ?\} ?\> ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1293 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1294 ;;(not (save-excursion (search-backward "#" beg t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1295 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1296 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1297 (insert last-command-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1298 (setq p (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1299 (if other-end (goto-char other-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1300 (insert (cdr (assoc last-command-char '((?\} . ?\{)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1301 (?\] . ?\[)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1302 (?\) . ?\()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1303 (?\> . ?\<)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1304 (goto-char (1+ p)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1305 (call-interactively 'self-insert-command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1306 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1307
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (defun cperl-electric-keyword ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 "Insert a construction appropriate after a keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (let ((beg (save-excursion (beginning-of-line) (point)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1311 (dollar (eq last-command-char ?$)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (cperl-after-expr-p nil "{};:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (save-excursion (or (not (re-search-backward "^=" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (looking-at "=cut")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (and dollar (insert " $"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ;;(insert " () {\n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (cperl-extra-newline-before-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (insert " ()\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (insert "{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (insert "\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (insert " () {\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (or (looking-at "[ \t]\\|$") (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (if dollar (progn (search-backward "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (search-backward ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (cperl-putback-char del-back-ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (defun cperl-electric-else ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 "Insert a construction appropriate after a keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (let ((beg (save-excursion (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (cperl-after-expr-p nil "{};:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (save-excursion (or (not (re-search-backward "^=" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (looking-at "=cut")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ;;(insert " {\n\n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (cperl-extra-newline-before-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (insert "{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (insert "\n\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (insert " {\n\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (or (looking-at "[ \t]\\|$") (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (cperl-putback-char del-back-ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (defun cperl-linefeed ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 "Go to end of line, open a new line and indent appropriately."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (end (save-excursion (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (pos (point)) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (if (and ; Check if we need to split:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ; i.e., on a boundary and inside "{...}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (save-excursion (cperl-to-comment-or-eol)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1384 (>= (point) pos)) ; Not in a comment
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (skip-chars-backward " \t" beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (forward-char -1)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1388 (looking-at "[;{]")) ; After { or ; + spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1389 (looking-at "[ \t]*}") ; Before }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1390 (re-search-forward "\\=[ \t]*;" end t)) ; Before spaces + ;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (and
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1393 (eq (car (parse-partial-sexp pos end -1)) -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1394 ; Leave the level of parens
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (looking-at "[,; \t]*\\($\\|#\\)") ; Comma to allow anon subr
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1396 ; Are at end
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (setq start (point-marker))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1400 (<= start pos))))) ; Redundant? Are after the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1401 ; start of parens group.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (or (memq (preceding-char) (append ";{" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (insert ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (or (looking-at "{[ \t]*$") ; If there is a statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ; before, move it to separate line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (forward-line 1) ; We are on the target line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (or (looking-at "[ \t]*}[,; \t]*$") ; If there is a statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ; after, move it to separate line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (search-backward "}" beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (or (memq (preceding-char) (append ";{" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (insert ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (forward-line -1) ; We are on the line before target
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (end-of-line) ; else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1434 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1435 ((and (looking-at "\n[ \t]*{$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1436 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1437 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1438 (eq (preceding-char) ?\)))) ; Probably if () {} group
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1439 ; with an extra newline.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1440 (forward-line 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1441 (cperl-indent-line))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1442 ((looking-at "\n[ \t]*$") ; Next line is empty - use it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1443 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1444 (cperl-indent-line))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1445 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1446 (newline-and-indent))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (defun cperl-electric-semi (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 "Insert character and correct line's indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (if cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (cperl-electric-terminator arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (self-insert-command (prefix-numeric-value arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (defun cperl-electric-terminator (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 "Insert character and correct line's indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (let (insertpos (end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (auto (and cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (or (not (eq last-command-char ?:))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 cperl-auto-newline-after-colon))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1462 (if (and ;;(not arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1463 (eolp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;; Ignore in comment lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (= (following-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 ;; Colon is special only after a label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 ;; So quickly rule out most other uses of colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 ;; and do no indentation for them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (and (eq last-command-char ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (progn (goto-char (- end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (not (looking-at ":"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (let ((pps (parse-partial-sexp (point) end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (insert last-command-char)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1486 ;;(forward-char -1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (if auto (setq insertpos (point-marker)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1488 ;;(forward-char 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (if auto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;; (if insertpos (progn (goto-char (marker-position insertpos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;; (search-forward (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; 1 last-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; (setq insertpos (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ;; (delete-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1501 (if insertpos (goto-char (1- (marker-position insertpos)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (delete-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (if insertpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (goto-char insertpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (self-insert-command (prefix-numeric-value arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (self-insert-command (prefix-numeric-value arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (defun cperl-electric-backspace (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 "Backspace-untabify, or remove the whitespace inserted by an electric key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (if (and cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (memq last-command '(cperl-electric-semi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 cperl-electric-terminator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 cperl-electric-lbrace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (memq (preceding-char) '(? ?\t ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (let (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (if (eq last-command 'cperl-electric-lbrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (skip-chars-forward " \t\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (delete-region (point) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (backward-delete-char-untabify arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (defun cperl-inside-parens-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (progn (beginning-of-defun) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (= (char-after (or (scan-lists (point) -1 1) (point-min))) ?\()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (defun cperl-indent-command (&optional whole-exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 "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
1538 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
1539 Otherwise, indent the current line only if point is at the left margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 or in the line's indentation; otherwise insert a tab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 A numeric argument, regardless of its value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 means indent rigidly all the lines of the expression starting after point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 so that this line becomes properly indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 The relative indentation among the lines of the expression are preserved."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1546 (interactive "P")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (if whole-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 ;; If arg, always indent this line as Perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; and shift remaining lines of expression the same amount.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (let ((shift-amt (cperl-indent-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (if cperl-tab-always-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (setq beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (if (> end beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (indent-code-rigidly beg end shift-amt "#")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (if (and (not cperl-tab-always-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (not (bolp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (insert-tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (cperl-indent-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (defun cperl-indent-line (&optional symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 "Indent current line as Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 Return the amount the indentation changed by."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (let (indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 beg shift-amt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (pos (- (point-max) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (setq indent (cperl-calculate-indent nil symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (cond ((eq indent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (setq indent (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ;;((eq indent t) ; Never?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 ;; (setq indent (cperl-calculate-indent-within-comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;;((looking-at "[ \t]*#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 ;; (setq indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (if (listp indent) (setq indent (car indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (cond ((looking-at "[A-Za-z]+:[^:]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (and (> indent 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (setq indent (max cperl-min-label-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (+ indent cperl-label-offset)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ((= (following-char) ?})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (setq indent (- indent cperl-indent-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 ((memq (following-char) '(?\) ?\])) ; To line up with opening paren.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (setq indent (+ indent cperl-close-paren-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 ((= (following-char) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (setq indent (+ indent cperl-brace-offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (setq shift-amt (- indent (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (if (zerop shift-amt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (if (> (- (point-max) pos) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (goto-char (- (point-max) pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (indent-to indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 ;; If initial point was within line's indentation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 ;; position after the indentation. Else stay at same point in text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (if (> (- (point-max) pos) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (goto-char (- (point-max) pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 shift-amt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (defun cperl-after-label ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 ;; Returns true if the point is after label. Does not do save-excursion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (and (eq (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (memq (char-syntax (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 '(?w ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (backward-sexp)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1619 (looking-at "[a-zA-Z_][a-zA-Z0-9_]*:[^:]"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (defun cperl-get-state (&optional parse-start start-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 ;; returns list (START STATE DEPTH PRESTART), START is a good place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 ;; to start parsing, STATE is what is returned by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ;; `parse-partial-sexp'. DEPTH is true is we are immediately after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ;; end of block which contains START. PRESTART is the position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ;; basing on which START was found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (let ((start-point (point)) depth state start prestart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (beginning-of-defun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (setq prestart (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (if start-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; Try to go out, if sub is not on the outermost level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (while (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (setq start (point) parse-start start depth nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 state (parse-partial-sexp start start-point -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (if (> (car state) -1) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;; The current line could start like }}}, so the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 ;; corresponds to a different level than what we reached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (setq depth t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (beginning-of-line 2))) ; Go to the next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (if start (goto-char start))) ; Not at the start of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (if (< start start-point) (setq parse-start start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (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
1647 (list start state depth prestart))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (defun cperl-block-p () ; Do not C-M-q ! One string contains ";" !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ;; Positions is before ?\{. Checks whether it starts a block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; No save-excursion!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (cperl-backward-to-noncomment (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ;;(skip-chars-backward " \t\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (or (memq (preceding-char) (append ";){}$@&%\C-@" nil)) ; Or label! \C-@ at bobp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ; Label may be mixed up with `$blah :'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (save-excursion (cperl-after-label))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1657 (and (memq (char-syntax (preceding-char)) '(?w ?_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ;; Need take into account `bless', `return', `tr',...
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1661 (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
1662 (not (looking-at "\\(bless\\|return\\|qw\\|tr\\|[smy]\\)\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (skip-chars-backward " \t\n\f")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1665 (and (memq (char-syntax (preceding-char)) '(?w ?_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (looking-at
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1669 "sub[ \t]+[a-zA-Z0-9_:]+[ \t\n\f]*[#{]")))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (defun cperl-calculate-indent (&optional parse-start symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 "Return appropriate indentation for current line as Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 In usual case returns an integer: the column to indent to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 Returns nil if line starts inside a string, t if in a comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (if (memq (get-text-property (point) 'syntax-type) '(pod here-doc)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (let* ((indent-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (s-s (cperl-get-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (start (nth 0 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (state (nth 1 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (containing-sexp (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (char-after (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (start-indent (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (- (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (if (nth 2 s-s) cperl-indent-level 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 old-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;; (or parse-start (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 ;; (setq parse-start (symbol-value symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 ;; start-indent (nth 2 parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 ;; parse-start (car parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 ;; (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 ;; (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 ;; (beginning-of-defun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;; ;; Try to go out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 ;; (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 ;; (setq start (point) parse-start start moved nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 ;; state (parse-partial-sexp start indent-point -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 ;; (if (> (car state) -1) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 ;; ;; The current line could start like }}}, so the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 ;; ;; corresponds to a different level than what we reached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 ;; (setq moved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 ;; (beginning-of-line 2))) ; Go to the next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 ;; (if start ; Not at the start of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ;; (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 ;; (setq start-indent (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; (if moved ; Should correct...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 ;; (setq start-indent (- start-indent cperl-indent-level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ;; (setq start-indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ;; (if (< (point) indent-point) (setq parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; (or state (setq state (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; (point) indent-point -1 nil start-state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 ;; (setq containing-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;; (or (car (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ;; (and (>= (nth 6 state) 0) old-containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ;; old-containing-sexp nil start-state nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 ;;;; (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 ;;;; (setq parse-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 ;;;; (setq state (parse-partial-sexp (point) indent-point -1 nil start-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 ;;;; (setq containing-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 ;;;; (or (car (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 ;;;; (and (>= (nth 6 state) 0) old-containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 ;;;; old-containing-sexp nil start-state nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 ;; (if symbol (set symbol (list indent-point state start-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 ;; (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (cond ((or (nth 3 state) (nth 4 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 ;; return nil or t if should not change this line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (nth 4 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ((null containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ;; Line is at top level. May be data or function definition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ;; or may be function argument declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ;; Indent like the previous top level line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ;; unless that ends in a closeparen without semicolon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ;; in which case this line is the first argument decl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (+ start-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (if (= (following-char) ?{) cperl-continued-brace-offset 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (cperl-backward-to-noncomment (or parse-start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;;(skip-chars-backward " \t\f\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; Look at previous line that's at column 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; to determine whether we are in top-level decls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ;; or function's arg decls. Set basic-indent accordingly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ;; Now add a little if this is a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (if (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (memq (preceding-char) (append " ;}" nil)) ; Was ?\)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1752 (memq char-after (append ")]}" nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1753 (and (eq (preceding-char) ?\:) ; label
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1754 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1755 (forward-sexp -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1756 (skip-chars-backward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1757 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 cperl-continued-statement-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 ((/= (char-after containing-sexp) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 ;; line is expression, not statement:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ;; indent to just after the surrounding open,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ;; skip blanks if we do not close the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (or (memq char-after (append ")]}" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 ;; Containing-expr starts with \{. Check whether it is a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (not (cperl-block-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (or (eq char-after ?\})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (+ (current-column) ; Correct indentation of trailing ?\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (if (eq char-after ?\}) (+ cperl-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 cperl-close-paren-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ;; Statement level. Is it a continuation or a new statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ;; Find previous non-comment character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (cperl-backward-to-noncomment containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ;; Back up over label lines, since they don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; affect whether our line is a continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (while (or (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (and (eq (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (or;;(eq (char-after (- (point) 2)) ?\') ; ????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (memq (char-syntax (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 '(?w ?_)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (if (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; Will go to beginning of line, essentially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 ;; Will ignore embedded sexpr XXXX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (cperl-backward-to-start-of-continued-exp containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (cperl-backward-to-noncomment containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;; Now we get the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (if (not (memq (preceding-char) (append ", ;}{" '(nil)))) ; Was ?\,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ;; This line is continuation of preceding line's statement;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ;; indent `cperl-continued-statement-offset' more than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ;; previous line of the statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (cperl-backward-to-start-of-continued-exp containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (+ (if (memq char-after (append "}])" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 0 ; Closing parenth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (if (eq char-after ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 cperl-continued-brace-offset 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 ;; This line starts a new statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ;; Is line first statement after an open-brace?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; If no, find that first statement and indent like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 ;; it. If the first statement begins with label, do
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1819 ;; not believe when the indentation of the label is too
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 ;; small.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (setq old-indent (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (let ((colon-line-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (while (progn (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (looking-at "#\\|[a-zA-Z0-9_$]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 ;; Skip over comments and labels following openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (cond ((= (following-char) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 ;; label:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (setq colon-line-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (search-forward ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ;; The first following code counts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ;; if it is before the line we want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (and (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (if (> colon-line-end (point)) ; After label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (if (> (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (- (current-indentation) cperl-label-offset)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1842 ;; Do not believe: `max' is involved
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (+ old-indent cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (current-column)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ;; If no previous statement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ;; indent it relative to line brace is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 ;; For open brace in column zero, don't let statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 ;; start there too. If cperl-indent-level is zero,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 ;; For open-braces not the first thing in a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ;; add in cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 ;; If first thing on a line: ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (+ (if (and (bolp) (zerop cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (+ cperl-brace-offset cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 cperl-indent-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ;; Move back over whitespace before the openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ;; If openbrace is not first nonwhite thing on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ;; add the cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (if (bolp) 0 cperl-brace-imaginary-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 ;; If the openbrace is preceded by a parenthesized exp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 ;; move to the beginning of that;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ;; possibly a different line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (if (eq (preceding-char) ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 ;; In the case it starts a subroutine, indent with
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1869 ;; respect to `sub', not with respect to the the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 ;; first thing on the line, say in the case of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 ;; anonymous sub in a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (if (and (eq (preceding-char) ?b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (looking-at "sub\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (setq old-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (nth 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (save-excursion (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (progn (goto-char (1+ old-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;; Get initial indentation of the line we are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 ;; If line starts with label, calculate label indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (if (> (current-indentation) cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (cperl-calculate-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (if (and parse-start (<= parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (current-indentation)))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (defvar cperl-indent-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 '((string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (comment nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (toplevel 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (toplevel-after-parenth 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (toplevel-continued 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (expression 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 "Alist of indentation rules for CPerl mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 The values mean:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 nil: do not indent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 number: add this amount of indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (defun cperl-where-am-i (&optional parse-start start-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ;; Unfinished
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 "Return a list of lists ((TYPE POS)...) of good points before the point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 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
1914 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (let* ((start-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (s-s (cperl-get-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (start (nth 0 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (state (nth 1 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (prestart (nth 3 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (containing-sexp (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (res (list (list 'parse-start start) (list 'parse-prestart prestart))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (cond ((nth 3 state) ; In string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (setq res (cons (list 'string nil (nth 3 state)) res))) ; What started string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 ((nth 4 state) ; In comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (setq res (cons '(comment) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 ((null containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 ;; Line is at top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 ;; Indent like the previous top level line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 ;; unless that ends in a closeparen without semicolon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;; in which case this line is the first argument decl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (cperl-backward-to-noncomment (or parse-start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;;(skip-chars-backward " \t\f\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ((or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (memq (preceding-char) (append ";}" nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (setq res (cons (list 'toplevel start) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 ((eq (preceding-char) ?\) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (setq res (cons (list 'toplevel-after-parenth start) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (setq res (cons (list 'toplevel-continued start) res)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 ((/= (char-after containing-sexp) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 ;; line is expression, not statement:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ;; indent to just after the surrounding open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 ;; skip blanks if we do not close the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (setq res (cons (list 'expression-blanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (or (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (cons (list 'expression containing-sexp) res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 ;; Containing-expr starts with \{. Check whether it is a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (not (cperl-block-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (setq res (cons (list 'expression-blanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (or (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (cons (list 'expression containing-sexp) res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 ;; Statement level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (setq res (cons (list 'in-block containing-sexp) res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 ;; Is it a continuation or a new statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 ;; Find previous non-comment character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (cperl-backward-to-noncomment containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 ;; Back up over label lines, since they don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 ;; affect whether our line is a continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 ;; Back up comma-delimited lines too ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (while (or (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (save-excursion (cperl-after-label)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (if (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 ;; Will go to beginning of line, essentially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 ;; Will ignore embedded sexpr XXXX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (cperl-backward-to-start-of-continued-exp containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (cperl-backward-to-noncomment containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 ;; Now we get the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (if (not (memq (preceding-char) (append ";}{" '(nil)))) ; Was ?\,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 ;; This line is continuation of preceding line's statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (list (list 'statement-continued containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 ;; This line starts a new statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 ;; Is line first statement after an open-brace?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 ;; If no, find that first statement and indent like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 ;; it. If the first statement begins with label, do
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1992 ;; not believe when the indentation of the label is too
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 ;; small.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (let ((colon-line-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (while (progn (skip-chars-forward " \t\n" start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (and (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 "#\\|[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 ;; Skip over comments and labels following openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (cond ((= (following-char) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 ;;(forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 ;; label:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (setq colon-line-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (search-forward ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 ;; Now at the point, after label, or at start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ;; of first statement in the block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (and (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (if (> colon-line-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 ;; Before statement after label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (if (> (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (list (list 'label-in-block (point)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2018 ;; Do not believe: `max' is involved
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (list 'label-in-block-min-indent (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 ;; Before statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (list 'statement-in-block (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 ;; If no previous statement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 ;; indent it relative to line brace is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 ;; For open brace in column zero, don't let statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 ;; start there too. If cperl-indent-level is zero,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 ;; For open-braces not the first thing in a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 ;; add in cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 ;; If first thing on a line: ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 (+ (if (and (bolp) (zerop cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (+ cperl-brace-offset cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 cperl-indent-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 ;; Move back over whitespace before the openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 ;; If openbrace is not first nonwhite thing on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 ;; add the cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (if (bolp) 0 cperl-brace-imaginary-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;; If the openbrace is preceded by a parenthesized exp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ;; move to the beginning of that;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ;; possibly a different line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (if (eq (preceding-char) ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ;; Get initial indentation of the line we are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 ;; If line starts with label, calculate label indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (if (> (current-indentation) cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (cperl-calculate-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (if (and parse-start (<= parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (current-indentation))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (defun cperl-calculate-indent-within-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 "Return the indentation amount for line, assuming that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 the current line is to be regarded as part of a block comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (let (end star-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (and (= (following-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (setq end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (defun cperl-to-comment-or-eol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 "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
2077 Returns true if comment is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (let (state stop-in cpoint (lim (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (if (re-search-forward "\\=[ \t]*\\(#\\|$\\)" lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (if (eq (preceding-char) ?\#) (progn (backward-char 1) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (while (not stop-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (setq state (parse-partial-sexp (point) lim nil nil nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ; stop at comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 ;; If fails (beginning-of-line inside sexp), then contains not-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 ;; Do simplified processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 ;;(if (re-search-forward "[^$]#" lim 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 ;; (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;; (skip-chars-backward " \t\n\f" lim))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; (goto-char lim)) ; No `#' at all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (if (nth 4 state) ; After `#';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ; (nth 2 state) can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 ; beginning of m,s,qq and so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ; on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (if (nth 2 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (setq cpoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (goto-char (nth 2 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 ((looking-at "\\(s\\|tr\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 lim 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (setq stop-in t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ((looking-at "\\(m\\|q\\([qxw]\\)?\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 lim 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (setq stop-in t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (t ; It was fair comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (setq stop-in t) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (goto-char (1- cpoint)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (setq stop-in t) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (setq stop-in t)) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (nth 4 state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (defun cperl-find-pods-heres (&optional min max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 "Scans the buffer for POD sections and here-documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 If `cperl-pod-here-fontify' is not-nil after evaluation, will fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 the sections using `cperl-pod-head-face', `cperl-pod-face',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 `cperl-here-face'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (or min (setq min (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 (or max (setq max (point-max)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2130 (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
2131 (cperl-pod-here-fontify (eval cperl-pod-here-fontify))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (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
2133 (modified (buffer-modified-p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2134 (after-change-functions nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2135 (search
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2136 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2137 "\\(\\`\n?\\|\n\n\\)="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2138 "\\|"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2139 ;; One extra () before this:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2140 "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\3\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)[^=]\\)" ; [^=] to avoid <<=.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2141 "\\|"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2142 ;; 1+5 extra () before this:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2143 "^[ \t]*format[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2147 (message "Scanning for pods, formats and here-docs...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (if cperl-pod-here-fontify
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2149 ;; We had evals here, do not know why...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2150 (setq face cperl-pod-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2151 head-face cperl-pod-head-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2152 here-face cperl-here-face))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (remove-text-properties min max '(syntax-type t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 ;; Need to remove face as well...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (goto-char min)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2156 (while (re-search-forward search max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2157 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2158 ((match-beginning 1) ; POD section
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2159 ;; "\\(\\`\n?\\|\n\n\\)="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2160 (if (looking-at "\n*cut\\>")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2161 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2162 (message "=cut is not preceeded by a pod section")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2163 (setq err (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (beginning-of-line)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2165
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2166 (setq b (point) bb b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2167 (or (re-search-forward "\n\n=cut\\>" max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2168 (message "Cannot find the end of a pod section"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2169 (beginning-of-line 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2170 (setq e (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2171 (put-text-property b e 'in-pod t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2172 (goto-char b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2173 (while (re-search-forward "\n\n[ \t]" e t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2174 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2175 (put-text-property b (point) 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2176 (cperl-put-do-not-fontify b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2177 ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2178 ;; (point) cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2179 (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2180 (re-search-forward "\n\n[^ \t\f\n]" e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2181 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2182 (setq b (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2183 (put-text-property (point) e 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2184 (cperl-put-do-not-fontify (point) e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2185 ;;(put-text-property (max (point-min) (1- (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2186 ;; e cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2187 (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2188 (progn (put-text-property (point) e 'face face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2189 (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2190 (if (looking-at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2191 "=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2192 (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2193 (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2194 'face head-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2195 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2196 ;; One paragraph
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2197 "\n\n=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2198 e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2199 (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2200 (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2201 'face head-face))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2202 (goto-char e)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2203 ;; Here document
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2204 ;; 1 () ahead
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2205 ;; "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\3\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2206 ((match-beginning 2) ; 1 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2207 ;; Abort in comment (_extremely_ simplified):
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2208 (setq b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2209 (if (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2210 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2211 (search-forward "#" b t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2212 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2213 (if (match-beginning 5) ;4 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2214 (setq b1 (match-beginning 5) ; 4 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2215 e1 (match-end 5)) ; 4 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2216 (setq b1 (match-beginning 4) ; 3 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2217 e1 (match-end 4))) ; 3 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2218 (setq tag (buffer-substring b1 e1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2219 qtag (regexp-quote tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2220 (cond (cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2221 (put-text-property b1 e1 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2222 (cperl-put-do-not-fontify b1 e1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2223 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2224 (setq b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2225 (cond ((re-search-forward (concat "^" qtag "$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2226 (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2227 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2228 (put-text-property (match-beginning 0) (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2229 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2230 (cperl-put-do-not-fontify b (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2231 ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2232 ;; (min (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2233 ;; (1+ (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2234 ;; cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2235 (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2236 'face here-face)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2237 (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2238 'syntax-type 'here-doc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2239 (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2240 (t (message "End of here-document `%s' not found." tag)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2241 ;; format
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2242 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2243 ;; 1+5=6 extra () before this:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2244 ;; "^[ \t]*format[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2245 (setq b (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2246 name (if (match-beginning 7) ; 6 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2247 (buffer-substring (match-beginning 7) ; 6 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2248 (match-end 7)) ; 6 + 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2249 ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2250 (setq argument nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (if cperl-pod-here-fontify
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2252 (while (and (eq (forward-line) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2253 (not (looking-at "^[.;]$")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2254 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2255 ((looking-at "^#")) ; Skip comments
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2256 ((and argument ; Skip argument multi-lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2257 (looking-at "^[ \t]*{"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2258 (forward-sexp 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2259 (setq argument nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2260 (argument ; Skip argument lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2261 (setq argument nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2262 (t ; Format line
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2263 (setq b1 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2264 (setq argument (looking-at "^[^\n]*[@^]"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2265 (end-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2266 (put-text-property b1 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2267 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2268 (cperl-put-do-not-fontify b1 (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2269 (re-search-forward (concat "^[.;]$") max 'toend))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2270 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2271 (if (looking-at "^[.;]$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2272 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2273 (put-text-property (point) (+ (point) 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2274 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2275 (cperl-put-do-not-fontify (point) (+ (point) 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2276 (message "End of format `%s' not found." name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2277 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2278 (put-text-property b (point) 'syntax-type 'format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2279 ;;; (cond ((re-search-forward (concat "^[.;]$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2280 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2281 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2282 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2283 ;;; 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2284 ;;; (cperl-put-do-not-fontify b (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2285 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2286 ;;; 'syntax-type 'format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2287 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2288 ;;; (t (message "End of format `%s' not found." name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2289 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2290 ;;; (while (re-search-forward "\\(\\`\n?\\|\n\n\\)=" max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2291 ;;; (if (looking-at "\n*cut\\>")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2292 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2293 ;;; (message "=cut is not preceeded by a pod section")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2294 ;;; (setq err (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2295 ;;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2296
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2297 ;;; (setq b (point) bb b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2298 ;;; (or (re-search-forward "\n\n=cut\\>" max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2299 ;;; (message "Cannot find the end of a pod section"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2300 ;;; (beginning-of-line 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2301 ;;; (setq e (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2302 ;;; (put-text-property b e 'in-pod t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2303 ;;; (goto-char b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2304 ;;; (while (re-search-forward "\n\n[ \t]" e t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2305 ;;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2306 ;;; (put-text-property b (point) 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2307 ;;; (cperl-put-do-not-fontify b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2308 ;;; ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2309 ;;; ;; (point) cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2310 ;;; (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2311 ;;; (re-search-forward "\n\n[^ \t\f\n]" e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2312 ;;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2313 ;;; (setq b (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2314 ;;; (put-text-property (point) e 'syntax-type 'pod)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2315 ;;; (cperl-put-do-not-fontify (point) e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2316 ;;; ;;(put-text-property (max (point-min) (1- (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2317 ;;; ;; e cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2318 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2319 ;;; (progn (put-text-property (point) e 'face face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2320 ;;; (goto-char bb)
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 ;;; "=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2323 ;;; (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2324 ;;; (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2325 ;;; 'face head-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2326 ;;; (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2327 ;;; ;; One paragraph
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2328 ;;; "\n\n=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2329 ;;; e 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2330 ;;; (put-text-property
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2331 ;;; (match-beginning 1) (match-end 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2332 ;;; 'face head-face))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2333 ;;; (goto-char e)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2334 ;;; (goto-char min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2335 ;;; (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2336 ;;; ;; We exclude \n to avoid misrecognition inside quotes.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2337 ;;; "<<\\(\\([\"'`]\\)\\([^\"'`\n]*\\)\\2\\|\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2338 ;;; max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2339 ;;; (if (match-beginning 4)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2340 ;;; (setq b1 (match-beginning 4)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2341 ;;; e1 (match-end 4))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2342 ;;; (setq b1 (match-beginning 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2343 ;;; e1 (match-end 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2344 ;;; (setq tag (buffer-substring b1 e1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2345 ;;; qtag (regexp-quote tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2346 ;;; (cond (cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2347 ;;; (put-text-property b1 e1 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2348 ;;; (cperl-put-do-not-fontify b1 e1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2349 ;;; (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2350 ;;; (setq b (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2351 ;;; (cond ((re-search-forward (concat "^" qtag "$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2352 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2353 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2354 ;;; (put-text-property (match-beginning 0) (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2355 ;;; 'face font-lock-reference-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2356 ;;; (cperl-put-do-not-fontify b (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2357 ;;; ;;(put-text-property (max (point-min) (1- b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2358 ;;; ;; (min (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2359 ;;; ;; (1+ (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2360 ;;; ;; cperl-do-not-fontify t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2361 ;;; (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2362 ;;; 'face here-face)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2363 ;;; (put-text-property b (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2364 ;;; 'syntax-type 'here-doc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2365 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2366 ;;; (t (message "End of here-document `%s' not found." tag))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2367 ;;; (goto-char min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2368 ;;; (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2369 ;;; "^[ \t]*format[ \t]*\\(\\([a-zA-Z0-9_]+[ \t]*\\)?\\)=[ \t]*$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2370 ;;; max t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2371 ;;; (setq b (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2372 ;;; name (buffer-substring (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2373 ;;; (match-end 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2374 ;;; (cond ((re-search-forward (concat "^[.;]$") max 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2375 ;;; (if cperl-pod-here-fontify
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2376 ;;; (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2377 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2378 ;;; 'face font-lock-string-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2379 ;;; (cperl-put-do-not-fontify b (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2380 ;;; (put-text-property b (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2381 ;;; 'syntax-type 'format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2382 ;;; (cperl-put-do-not-fontify b (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2383 ;;; (t (message "End of format `%s' not found." name))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2384 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (if err (goto-char err)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2386 (message "Scan for pods, formats and here-docs completed.")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (not modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (set-buffer-modified-p nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (defun cperl-backward-to-noncomment (lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ;; Stops at lim or after non-whitespace that is not in comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (let (stop p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (while (and (not stop) (> (point) (or lim 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (skip-chars-backward " \t\n\f" lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (if (< p (point)) (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (setq stop t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (defun cperl-after-expr-p (&optional lim chars test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 "Returns true if the position is good for start of expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 TEST is the expression to evaluate at the found position. If absent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 CHARS is a string that contains good characters to have before us."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 (let (stop p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (while (and (not stop) (> (point) (or lim 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (skip-chars-backward " \t\n\f" lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 ;; Else: last iteration (What to do with labels?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 (if (< p (point)) (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 (setq stop t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (if test (eval test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (memq (following-char) (append (or chars "{};") nil))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (defun cperl-backward-to-start-of-continued-exp (lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (if (memq (preceding-char) (append ")]}\"'`" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (if (<= (point) lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (goto-char (1+ lim)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (defvar innerloop-done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (defvar last-depth nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (defun cperl-indent-exp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 "Simple variant of indentation of continued-sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 Should be slow. Will not indent comment if it starts at `comment-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 or looks like continuation of the comment on the previous line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (let ((tmp-end (progn (end-of-line) (point))) top done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (while (null done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (setq top (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (while (= (nth 0 (parse-partial-sexp (point) tmp-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 -1)) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (setq top (point))) ; Get the outermost parenths in line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (goto-char top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (while (< (point) tmp-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (parse-partial-sexp (point) tmp-end nil t) ; To start-sexp or eol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 (or (eolp) (forward-sexp 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 (if (> (point) tmp-end) (progn (end-of-line) (setq tmp-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (setq done t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (goto-char tmp-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (setq tmp-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (cperl-indent-region (point) tmp-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (defun cperl-indent-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 "Simple variant of indentation of region in CPerl mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 Should be slow. Will not indent comment if it starts at `comment-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 or looks like continuation of the comment on the previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 Indents all the lines whose first character is between START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 inclusive."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (let (st comm indent-info old-comm-indent new-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (pm 0) (imenu-scanning-message "Indenting... (%3d%%)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (setq old-comm-indent (and (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 new-comm-indent old-comm-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (or (bolp) (beginning-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (or (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (message "Indenting... For feedback load `imenu'..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (while (and (<= (point) end) (not (eobp))) ; bol to check start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 (and (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 (imenu-progress-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 pm (/ (* 100 (- (point) start)) (- end start -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (setq st (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 indent-info nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 ) ; Believe indentation of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (if (and (setq comm (looking-at "[ \t]*#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (or (eq (current-indentation) (or old-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (setq old-comm-indent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (if (and old-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (= (current-indentation) old-comm-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (let ((comment-column new-comm-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (indent-for-comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (cperl-indent-line 'indent-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (or comm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (if (setq old-comm-indent (and (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (progn (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (skip-chars-backward "#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (setq new-comm-indent (current-column))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (beginning-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (if (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (imenu-progress-message pm 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (message nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (defun cperl-slash-is-regexp (&optional pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (goto-char (if pos pos (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (not (memq (get-text-property (point) 'face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 '(font-lock-string-face font-lock-comment-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (cperl-after-expr-p nil nil '
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (or (looking-at "[^]a-zA-Z0-9_)}]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (eq (get-text-property (point) 'face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 'font-lock-keyword-face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 ;; Stolen from lisp-mode with a lot of improvements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (defun cperl-fill-paragraph (&optional justify iteration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 "Like \\[fill-paragraph], but handle CPerl comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 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
2527 block of it that point is in, preserving the comment's initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 indentation and initial hashes. Behaves usually outside of comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;; Non-nil if the current line contains a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 has-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;; If has-comment, the appropriate fill-prefix for the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 comment-fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;; Line that contains code and comment (or nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 c spaces len dc (comment-column comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;; Figure out what kind of comment we are looking at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 ;; A line with nothing but a comment on it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ((looking-at "[ \t]*#[# \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (setq has-comment t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 comment-fill-prefix (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 ;; A line with some code, followed by a comment? Remember that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 ;; semi which starts the comment shouldn't be part of a string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 ;; character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 ((cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (setq has-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (looking-at "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (setq start (point) c (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 comment-fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 (concat (make-string (current-column) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (buffer-substring (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 spaces (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 (buffer-substring (point) start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 dc (- c (current-column)) len (- start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 start (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (delete-char len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (insert (make-string dc ?-)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 (if (not has-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (fill-paragraph justify) ; Do the usual thing outside of comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 ;; Narrow to include only the comment, and then fill the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 ;; Find the first line we should include in the region to fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 (if start (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (while (and (zerop (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 ;; We may have gone to far. Go forward again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 (or (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 ;; Find the beginning of the first line past the region to fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 (while (progn (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 ;; Remove existing hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (while (progn (forward-line 1) (< (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (and (looking-at "#+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (delete-char (- (match-end 0) (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 ;; Lines with only hashes on them can be paragraph boundaries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (paragraph-separate (concat paragraph-start "\\|^[ \t#]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (fill-prefix comment-fill-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (fill-paragraph justify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (if (and start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (if (> dc 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (progn (delete-char dc) (insert spaces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 (if (or (= (current-column) c) iteration) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (setq comment-column c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 ;; Repeat once more, flagging as iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (cperl-fill-paragraph justify t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (defun cperl-do-auto-fill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 ;; Break out if the line is short enough
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (if (> (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (let ((c (save-excursion (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (cperl-to-comment-or-eol) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (s (memq (following-char) '(?\ ?\t))) marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (if (>= c (point)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 (setq marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (cperl-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (goto-char marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 ;; Is not enough, sometimes marker is a start of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (if (bolp) (progn (re-search-forward "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (goto-char (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 ;; Following space could have gone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (if (or (not s) (memq (following-char) '(?\ ?\t))) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 ;; Previous space could have gone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (or (memq (preceding-char) '(?\ ?\t)) (insert " "))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (defvar imenu-example--function-name-regexp-perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 "^\\([ \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
2633
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2634 (defun cperl-imenu-addback (lst &optional isback name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2635 ;; 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
2636 ;; loops back, and ISBACK is set. Thus this function cannot be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2637 ;; applied twice without ISBACK set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2638 (cond ((not cperl-imenu-addback) lst)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2639 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2640 (or name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2641 (setq name "+++BACK+++"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2642 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2643 (if (and (listp elt) (listp (cdr elt)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2644 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2645 ;; In the other order it goes up
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2646 ;; one level only ;-(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2647 (setcdr elt (cons (cons name lst)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2648 (cdr elt)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2649 (cperl-imenu-addback (cdr elt) t name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2650 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2651 (if isback (cdr lst) lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2652 lst)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2653
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (defun imenu-example--create-perl-index (&optional regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2658 (index-meth-alist '()) meth
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 packages ends-ranges p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (prev-pos 0) char fchar index index1 name (end-range 0) package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (imenu-progress-message prev-pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 ;; Search for the function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2664 (progn ;;save-match-data
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (or regexp imenu-example--function-name-regexp-perl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (imenu-progress-message prev-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 ;;(backward-up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 ((match-beginning 2) ; package or sub
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (goto-char (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 (setq fchar (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2676 (setq char (following-char) meth nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 (while (and ends-ranges (>= p (car ends-ranges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 ;; delete obsolete entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 (setq ends-ranges (cdr ends-ranges) packages (cdr packages)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (setq package (or (car packages) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 end-range (or (car ends-ranges) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 (if (eq fchar ?p)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2684 (setq name (buffer-substring (match-beginning 3) (match-end 3))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2685 name (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2686 (set-text-properties 0 (length name) nil name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2687 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2688 package (concat name "::")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2689 name (concat "package " name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2690 end-range
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2691 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2692 (parse-partial-sexp (point) (point-max) -1) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2693 ends-ranges (cons end-range ends-ranges)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2694 packages (cons package packages)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 ;; Skip this function name if it is a prototype declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 (if (and (eq fchar ?s) (eq char ?\;)) nil
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2698 (setq index (imenu-example--name-and-position))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 (if (eq fchar ?p) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2701 (set-text-properties 0 (length name) nil name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2702 (cond ((string-match "[:']" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2703 (setq meth t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2704 ((> p end-range) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2705 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2706 (setq name (concat package name) meth t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (setcar index name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 (if (eq fchar ?p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 (push index index-pack-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 (push index index-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2711 (if meth (push index index-meth-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (push index index-unsorted-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 (t ; Pod section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 ;; (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (setq index (imenu-example--name-and-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 name (buffer-substring (match-beginning 5) (match-end 5)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2717 (set-text-properties 0 (length name) nil name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (if (eq (char-after (match-beginning 4)) ?2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (setq name (concat " " name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (setcar index name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (setq index1 (cons (concat "=" name) (cdr index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (push index index-pod-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 (push index1 index-unsorted-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (imenu-progress-message prev-pos 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 (setq index-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (if (default-value 'imenu-sort-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (sort index-alist (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 (nreverse index-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 (and index-pod-alist
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2730 (push (cons "+POD headers+..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (nreverse index-pod-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 index-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2733 (and (or index-pack-alist index-meth-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2734 (let ((lst index-pack-alist) hier-list pack elt group name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2735 ;; Remove "package ", reverse and uniquify.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2736 (while lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2737 (setq elt (car lst) lst (cdr lst) name (substring (car elt) 8))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2738 (if (assoc name hier-list) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2739 (setq hier-list (cons (cons name (cdr elt)) hier-list))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2740 (setq lst index-meth-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2741 (while lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2742 (setq elt (car lst) lst (cdr lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2743 (cond ((string-match "\\(::\\|'\\)[_a-zA-Z0-9]+$" (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2744 (setq pack (substring (car elt) 0 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2745 (if (setq group (assoc pack hier-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2746 (if (listp (cdr group))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2747 ;; Have some functions already
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2748 (setcdr group
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2749 (cons (cons (substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2750 (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2751 (+ 2 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2752 (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2753 (cdr group)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2754 (setcdr group (list (cons (substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2755 (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2756 (+ 2 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2757 (cdr elt)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2758 (setq hier-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2759 (cons (cons pack
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2760 (list (cons (substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2761 (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2762 (+ 2 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2763 (cdr elt))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2764 hier-list))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2765 (push (cons "+Hierarchy+..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2766 hier-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2767 index-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 (and index-pack-alist
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2769 (push (cons "+Packages+..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (nreverse index-pack-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (and (or index-pack-alist index-pod-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 index-unsorted-alist
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2775 (push (cons "+Unsorted List+..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 (nreverse index-unsorted-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 index-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2778 (cperl-imenu-addback index-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 (defvar cperl-compilation-error-regexp-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 ;; 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
2782 '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 2 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 "Alist that specifies how to match errors in perl output.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 (if (fboundp 'eval-after-load)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (eval-after-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 "mode-compile"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 '(setq perl-compilation-error-regexp-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 cperl-compilation-error-regexp-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 (defvar cperl-faces-init nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (defun cperl-windowed-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 "Initialization under windowed version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 (add-hook 'font-lock-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 (if (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 (eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 (eq major-mode 'cperl-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (or cperl-faces-init (cperl-init-faces))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (defvar perl-font-lock-keywords-1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 "Additional expressions to highlight in Perl mode. Minimal set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 (defvar perl-font-lock-keywords nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 "Additional expressions to highlight in Perl mode. Default set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 (defvar perl-font-lock-keywords-2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 "Additional expressions to highlight in Perl mode. Maximal set")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (defun cperl-init-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 (require 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 (and (fboundp 'font-lock-fontify-anchored-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 (featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 (message "You have an obsolete package `font-lock-extra'. Install `choose-color'."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 (let (t-font-lock-keywords t-font-lock-keywords-1 font-lock-anchored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 ;;(defvar cperl-font-lock-enhanced nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 ;; "Set to be non-nil if font-lock allows active highlights.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (if (fboundp 'font-lock-fontify-anchored-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 (setq font-lock-anchored t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 "\\(^\\|[^$@%&\\]\\)\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 '("if" "until" "while" "elsif" "else" "unless" "for"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 "foreach" "continue" "exit" "die" "last" "goto" "next"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 "redo" "return" "local" "exec" "sub" "do" "dump" "use"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 "require" "package" "eval" "my" "BEGIN" "END")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 "\\|") ; Flow control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 "\\)\\>") 2) ; was "\\)[ \n\t;():,\|&]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 ; In what follows we use `type' style
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2840 ; for overwritable builtins
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 "\\(^\\|[^$@%&\\]\\)\\<\\("
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2844 ;; "CORE" "__FILE__" "__LINE__" "abs" "accept" "alarm"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2845 ;; "and" "atan2" "bind" "binmode" "bless" "caller"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2846 ;; "chdir" "chmod" "chown" "chr" "chroot" "close"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2847 ;; "closedir" "cmp" "connect" "continue" "cos" "crypt"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2848 ;; "dbmclose" "dbmopen" "die" "dump" "endgrent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2849 ;; "endhostent" "endnetent" "endprotoent" "endpwent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2850 ;; "endservent" "eof" "eq" "exec" "exit" "exp" "fcntl"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2851 ;; "fileno" "flock" "fork" "formline" "ge" "getc"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2852 ;; "getgrent" "getgrgid" "getgrnam" "gethostbyaddr"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2853 ;; "gethostbyname" "gethostent" "getlogin"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2854 ;; "getnetbyaddr" "getnetbyname" "getnetent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2855 ;; "getpeername" "getpgrp" "getppid" "getpriority"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2856 ;; "getprotobyname" "getprotobynumber" "getprotoent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2857 ;; "getpwent" "getpwnam" "getpwuid" "getservbyname"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2858 ;; "getservbyport" "getservent" "getsockname"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2859 ;; "getsockopt" "glob" "gmtime" "gt" "hex" "index" "int"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2860 ;; "ioctl" "join" "kill" "lc" "lcfirst" "le" "length"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2861 ;; "link" "listen" "localtime" "log" "lstat" "lt"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2862 ;; "mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "ne"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2863 ;; "not" "oct" "open" "opendir" "or" "ord" "pack" "pipe"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2864 ;; "quotemeta" "rand" "read" "readdir" "readline"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2865 ;; "readlink" "readpipe" "recv" "ref" "rename" "require"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2866 ;; "reset" "reverse" "rewinddir" "rindex" "rmdir" "seek"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2867 ;; "seekdir" "select" "semctl" "semget" "semop" "send"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2868 ;; "setgrent" "sethostent" "setnetent" "setpgrp"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2869 ;; "setpriority" "setprotoent" "setpwent" "setservent"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2870 ;; "setsockopt" "shmctl" "shmget" "shmread" "shmwrite"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2871 ;; "shutdown" "sin" "sleep" "socket" "socketpair"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2872 ;; "sprintf" "sqrt" "srand" "stat" "substr" "symlink"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2873 ;; "syscall" "sysread" "system" "syswrite" "tell"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2874 ;; "telldir" "time" "times" "truncate" "uc" "ucfirst"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2875 ;; "umask" "unlink" "unpack" "utime" "values" "vec"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2876 ;; "wait" "waitpid" "wantarray" "warn" "write" "x" "xor"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 "a\\(bs\\|ccept\\|tan2\\|larm\\|nd\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 "b\\(in\\(d\\|mode\\)\\|less\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 "c\\(h\\(r\\(\\|oot\\)\\|dir\\|mod\\|own\\)\\|aller\\|rypt\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 "lose\\(\\|dir\\)\\|mp\\|o\\(s\\|n\\(tinue\\|nect\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 "CORE\\|d\\(ie\\|bm\\(close\\|open\\)\\|ump\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 "e\\(x\\(p\\|it\\|ec\\)\\|q\\|nd\\(p\\(rotoent\\|went\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 "hostent\\|servent\\|netent\\|grent\\)\\|of\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 "f\\(ileno\\|cntl\\|lock\\|or\\(k\\|mline\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 "g\\(t\\|lob\\|mtime\\|e\\(\\|t\\(p\\(pid\\|r\\(iority\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 "oto\\(byn\\(ame\\|umber\\)\\|ent\\)\\)\\|eername\\|w"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 "\\(uid\\|ent\\|nam\\)\\|grp\\)\\|host\\(by\\(addr\\|name\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 "ent\\)\\|s\\(erv\\(by\\(port\\|name\\)\\|ent\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 "ock\\(name\\|opt\\)\\)\\|c\\|login\\|net\\(by\\(addr\\|name\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 "ent\\)\\|gr\\(ent\\|nam\\|gid\\)\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 "hex\\|i\\(n\\(t\\|dex\\)\\|octl\\)\\|join\\|kill\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 "l\\(i\\(sten\\|nk\\)\\|stat\\|c\\(\\|first\\)\\|t\\|e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 "\\(\\|ngth\\)\\|o\\(caltime\\|g\\)\\)\\|m\\(sg\\(rcv\\|snd\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 "ctl\\|get\\)\\|kdir\\)\\|n\\(e\\|ot\\)\\|o\\(pen\\(\\|dir\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 "r\\(\\|d\\)\\|ct\\)\\|p\\(ipe\\|ack\\)\\|quotemeta\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 "r\\(index\\|and\\|mdir\\|e\\(quire\\|ad\\(pipe\\|\\|lin"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 "\\(k\\|e\\)\\|dir\\)\\|set\\|cv\\|verse\\|f\\|winddir\\|name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 "\\)\\)\\|s\\(printf\\|qrt\\|rand\\|tat\\|ubstr\\|e\\(t\\(p\\(r"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 "\\(iority\\|otoent\\)\\|went\\|grp\\)\\|hostent\\|s\\(ervent\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 "ockopt\\)\\|netent\\|grent\\)\\|ek\\(\\|dir\\)\\|lect\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 "m\\(ctl\\|op\\|get\\)\\|nd\\)\\|h\\(utdown\\|m\\(read\\|ctl\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 "write\\|get\\)\\)\\|y\\(s\\(read\\|call\\|tem\\|write\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 "mlink\\)\\|in\\|leep\\|ocket\\(pair\\|\\)\\)\\|t\\(runcate\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 "ell\\(\\|dir\\)\\|ime\\(\\|s\\)\\)\\|u\\(c\\(\\|first\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 "time\\|mask\\|n\\(pack\\|link\\)\\)\\|v\\(alues\\|ec\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 "w\\(a\\(rn\\|it\\(pid\\|\\)\\|ntarray\\)\\|rite\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 "x\\(\\|or\\)\\|__\\(FILE__\\|LINE__\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 "\\)\\>") 2 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 ;; In what follows we use `other' style
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2910 ;; for nonoverwritable builtins
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2911 ;; Somehow 's', 'm' are not auto-generated???
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 "\\(^\\|[^$@%&\\]\\)\\<\\("
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2915 ;; "AUTOLOAD" "BEGIN" "DESTROY" "END" "__END__" "chomp"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2916 ;; "chop" "defined" "delete" "do" "each" "else" "elsif"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2917 ;; "eval" "exists" "for" "foreach" "format" "goto"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2918 ;; "grep" "if" "keys" "last" "local" "map" "my" "next"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2919 ;; "no" "package" "pop" "pos" "print" "printf" "push"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2920 ;; "q" "qq" "qw" "qx" "redo" "return" "scalar" "shift"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2921 ;; "sort" "splice" "split" "study" "sub" "tie" "tr"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2922 ;; "undef" "unless" "unshift" "untie" "until" "use"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2923 ;; "while" "y"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 "AUTOLOAD\\|BEGIN\\|cho\\(p\\|mp\\)\\|d\\(e\\(fined\\|lete\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 "o\\)\\|DESTROY\\|e\\(ach\\|val\\|xists\\|ls\\(e\\|if\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 "END\\|for\\(\\|each\\|mat\\)\\|g\\(rep\\|oto\\)\\|if\\|keys\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 "l\\(ast\\|ocal\\)\\|m\\(ap\\|y\\)\\|n\\(ext\\|o\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 "p\\(ackage\\|rint\\(\\|f\\)\\|ush\\|o\\(p\\|s\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 "q\\(\\|q\\|w\\|x\\)\\|re\\(turn\\|do\\)\\|s\\(pli\\(ce\\|t\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 "calar\\|tudy\\|ub\\|hift\\|ort\\)\\|t\\(r\\|ie\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 "u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 "while\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 "\\|[sm]" ; Added manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 "\\)\\>") 2 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 ;; (mapconcat 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 ;; "#include" "#define" "#undef")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 ;; "\\|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 '("-[rwxoRWXOezsfdlpSbctugkTBMAC]\\>\\([ \t]+_\\>\\)?" 0
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2940 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
2941 '("\\<sub[ \t]+\\([^ \t{;]+\\)[ \t]*[{\n]" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 '("\\<\\(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
2944 2 font-lock-function-name-face)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2945 '("^[ \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
2946 1 font-lock-function-name-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (cond ((featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (2 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (0 '(restart 2 t)))) ; To highlight $a{bc}{ef}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (font-lock-anchored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (2 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (1 font-lock-string-face t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (t '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 2 font-lock-string-face t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 '("[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 '("^[ \t]*\\([a-zA-Z0-9_]+[ \t]*:\\)[ \t]*\\($\\|{\\|\\<\\(until\\|while\\|for\\(each\\)?\\|do\\)\\>\\)" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 font-lock-reference-face) ; labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 '("\\<\\(continue\\|next\\|last\\|redo\\|goto\\)\\>[ \t]+\\([a-zA-Z0-9_:]+\\)" ; labels as targets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 2 font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (cond ((featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 (3 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (4 '(another 4 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (1 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (2 '(restart 2 nil) nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 nil t))) ; local variables, multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 (font-lock-anchored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 (3 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 (1 font-lock-variable-name-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 (t '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 3 font-lock-variable-name-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 '("\\<for\\(each\\)?[ \t]*\\(\\$[a-zA-Z_][a-zA-Z_0-9]*\\)[ \t]*("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 2 font-lock-variable-name-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 t-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 (and (fboundp 'turn-on-font-lock) ; Check for newer font-lock
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2986 (not cperl-xemacs-p) ; not yet as of XEmacs 19.12
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2987 '(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2988 ("\\(\\([@%]\\|\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2989 (if (eq (char-after (match-beginning 2)) ?%)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2990 font-lock-other-emphasized-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2991 font-lock-emphasized-face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2992 t) ; arrays and hashes
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2993 ("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 (if (= (- (match-end 2) (match-beginning 2)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 (if (eq (char-after (match-beginning 3)) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 font-lock-emphasized-face) ; arrays and hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 font-lock-variable-name-face) ; Just to put something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 ;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 ;;; Too much noise from \s* @s[ and friends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 ;;(3 font-lock-function-name-face t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 ;;(4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 ;; (if (cperl-slash-is-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 ;; font-lock-function-name-face 'default) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (setq perl-font-lock-keywords-1 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 perl-font-lock-keywords perl-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 perl-font-lock-keywords-2 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 t-font-lock-keywords-1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 (if (fboundp 'ps-print-buffer) (cperl-ps-print-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 (if (or (featurep 'choose-color) (featurep 'font-lock-extra))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 (font-lock-require-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 ;; Color-light Color-dark Gray-light Gray-dark Mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (list 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 ["Firebrick" "OrangeRed" "DimGray" "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (list 'font-lock-string-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 ["RosyBrown" "LightSalmon" "Gray50" "LightGray"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (list 'font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 ["Purple" "LightSteelBlue" "DimGray" "Gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 (list 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 "Blue" "LightSkyBlue" "Gray50" "LightGray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 (cdr (assq 'background-color ; if mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 (frame-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 nil nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 (cdr (assq 'foreground-color ; if mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 (frame-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (list 'font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 ["DarkGoldenrod" "LightGoldenrod" "DimGray" "Gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 (list 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 ["DarkOliveGreen" "PaleGreen" "DimGray" "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 (list 'font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 ["CadetBlue" "Aquamarine" "Gray50" "LightGray"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (list 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 ["chartreuse3" ("orchid1" "orange")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 [nil nil "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 [nil nil nil t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 [nil nil t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (list 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 ["blue" "yellow" nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 ["lightyellow2" ("navy" "os2blue" "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 nil
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 (list 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 ["red" "red" nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 ["lightyellow2" ("navy" "os2blue" "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (defvar cperl-guessed-background nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 "Display characteristics as guessed by cperl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (or (fboundp 'x-color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (defalias 'x-color-defined-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 (cond ((fboundp 'color-defined-p) 'color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 ;; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 ((fboundp 'valid-color-name-p) 'valid-color-name-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 ;; XEmacs 19.11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (t 'x-valid-color-name-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 (defvar font-lock-reference-face 'font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 (defvar font-lock-variable-name-face 'font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 (or (boundp 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 "Face to use for data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 (or (boundp 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 (defconst font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 "Face to use for data types from another group.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3112 (if (not cperl-xemacs-p) nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 (or (boundp 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 (defconst font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 "Face to use for comments.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 (or (boundp 'font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (defconst font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 'font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 "Face to use for keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 (or (boundp 'font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 (defconst font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 "Face to use for function names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 ;;(if (featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 (if (face-equal font-lock-type-face font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 "Face to use for basic data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 ;;; (if (fboundp 'eval-after-load)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 ;;; (eval-after-load "font-lock"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 ;;; '(if (face-equal font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 ;;; font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 ;;; (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 ;;; 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 ;;; "Face to use for basic data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 ;;; ))) ; This does not work :-( Why?!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 ;;; ; Workaround: added to font-lock-m-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 ;;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (or (boundp 'font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 (defconst font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 "Face to use for another type of emphasizing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 (or (boundp 'font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 (defconst font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 "Face to use for emphasizing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 ;; Here we try to guess background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 (let ((background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 (if (boundp 'font-lock-background-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 font-lock-background-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 'light))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (face-list (and (fboundp 'face-list) (face-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 is-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 (fset 'is-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 (cond ((fboundp 'find-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 (symbol-function 'find-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 (face-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 (function (lambda (face) (member face face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 (function (lambda (face) (boundp face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (defvar cperl-guessed-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 (if (and (boundp 'font-lock-display-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 (eq font-lock-display-type 'grayscale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 'gray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 background)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 "Background as guessed by CPerl mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 (if (is-face 'font-lock-type-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 (copy-face 'default 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (set-face-foreground 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (if (x-color-defined-p "seagreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 "seagreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 "sea green")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (set-face-foreground 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 (if (x-color-defined-p "os2pink")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 "os2pink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 "pink")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (set-face-background 'font-lock-type-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 (if (is-face 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 (copy-face 'font-lock-type-face 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 (set-face-foreground 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 (if (x-color-defined-p "chartreuse3")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 "chartreuse3"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 "chartreuse")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (set-face-foreground 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 (if (x-color-defined-p "orchid1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 "orchid1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 "orange")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 (if (is-face 'font-lock-other-emphasized-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 (copy-face 'bold-italic 'font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 (set-face-background 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 (if (x-color-defined-p "lightyellow2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 "lightyellow2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (if (x-color-defined-p "lightyellow")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 "lightyellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 "light yellow"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (set-face-background 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (if (x-color-defined-p "navy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (if (x-color-defined-p "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 "darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 "dark green"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (t (set-face-background 'font-lock-other-emphasized-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (if (is-face 'font-lock-emphasized-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 (copy-face 'bold 'font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (set-face-background 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (if (x-color-defined-p "lightyellow2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 "lightyellow2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 "lightyellow")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 (set-face-background 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 (if (x-color-defined-p "navy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 (if (x-color-defined-p "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 "darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 "dark green"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 (t (set-face-background 'font-lock-emphasized-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 (if (is-face 'font-lock-variable-name-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 (copy-face 'italic 'font-lock-variable-name-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 (if (is-face 'font-lock-reference-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 (copy-face 'italic 'font-lock-reference-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (setq cperl-faces-init t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 (defun cperl-ps-print-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 "Initialization of `ps-print' components for faces used in CPerl."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 ;; Guard against old versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 (defvar ps-underlined-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 (defvar ps-bold-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 (defvar ps-italic-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 (setq ps-bold-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 (append '(font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 ps-bold-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 (setq ps-italic-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (append '(font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 ps-italic-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 (setq ps-underlined-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 (append '(font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 font-lock-other-type-face font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 ps-underlined-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 (cons 'font-lock-type-face ps-underlined-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 (if (cperl-enable-font-lock) (cperl-windowed-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 (defun cperl-set-style (style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 "Set CPerl-mode variables to use one of several different indentation styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 The arguments are a string representing the desired style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 Available styles are GNU, K&R, BSD and Whitesmith."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 (let ((list (mapcar (function (lambda (elt) (list (car elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 c-style-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 (list (completing-read "Enter style: " list nil 'insist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (let ((style (cdr (assoc style c-style-alist))) setting str sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (while style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 (setq setting (car style) style (cdr style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (setq str (symbol-name (car setting)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 (and (string-match "^c-" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 (setq str (concat "cperl-" (substring str 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (setq sym (intern-soft str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 (set sym (cdr setting))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 (defun cperl-check-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 (require 'mode-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 (let ((perl-dbg-flags "-wc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 (mode-compile)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 (defun cperl-info-buffer ()
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3299 ;; Returns buffer with documentation. Creates if missing
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 (let ((info (get-buffer "*info-perl*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 (if info info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 ;; Get Info running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 (require 'info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 (info))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3307 (Info-find-node cperl-info-page "perlfunc")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 (set-buffer "*info*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 (rename-buffer "*info-perl*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 (defun cperl-word-at-point (&optional p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 ;; Returns the word at point or at P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 (if p (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 (require 'etags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 (funcall (or (and (boundp 'find-tag-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 find-tag-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 (get major-mode 'find-tag-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 ;; XEmacs 19.12 has `find-tag-default-hook'; it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 ;; automatically used within `find-tag-default':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 'find-tag-default))))
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-info-on-command (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 "Shows documentation for Perl command in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 (let* ((default (cperl-word-at-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 (read (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 (format "Find doc for Perl function (default %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 (list (if (equal read "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 read))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 (let ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 (cmd-desc (concat "^" (regexp-quote command) "[^a-zA-Z_0-9]")) ; "tr///"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 (if (string-match "^-[a-zA-Z]$" command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 (setq cmd-desc "^-X[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 (set-buffer (cperl-info-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 (re-search-forward "^-X[ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 (if (re-search-forward cmd-desc nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 (setq pos (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 (pop-to-buffer (cperl-info-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 (set-window-start (selected-window) pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 (message "No entry for %s found." command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 (pop-to-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 (defun cperl-info-on-current-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 "Shows documentation for Perl command at point in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 (cperl-info-on-command (cperl-word-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 (defun cperl-imenu-info-imenu-search ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 (if (looking-at "^-X[ \t\n]") nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 "^\n\\([-a-zA-Z]+\\)[ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 (defun cperl-imenu-info-imenu-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 (defun cperl-imenu-on-info ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 (let* ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 imenu-prev-index-position-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 imenu-extract-index-name-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 (index-item (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 (set-buffer (cperl-info-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 (setq imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 'imenu-default-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 imenu-prev-index-position-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 'cperl-imenu-info-imenu-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 imenu-extract-index-name-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 'cperl-imenu-info-imenu-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 (imenu-choose-buffer-index)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 (and index-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 (pop-to-buffer "*info-perl*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 ((markerp (cdr index-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 (goto-char (marker-position (cdr index-item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 (goto-char (cdr index-item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 (set-window-start (selected-window) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 (pop-to-buffer buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 (defun cperl-lineup (beg end &optional step minshift)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 "Lineup construction in a region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 Beginning of region should be at the start of a construction.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3399 All first occurrences of this construction in the lines that are
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 partially contained in the region are lined up at the same column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 MINSHIFT is the minimal amount of space to insert before the construction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 STEP is the tabwidth to position constructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 If STEP is `nil', `cperl-lineup-step' will be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 \(or `cperl-indent-level', if `cperl-lineup-step' is `nil').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 Will not move the position at the start to the left."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 (let (search col tcol seen b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 (setq end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 (skip-chars-forward " \t\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 (setq beg (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416 (indent-region beg end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 (setq col (current-column))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3419 (if (looking-at "[a-zA-Z0-9_]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3420 (if (looking-at "\\<[a-zA-Z0-9_]+\\>")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 (setq search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 (concat "\\<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 (match-end 0))) "\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 (error "Cannot line up in a middle of the word"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427 (if (looking-at "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 (error "Cannot line up end of line"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429 (setq search (regexp-quote (char-to-string (following-char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430 (setq step (or step cperl-lineup-step cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 (or minshift (setq minshift 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 (re-search-forward search end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436 (goto-char (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 (setq tcol (current-column) seen t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438 (if (> tcol col) (setq col tcol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 (or seen
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3440 (error "The construction to line up occurred only once"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 (setq col (+ col minshift))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 (if (/= (% col step) 0) (setq step (* step (1+ (/ col step)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446 (setq e (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 (delete-region (point) e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 (indent-to-column col); (make-string (- col (current-column)) ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 (re-search-forward search end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 (goto-char (match-beginning 0)))))))) ; No body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 (defun cperl-etags (&optional add all files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 "Run etags with appropriate options for Perl files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 If optional argument ALL is `recursive', will process Perl files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 in subdirectories too."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460 (let ((cmd "etags")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 (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
3462 res)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 (if add (setq args (cons "-a" args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 (or files (setq files (list buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 ((eq all 'recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 ;;(error "Not implemented: recursive")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 (setq args (append (list "-e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 "sub wanted {push @ARGV, $File::Find::name if /\\.[Pp][Llm]$/}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 use File::Find;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 find(\\&wanted, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 exec @ARGV;"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 cmd) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 cmd "perl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 (all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 ;;(error "Not implemented: all")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 (setq args (append (list "-e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 "push @ARGV, <*.PL *.pl *.pm>;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 exec @ARGV;"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 cmd) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 cmd "perl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 (setq args (append args files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 (setq res (apply 'call-process cmd nil nil nil args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 (or (eq res 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 (message "etags returned \"%s\"" res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 (defun cperl-toggle-auto-newline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 "Toggle the state of `cperl-auto-newline'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 (setq cperl-auto-newline (not cperl-auto-newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 (message "Newlines will %sbe auto-inserted now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 (if cperl-auto-newline "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 (defun cperl-toggle-abbrev ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 "Toggle the state of automatic keyword expansion in CPerl mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 (abbrev-mode (if abbrev-mode 0 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499 (message "Perl control structure will %sbe auto-inserted now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 (if abbrev-mode "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 (defun cperl-toggle-electric ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 "Toggle the state of parentheses doubling in CPerl mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 (setq cperl-electric-parens (if (cperl-val 'cperl-electric-parens) 'null t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507 (message "Parentheses will %sbe auto-doubled now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 (if (cperl-val 'cperl-electric-parens) "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3510 ;;;; Tags file creation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3511
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3512 (defvar cperl-tmp-buffer " *cperl-tmp*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3513
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3514 (defun cperl-setup-tmp-buf ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3515 (set-buffer (get-buffer-create cperl-tmp-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3516 (set-syntax-table cperl-mode-syntax-table)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3517 (buffer-disable-undo)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3518 (auto-fill-mode 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3519
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3520 (defun cperl-xsub-scan ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3521 (require 'cl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3522 (require 'imenu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3523 (let ((index-alist '())
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3524 (prev-pos 0) index index1 name package prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3525 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3526 (imenu-progress-message prev-pos 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3527 ;; Search for the function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3528 (progn ;;save-match-data
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3529 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3530 "^\\([ \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
3531 nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3532 (imenu-progress-message prev-pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3533 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3534 ((match-beginning 2) ; SECTION
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3535 (setq package (buffer-substring (match-beginning 2) (match-end 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3536 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3537 (skip-chars-forward " \t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3538 (forward-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3539 (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
3540 (setq prefix (buffer-substring (match-beginning 1) (match-end 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3541 (setq prefix nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3542 ((not package) nil) ; C language section
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3543 ((match-beginning 3) ; XSUB
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3544 (goto-char (1+ (match-beginning 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3545 (setq index (imenu-example--name-and-position))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3546 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3547 (if (and prefix (string-match (concat "^" prefix) name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3548 (setq name (substring name (length prefix))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3549 (cond ((string-match "::" name) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3550 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3551 (setq index1 (cons (concat package "::" name) (cdr index)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3552 (push index1 index-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3553 (setcar index name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3554 (push index index-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3555 (t ; BOOT: section
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3556 ;; (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3557 (setq index (imenu-example--name-and-position))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3558 (setcar index (concat package "::BOOT:"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3559 (push index index-alist)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3560 (imenu-progress-message prev-pos 100)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3561 ;;(setq index-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3562 ;; (if (default-value 'imenu-sort-function)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3563 ;; (sort index-alist (default-value 'imenu-sort-function))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3564 ;; (nreverse index-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3565 index-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3566
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3567 (defun cperl-find-tags (file xs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3568 (let (ind (b (get-buffer cperl-tmp-buffer)) lst elt pos ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3569 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3570 (if b (set-buffer b)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3571 (cperl-setup-tmp-buf))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3572 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3573 (setq file (car (insert-file-contents file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3574 (message "Scanning file %s..." file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3575 (if xs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3576 (setq lst (cperl-xsub-scan))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3577 (setq ind (imenu-example--create-perl-index))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3578 (setq lst (cdr (assoc "+Unsorted List+..." ind))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3579 (setq lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3580 (mapcar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3581 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3582 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3583 (cond ((string-match "^[_a-zA-Z]" (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3584 (goto-char (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3585 (list (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3586 (point) (count-lines 1 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3587 (buffer-substring (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3588 (skip-chars-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3589 ":_a-zA-Z0-9")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3590 (or (eolp) (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3591 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3592 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3593 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3594 (point))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3595 lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3596 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3597 (while lst
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3598 (setq elt (car lst) lst (cdr lst))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3599 (if elt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3600 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3601 (insert (elt elt 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3602 127
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3603 (if (string-match "^package " (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3604 (substring (car elt) 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3605 (car elt) )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3606 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3607 (number-to-string (elt elt 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3608 ","
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3609 (number-to-string (elt elt 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3610 "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3611 (if (and (string-match "^[_a-zA-Z]+::" (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3612 (string-match "^sub[ \t]+\\([_a-zA-Z]+\\)[^:_a-zA-Z]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3613 (elt elt 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3614 ;; Need to insert the name without package as well
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3615 (setq lst (cons (cons (substring (elt elt 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3616 (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3617 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3618 (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3619 lst))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3620 (setq pos (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3621 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3622 (insert "\f\n" file "," (number-to-string (1- pos)) "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3623 (setq ret (buffer-substring 1 (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3624 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3625 (message "Scanning file %s finished" file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3626 ret)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3627
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3628 (defun cperl-write-tags (&optional file erase recurse dir inbuffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3629 ;; If INBUFFER, do not select buffer, and do not save
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3630 ;; 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
3631 (require 'etags)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3632 (if file nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3633 (setq file (if dir default-directory (buffer-file-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3634 (if (and (not dir) (buffer-modified-p)) (error "Save buffer first!")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3635 (let ((tags-file-name "TAGS")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3636 (case-fold-search (eq system-type 'emx))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3637 xs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3638 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3639 (cond (inbuffer nil) ; Already there
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3640 ((file-exists-p tags-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3641 (visit-tags-table-buffer tags-file-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3642 (t (set-buffer (find-file-noselect tags-file-name))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3643 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3644 (dir
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3645 (cond ((eq erase 'ignore))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3646 (erase
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3647 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3648 (setq erase 'ignore)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3649 (let ((files
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3650 (directory-files file t (if recurse nil "\\.[Pp][Llm]$") t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3651 (mapcar (function (lambda (file)
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 ((string-match "/\\.\\.?$" file) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3654 ((not (file-directory-p file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3655 (if (string-match "\\.\\([Pp][Llm]\\|xs\\)$" file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3656 (cperl-write-tags file erase recurse nil t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3657 ((not recurse) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3658 (t (cperl-write-tags file erase recurse t t)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3659 files))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3660 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3661 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3662 (setq xs (string-match "\\.xs$" file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3663 (cond ((eq erase 'ignore) nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3664 (erase (erase-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3665 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3666 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3667 (if (search-forward (concat "\f\n" file ",") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3668 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3669 (search-backward "\f\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3670 (delete-region (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3671 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3672 (forward-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3673 (search-forward "\f\n" nil 'toend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3674 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3675 (goto-char 1)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3676 (insert (cperl-find-tags file xs))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3677 (if inbuffer nil ; Delegate to the caller
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3678 (save-buffer 0) ; No backup
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3679 (initialize-new-tags-table)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3680
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3681 (defvar cperl-tags-hier-regexp-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3682 "^\\(\\(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
3683
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3684 (defvar cperl-hierarchy '(() ())
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3685 "Global hierarchy of classes")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3686
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3687 (defun cperl-tags-hier-fill ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3688 ;; Suppose we are in a tag table cooked by cperl.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3689 (goto-char 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3690 (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
3691 (while (re-search-forward cperl-tags-hier-regexp-list nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3692 (setq pos (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3693 pack (match-beginning 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3694 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3695 (if (looking-at "\\([^\n]+\\)\C-?\\([^\n]+\\)\C-a\\([0-9]+\\),\\([0-9]+\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3696 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3697 (setq ;;str (buffer-substring (match-beginning 1) (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3698 name (buffer-substring (match-beginning 2) (match-end 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3699 ;;pos (buffer-substring (match-beginning 3) (match-end 3))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3700 line (buffer-substring (match-beginning 4) (match-end 4))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3701 ord (if pack 1 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3702 info (etags-snarf-tag) ; Moves to beginning of the next line
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3703 file (file-of-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3704 fileind (format "%s:%s" file line))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3705 ;; Move back
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3706 (forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3707 ;; Make new member of hierarchy name ==> file ==> pos if needed
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3708 (if (setq cons1 (assoc name (nth ord cperl-hierarchy)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3709 ;; Name known
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3710 (setcdr cons1 (cons (cons fileind (vector file info))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3711 (cdr cons1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3712 ;; First occurrence of the name, start alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3713 (setq cons1 (cons name (list (cons fileind (vector file info)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3714 (if pack
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3715 (setcar (cdr cperl-hierarchy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3716 (cons cons1 (nth 1 cperl-hierarchy)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3717 (setcar cperl-hierarchy
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3718 (cons cons1 (car cperl-hierarchy)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3719 (end-of-line))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3720
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3721 (defun cperl-tags-hier-init (&optional update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3722 "Show hierarchical menu of classes and methods.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3723 Finds info about classes by a scan of loaded TAGS files.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3724 Supposes that the TAGS files contain fully qualified function names.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3725 One may build such TAGS files from CPerl mode menu."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3726 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3727 (require 'etags)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3728 (require 'imenu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3729 (if (or update (null (nth 2 cperl-hierarchy)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3730 (let (pack name cons1 to l1 l2 l3 l4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3731 (remover (function (lambda (elt) ; (name (file1...) (file2..))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3732 (or (nthcdr 2 elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3733 ;; Only in one file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3734 (setcdr elt (cdr (nth 1 elt))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3735 ;; (setq cperl-hierarchy '(() () ())) ; Would write into '() later!
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3736 (setq cperl-hierarchy (list l1 l2 l3))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3737 (or tags-table-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3738 (call-interactively 'visit-tags-table))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3739 (message "Updating list of classes...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3740 (mapcar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3741 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3742 (lambda (tagsfile)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3743 (set-buffer (get-file-buffer tagsfile))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3744 (cperl-tags-hier-fill)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3745 tags-table-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3746 (mapcar remover (car cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3747 (mapcar remover (nth 1 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3748 (setq to (list nil (cons "Packages: " (nth 1 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3749 (cons "Methods: " (car cperl-hierarchy))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3750 (cperl-tags-treeify to 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3751 (setcar (nthcdr 2 cperl-hierarchy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3752 (cperl-menu-to-keymap (cons '("+++UPDATE+++" . -999) (cdr to))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3753 (message "Updating list of classes: done, requesting display...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3754 ;;(cperl-imenu-addback (nth 2 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3755 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3756 (or (nth 2 cperl-hierarchy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3757 (error "No items found"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3758 (setq update
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3759 ;;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3760 (if window-system
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3761 (x-popup-menu t (nth 2 cperl-hierarchy))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3762 (require 'tmm)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3763 (tmm-prompt t (nth 2 cperl-hierarchy))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3764 (if (and update (listp update))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3765 (progn (while (cdr update) (setq update (cdr update)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3766 (setq update (car update)))) ; Get the last from the list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3767 (if (vectorp update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3768 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3769 (find-file (elt update 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3770 (etags-goto-tag-location (elt update 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3771 (if (eq update -999) (cperl-tags-hier-init t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3772
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3773 (defun cperl-tags-treeify (to level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3774 ;; cadr of to is read-write. On start it is a cons
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3775 (let* ((regexp (concat "^\\(" (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3776 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3777 (make-list level "[_a-zA-Z0-9]+")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3778 "::")
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 (packages (cdr (nth 1 to)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3781 (methods (cdr (nth 2 to)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3782 l1 head tail cons1 cons2 ord writeto packs recurse
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3783 root-packages root-functions ms many_ms same_name ps
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3784 (move-deeper
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3785 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3786 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3787 (cond ((and (string-match regexp (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3788 (or (eq ord 1) (match-end 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3789 (setq head (substring (car elt) 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3790 tail (if (match-end 2) (substring (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3791 (match-end 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3792 recurse t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3793 (if (setq cons1 (assoc head writeto)) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3794 ;; Need to init new head
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3795 (setcdr writeto (cons (list head (list "Packages: ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3796 (list "Methods: "))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3797 (cdr writeto)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3798 (setq cons1 (nth 1 writeto)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3799 (setq cons2 (nth ord cons1)) ; Either packs or meths
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3800 (setcdr cons2 (cons elt (cdr cons2))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3801 ((eq ord 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3802 (setq root-functions (cons elt root-functions)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3803 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3804 (setq root-packages (cons elt root-packages))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3805 (setcdr to l1) ; Init to dynamic space
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3806 (setq writeto to)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3807 (setq ord 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3808 (mapcar move-deeper packages)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3809 (setq ord 2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3810 (mapcar move-deeper methods)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3811 (if recurse
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3812 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3813 (cperl-tags-treeify elt (1+ level))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3814 (cdr to)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3815 ;; Now add back functions removed from display
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3816 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3817 (setcdr to (cons elt (cdr to)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3818 root-functions)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3819 ;; Now add back packages removed from display
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3820 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3821 (setcdr to (cons (cons (concat "package " (car elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3822 (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3823 (cdr to)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3824 root-packages)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3825 ;;Now clean up leaders with one child only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3826 (mapcar (function (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3827 (if (not (and (listp (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3828 (eq (length elt) 2))) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3829 (setcar elt (car (nth 1 elt)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3830 (setcdr elt (cdr (nth 1 elt))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3831 (cdr to))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3832 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3833
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3834 ;;;(x-popup-menu t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3835 ;;; '(keymap "Name1"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3836 ;;; ("Ret1" "aa")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3837 ;;; ("Head1" "ab"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3838 ;;; keymap "Name2"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3839 ;;; ("Tail1" "x") ("Tail2" "y"))))
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-list-fold (list name limit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3842 (let (list1 list2 elt1 (num 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3843 (if (<= (length list) limit) list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3844 (setq list1 nil list2 nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3845 (while list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3846 (setq num (1+ num)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3847 elt1 (car list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3848 list (cdr list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3849 (if (<= num imenu-max-items)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3850 (setq list2 (cons elt1 list2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3851 (setq list1 (cons (cons name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3852 (nreverse list2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3853 list1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3854 list2 (list elt1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3855 num 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3856 (nreverse (cons (cons name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3857 (nreverse list2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3858 list1)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3859
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3860 (defun cperl-menu-to-keymap (menu &optional name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3861 (let (list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3862 (cons 'keymap
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3863 (mapcar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3864 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3865 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3866 (cond ((listp (cdr elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3867 (setq list (cperl-list-fold
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3868 (cdr elt) (car elt) imenu-max-items))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3869 (cons nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3870 (cons (car elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3871 (cperl-menu-to-keymap list))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3872 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3873 (list (cdr elt) (car elt))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3874 (cperl-list-fold menu "Root" imenu-max-items)))))
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3877 (defvar cperl-bad-style-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3878 (mapconcat 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3879 '("[^-\n\t <>=+!.&|(*/'`\"#^][-=+<>!|&^]" ; char sign
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3880 "[-<>=+^&|]+[^- \t\n=+<>~]" ; sign+ char
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3881 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3882 "\\|")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3883 "Finds places such that insertion of a whitespace may help a lot.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3884
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3885 (defvar cperl-not-bad-style-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3886 (mapconcat 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3887 '("[^-\t <>=+]\\(--\\|\\+\\+\\)" ; var-- var++
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3888 "[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
3889 "&[(a-zA-Z0-9$]" ; &subroutine &(var->field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3890 "<\\$?\\sw+\\(\\.\\sw+\\)?>" ; <IN> <stdin.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3891 "-[a-zA-Z][ \t]+[_$\"'`]" ; -f file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3892 "-[0-9]" ; -5
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3893 "\\+\\+" ; ++var
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3894 "--" ; --var
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3895 ".->" ; a->b
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3896 "->" ; a SPACE ->b
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3897 "\\[-" ; a[-1]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3898 "^=" ; =head
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 "&&"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3901 "[CBIXSLFZ]<\\(\\sw\\|\\s \\|\\s_\\|[\n]\\)*>" ; C<code like text>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3902 "-[a-zA-Z0-9]+[ \t]*=>" ; -option => value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3903 ;; Unaddressed trouble spots: = -abc, f(56, -abc) --- specialcased below
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3904 ;;"[*/+-|&<.]+="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3905 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3906 "\\|")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3907 "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
3908 insertion of a whitespace will not help.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3909
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3910 (defvar found-bad)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3911
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3912 (defun cperl-find-bad-style ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3913 "Find places in the buffer where insertion of a whitespace may help.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3914 Prompts user for insertion of spaces.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3915 Currently it is tuned to C and Perl syntax."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3916 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3917 (let (found-bad (p (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3918 (setq last-nonmenu-event 13) ; To disable popup
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3919 (beginning-of-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3920 (map-y-or-n-p "Insert space here? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3921 (function (lambda (arg) (insert " ")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3922 'cperl-next-bad-style
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3923 '("location" "locations" "insert a space into")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3924 '((?\C-r (lambda (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3925 (let ((buffer-quit-function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3926 'exit-recursive-edit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3927 (message "Exit with Esc Esc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3928 (recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3929 t)) ; Consider acted upon
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3930 "edit, exit with Esc Esc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3931 (?e (lambda (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3932 (let ((buffer-quit-function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3933 'exit-recursive-edit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3934 (message "Exit with Esc Esc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3935 (recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3936 t)) ; Consider acted upon
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3937 "edit, exit with Esc Esc"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3938 t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3939 (if found-bad (goto-char found-bad)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3940 (goto-char p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3941 (message "No appropriate place found"))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3942
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3943 (defun cperl-next-bad-style ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3944 (let (p (not-found t) (point (point)) found)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3945 (while (and not-found
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3946 (re-search-forward cperl-bad-style-regexp nil 'to-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3947 (setq p (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3948 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3949 (if (or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3950 (looking-at cperl-not-bad-style-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3951 ;; Check for a < -b and friends
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3952 (and (eq (following-char) ?\-)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3953 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3954 (skip-chars-backward " \t\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3955 (memq (preceding-char) '(?\= ?\> ?\< ?\, ?\(, ?\[, ?\{))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3956 ;; Now check for syntax type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3957 (save-match-data
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3958 (setq found (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3959 (beginning-of-defun)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3960 (let ((pps (parse-partial-sexp (point) found)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3961 (or (nth 3 pps) (nth 4 pps) (nth 5 pps)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3962 (goto-char (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3963 (goto-char (1- p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3964 (setq not-found nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3965 found-bad found)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3966 (not not-found)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3967
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3968 
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3969 ;;; Getting help
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3970 (defvar cperl-have-help-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3971 ;;(concat "\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3972 (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3973 'identity
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3974 '("[$@%*&][0-9a-zA-Z_:]+" ; Usual variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3975 "[$@]\\^[a-zA-Z]" ; Special variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3976 "[$@][^ \n\t]" ; Special variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3977 "-[a-zA-Z]" ; File test
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3978 "\\\\[a-zA-Z0]" ; Special chars
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3979 "[-!&*+,-./<=>?\\\\^|~]+" ; Operator
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3980 "[a-zA-Z_0-9:]+" ; symbol or number
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3981 "x="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3982 "#!"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3983 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3984 ;;"\\)\\|\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3985 "\\|"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3986 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3987 ;;"\\)"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3988 ;;)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3989 "Matches places in the buffer we can find help for.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3990
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3991 (defvar cperl-message-on-help-error t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3992
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3993 (defun cperl-get-help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3994 "Get one-line docs on the symbol at the point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3995 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
3996 than a line. Your contribution to update/shorten it is appreciated."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3997 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3998 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3999 ;; Get to the something meaningful
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4000 (or (eobp) (eolp) (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4001 (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4002 (save-excursion (beginning-of-line) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4003 'to-beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4004 ;; (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4005 ;; ((or (eobp) (looking-at "[][ \t\n{}();,]")) ; Not at a symbol
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4006 ;; (skip-chars-backward " \n\t\r({[]});,")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4007 ;; (or (bobp) (backward-char 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4008 ;; Try to backtrace
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4009 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4010 ((looking-at "[a-zA-Z0-9_:]") ; symbol
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4011 (skip-chars-backward "[a-zA-Z0-9_:]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4012 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4013 ((and (eq (preceding-char) ?^) ; $^I
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4014 (eq (char-after (- (point) 2)) ?\$))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4015 (forward-char -2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4016 ((memq (preceding-char) (append "*$@%&\\" nil)) ; *glob
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4017 (forward-char -1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4018 (if (and (eq (preceding-char) ?\<)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4019 (looking-at "\\$?[a-zA-Z0-9_:]+>")) ; <FH>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4020 (forward-char -1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4021 ((and (looking-at "=") (eq (preceding-char) ?x)) ; x=
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4022 (forward-char -1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4023 ((and (looking-at "\\^") (eq (preceding-char) ?\$)) ; $^I
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4024 (forward-char -1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4025 ((looking-at "[-!&*+,-./<=>?\\\\^|~]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4026 (skip-chars-backward "[-!&*+,-./<=>?\\\\^|~]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4027 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4028 ((and (eq (preceding-char) ?\$)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4029 (not (eq (char-after (- (point) 2)) ?\$))) ; $-
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4030 (forward-char -1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4031 ((and (eq (following-char) ?\>)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4032 (string-match "[a-zA-Z0-9_]" (char-to-string (preceding-char)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4033 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4034 (forward-sexp -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4035 (and (eq (preceding-char) ?\<)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4036 (looking-at "\\$?[a-zA-Z0-9_:]+>")))) ; <FH>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4037 (search-backward "<"))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4038 ((and (eq (following-char) ?\$)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4039 (eq (preceding-char) ?\<)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4040 (looking-at "\\$?[a-zA-Z0-9_:]+>")) ; <$fh>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4041 (forward-char -1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4042 ;;(or (eobp) (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4043 (if (looking-at cperl-have-help-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4044 (cperl-describe-perl-symbol
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4045 (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4046 (if cperl-message-on-help-error
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4047 (message "Nothing found for %s..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4048 (buffer-substring (point) (+ 5 (point))))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4049
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4050 ;;; Stolen from perl-descr.el by Johan Vromans:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4051
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4052 (defvar cperl-doc-buffer " *perl-doc*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4053 "Where the documentation can be found.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4054
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4055 (defun cperl-describe-perl-symbol (val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4056 "Display the documentation of symbol at point, a Perl operator."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4057 ;; We suppose that the current position is at the start of the symbol
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4058 ;; when we convert $_[5] to @_
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4059 (let (;;(fn (perl-symbol-at-point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4060 (enable-recursive-minibuffers t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4061 ;;val
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4062 args-file regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4063 ;; (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4064 ;; (let ((fn (perl-symbol-at-point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4065 ;; (enable-recursive-minibuffers t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4066 ;; val args-file regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4067 ;; (setq val (read-from-minibuffer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4068 ;; (if fn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4069 ;; (format "Symbol (default %s): " fn)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4070 ;; "Symbol: ")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4071 ;; (if (string= val "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4072 ;; (setq val fn))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4073 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4074 ((string-match "^[&*][a-zA-Z_]" val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4075 (setq val (concat (substring val 0 1) "NAME")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4076 ((looking-at "[$@][a-zA-Z_:0-9]+\\([[{]\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4077 (if (= ?\[ (char-after (match-beginning 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4078 (setq val (concat "@" (substring val 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4079 (setq val (concat "%" (substring val 1)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4080 ((and (string= val "x") (looking-at "x="))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4081 (setq val "x="))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4082 ((string-match "^\\$[\C-a-\C-z]" val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4083 (setq val (concat "$^" (char-to-string (+ ?A -1 (aref val 1))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4084 ((and (string= "<" val) (looking-at "<\\$?[a-zA-Z0-9_:]+>"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4085 (setq val "<NAME>")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4086 ;;; (if (string-match "^[&*][a-zA-Z_]" val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4087 ;;; (setq val (concat (substring val 0 1) "NAME"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4088 ;;; (if (looking-at "[$@][a-zA-Z_:0-9]+\\([[{]\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4089 ;;; (if (= ?\[ (char-after (match-beginning 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4090 ;;; (setq val (concat "@" (substring val 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4091 ;;; (setq val (concat "%" (substring val 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4092 ;;; (if (and (string= val "x") (looking-at "x="))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4093 ;;; (setq val "x=")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4094 ;;; (if (looking-at "[$@][a-zA-Z_:0-9]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4095 ;;; ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4096 (setq regexp (concat "^" "\\([^a-zA-Z0-9_:]+[ \t]\\)?"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4097 (regexp-quote val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4098 "\\([ \t([/]\\|$\\)"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4099
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4100 ;; get the buffer with the documentation text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4101 (cperl-switch-to-doc-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4102
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4103 ;; lookup in the doc
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4104 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4105 (let ((case-fold-search nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4106 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4107 (if (re-search-forward regexp (point-max) t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4108 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4109 (beginning-of-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4110 (let ((lnstart (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4111 (end-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4112 (message "%s" (buffer-substring lnstart (point)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4113 (if cperl-message-on-help-error
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4114 (message "No definition for %s" val)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4115
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4116 (defvar cperl-short-docs "Ignore my value"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4117 "# based on '@(#)@ perl-descr.el 1.9 - describe-perl-symbol' [Perl 5]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4118 ! Logical negation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4119 != Numeric inequality.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4120 !~ Search pattern, substitution, or translation (negated).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4121 $! In numeric context: errno. In a string context: error string.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4122 $\" The separator which joins elements of arrays interpolated in strings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4123 $# The output format for printed numbers. Initial value is %.20g.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4124 $$ The process number of the perl running this script. Altered (in the child process) by fork().
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4125 $% The current page number of the currently selected output channel.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4126
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4127 The following variables are always local to the current block:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4128
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4129 $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
4130 $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
4131 $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
4132 $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
4133 $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
4134 $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
4135 $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
4136 $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
4137 $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
4138 $& The string matched by the last pattern match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4139 $' The string after what was matched by the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4140 $` The string before what was matched by the last match (auto-local).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4141
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4142 $( The real gid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4143 $) The effective gid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4144 $* Deprecated: Set to 1 to do multiline matching within a string.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4145 $+ The last bracket matched by the last search pattern.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4146 $, The output field separator for the print operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4147 $- The number of lines left on the page.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4148 $. The current input line number of the last filehandle that was read.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4149 $/ The input record separator, newline by default.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4150 $0 The name of the file containing the perl script being executed. May be set
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4151 $: The set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4152 $; The subscript separator for multi-dimensional array emulation. Default is \"\\034\".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4153 $< The real uid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4154 $= The page length of the current output channel. Default is 60 lines.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4155 $> The effective uid of this process.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4156 $? The status returned by the last ``, pipe close or `system'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4157 $@ 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
4158 $ARGV The name of the current file used with <> .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4159 $[ Deprecated: The index of the first element/char in an array/string.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4160 $\\ The output record separator for the print operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4161 $] The perl version string as displayed with perl -v.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4162 $^ The name of the current top-of-page format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4163 $^A The current value of the write() accumulator for format() lines.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4164 $^D The value of the perl debug (-D) flags.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4165 $^E Information about the last system error other than that provided by $!.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4166 $^F The highest system file descriptor, ordinarily 2.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4167 $^H The current set of syntax checks enabled by `use strict'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4168 $^I The value of the in-place edit extension (perl -i option).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4169 $^L What formats output to perform a formfeed. Default is \f.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4170 $^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
4171 $^P Internal debugging flag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4172 $^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
4173 $^W True if warnings are requested (perl -w flag).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4174 $^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
4175 $_ The default input and pattern-searching space.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4176 $| Flag for auto-flush after write/print on the currently selected output channel. Default is 0.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4177 $~ The name of the current report format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4178 % Modulo division.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4179 %= Modulo division assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4180 %ENV Contains the current environment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4181 %INC List of files that have been require-d or do-ne.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4182 %SIG Used to set signal handlers for various signals.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4183 & Bitwise and.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4184 && Logical and.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4185 &&= Logical and assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4186 &= Bitwise and assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4187 * Multiplication.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4188 ** Exponentiation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4189 *NAME Refers to all objects represented by NAME. *NAM1 = *NAM2 makes NAM1 a reference to NAM2.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4190 &NAME(arg0, ...) Subroutine call. Arguments go to @_.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4191 + Addition.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4192 ++ Auto-increment (magical on strings).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4193 += Addition assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4194 , Comma operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4195 - Subtraction.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4196 -- Auto-decrement.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4197 -= Subtraction assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4198 -A Access time in days since script started.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4199 -B File is a non-text (binary) file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4200 -C Inode change time in days since script started.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4201 -M Age in days since script started.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4202 -O File is owned by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4203 -R File is readable by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4204 -S File is a socket .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4205 -T File is a text file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4206 -W File is writable by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4207 -X File is executable by real uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4208 -b File is a block special file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4209 -c File is a character special file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4210 -d File is a directory.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4211 -e File exists .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4212 -f File is a plain file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4213 -g File has setgid bit set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4214 -k File has sticky bit set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4215 -l File is a symbolic link.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4216 -o File is owned by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4217 -p File is a named pipe (FIFO).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4218 -r File is readable by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4219 -s File has non-zero size.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4220 -t Tests if filehandle (STDIN by default) is opened to a tty.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4221 -u File has setuid bit set.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4222 -w File is writable by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4223 -x File is executable by effective uid.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4224 -z File has zero size.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4225 . Concatenate strings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4226 .. Alternation, also range operator.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4227 .= Concatenate assignment strings
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4228 / Division. /PATTERN/ioxsmg Pattern match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4229 /= Division assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4230 /PATTERN/ioxsmg Pattern match.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4231 < Numeric less than. <pattern> Glob. See <NAME>, <> as well.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4232 <NAME> Reads line from filehandle NAME. NAME must be bareword/dollar-bareword.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4233 <pattern> Glob. (Unless pattern is bareword/dollar-bareword - see <NAME>)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4234 <> Reads line from union of files in @ARGV (= command line) and STDIN.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4235 << Bitwise shift left. << start of HERE-DOCUMENT.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4236 <= Numeric less than or equal to.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4237 <=> Numeric compare.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4238 = Assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4239 == Numeric equality.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4240 =~ Search pattern, substitution, or translation
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4241 > Numeric greater than.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4242 >= Numeric greater than or equal to.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4243 >> Bitwise shift right.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4244 >>= Bitwise shift right assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4245 ? : Alternation (if-then-else) operator. ?PAT? Backwards pattern match.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4246 ?PATTERN? Backwards pattern match.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4247 @ARGV Command line arguments (not including the command name - see $0).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4248 @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
4249 @_ Parameter array for subroutines. Also used by split unless in array context.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4250 \\ Creates a reference to whatever follows, like \$var.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4251 \\0 Octal char, e.g. \\033.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4252 \\E Case modification terminator. See \\Q, \\L, and \\U.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4253 \\L Lowercase until \\E .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4254 \\U Upcase until \\E .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4255 \\Q Quote metacharacters until \\E .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4256 \\a Alarm character (octal 007).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4257 \\b Backspace character (octal 010).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4258 \\c Control character, e.g. \\c[ .
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4259 \\e Escape character (octal 033).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4260 \\f Formfeed character (octal 014).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4261 \\l Lowercase of next character. See also \\L and \\u,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4262 \\n Newline character (octal 012).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4263 \\r Return character (octal 015).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4264 \\t Tab character (octal 011).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4265 \\u Upcase of next character. See also \\U and \\l,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4266 \\x Hex character, e.g. \\x1b.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4267 ^ Bitwise exclusive or.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4268 __END__ End of program source.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4269 __DATA__ End of program source.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4270 __FILE__ Current (source) filename.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4271 __LINE__ Current line in current source.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4272 ARGV Default multi-file input filehandle. <ARGV> is a synonym for <>.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4273 ARGVOUT Output filehandle with -i flag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4274 BEGIN { block } Immediately executed (during compilation) piece of code.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4275 END { block } Pseudo-subroutine executed after the script finishes.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4276 DATA Input filehandle for what follows after __END__ or __DATA__.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4277 accept(NEWSOCKET,GENERICSOCKET)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4278 alarm(SECONDS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4279 atan2(X,Y)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4280 bind(SOCKET,NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4281 binmode(FILEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4282 caller[(LEVEL)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4283 chdir(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4284 chmod(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4285 chop[(LIST|VAR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4286 chown(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4287 chroot(FILENAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4288 close(FILEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4289 closedir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4290 cmp String compare.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4291 connect(SOCKET,NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4292 continue of { block } continue { block }. Is executed after `next' or at end.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4293 cos(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4294 crypt(PLAINTEXT,SALT)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4295 dbmclose(ASSOC_ARRAY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4296 dbmopen(ASSOC,DBNAME,MODE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4297 defined(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4298 delete($ASSOC{KEY})
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4299 die(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4300 do { ... }|SUBR while|until EXPR executes at least once
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4301 do(EXPR|SUBR([LIST]))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4302 dump LABEL
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4303 each(ASSOC_ARRAY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4304 endgrent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4305 endhostent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4306 endnetent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4307 endprotoent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4308 endpwent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4309 endservent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4310 eof[([FILEHANDLE])]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4311 eq String equality.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4312 eval(EXPR) or eval { BLOCK }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4313 exec(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4314 exit(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4315 exp(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4316 fcntl(FILEHANDLE,FUNCTION,SCALAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4317 fileno(FILEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4318 flock(FILEHANDLE,OPERATION)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4319 for (EXPR;EXPR;EXPR) { ... }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4320 foreach [VAR] (@ARRAY) { ... }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4321 fork
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4322 ge String greater than or equal.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4323 getc[(FILEHANDLE)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4324 getgrent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4325 getgrgid(GID)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4326 getgrnam(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4327 gethostbyaddr(ADDR,ADDRTYPE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4328 gethostbyname(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4329 gethostent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4330 getlogin
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4331 getnetbyaddr(ADDR,ADDRTYPE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4332 getnetbyname(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4333 getnetent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4334 getpeername(SOCKET)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4335 getpgrp(PID)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4336 getppid
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4337 getpriority(WHICH,WHO)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4338 getprotobyname(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4339 getprotobynumber(NUMBER)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4340 getprotoent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4341 getpwent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4342 getpwnam(NAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4343 getpwuid(UID)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4344 getservbyname(NAME,PROTO)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4345 getservbyport(PORT,PROTO)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4346 getservent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4347 getsockname(SOCKET)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4348 getsockopt(SOCKET,LEVEL,OPTNAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4349 gmtime(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4350 goto LABEL
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4351 grep(EXPR,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4352 gt String greater than.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4353 hex(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4354 if (EXPR) { ... } [ elsif (EXPR) { ... } ... ] [ else { ... } ] or EXPR if EXPR
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4355 index(STR,SUBSTR[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4356 int(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4357 ioctl(FILEHANDLE,FUNCTION,SCALAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4358 join(EXPR,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4359 keys(ASSOC_ARRAY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4360 kill(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4361 last [LABEL]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4362 le String less than or equal.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4363 length(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4364 link(OLDFILE,NEWFILE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4365 listen(SOCKET,QUEUESIZE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4366 local(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4367 localtime(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4368 log(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4369 lstat(EXPR|FILEHANDLE|VAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4370 lt String less than.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4371 m/PATTERN/iogsmx
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4372 mkdir(FILENAME,MODE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4373 msgctl(ID,CMD,ARG)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4374 msgget(KEY,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4375 msgrcv(ID,VAR,SIZE,TYPE.FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4376 msgsnd(ID,MSG,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4377 my VAR or my (VAR1,...) Introduces a lexical variable ($VAR, @ARR, or %HASH).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4378 ne String inequality.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4379 next [LABEL]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4380 oct(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4381 open(FILEHANDLE[,EXPR])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4382 opendir(DIRHANDLE,EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4383 ord(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4384 pack(TEMPLATE,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4385 package Introduces package context.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4386 pipe(READHANDLE,WRITEHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4387 pop(ARRAY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4388 print [FILEHANDLE] [(LIST)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4389 printf [FILEHANDLE] (FORMAT,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4390 push(ARRAY,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4391 q/STRING/ Synonym for 'STRING'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4392 qq/STRING/ Synonym for \"STRING\"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4393 qx/STRING/ Synonym for `STRING`
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4394 rand[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4395 read(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4396 readdir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4397 readlink(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4398 recv(SOCKET,SCALAR,LEN,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4399 redo [LABEL]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4400 rename(OLDNAME,NEWNAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4401 require [FILENAME | PERL_VERSION]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4402 reset[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4403 return(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4404 reverse(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4405 rewinddir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4406 rindex(STR,SUBSTR[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4407 rmdir(FILENAME)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4408 s/PATTERN/REPLACEMENT/gieoxsm
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4409 scalar(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4410 seek(FILEHANDLE,POSITION,WHENCE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4411 seekdir(DIRHANDLE,POS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4412 select(FILEHANDLE | RBITS,WBITS,EBITS,TIMEOUT)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4413 semctl(ID,SEMNUM,CMD,ARG)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4414 semget(KEY,NSEMS,SIZE,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4415 semop(KEY,...)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4416 send(SOCKET,MSG,FLAGS[,TO])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4417 setgrent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4418 sethostent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4419 setnetent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4420 setpgrp(PID,PGRP)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4421 setpriority(WHICH,WHO,PRIORITY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4422 setprotoent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4423 setpwent
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4424 setservent(STAYOPEN)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4425 setsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4426 shift[(ARRAY)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4427 shmctl(ID,CMD,ARG)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4428 shmget(KEY,SIZE,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4429 shmread(ID,VAR,POS,SIZE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4430 shmwrite(ID,STRING,POS,SIZE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4431 shutdown(SOCKET,HOW)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4432 sin(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4433 sleep[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4434 socket(SOCKET,DOMAIN,TYPE,PROTOCOL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4435 socketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4436 sort [SUBROUTINE] (LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4437 splice(ARRAY,OFFSET[,LENGTH[,LIST]])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4438 split[(/PATTERN/[,EXPR[,LIMIT]])]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4439 sprintf(FORMAT,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4440 sqrt(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4441 srand(EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4442 stat(EXPR|FILEHANDLE|VAR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4443 study[(SCALAR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4444 sub [NAME [(format)]] { BODY } or sub [NAME [(format)]];
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4445 substr(EXPR,OFFSET[,LEN])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4446 symlink(OLDFILE,NEWFILE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4447 syscall(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4448 sysread(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4449 system(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4450 syswrite(FILEHANDLE,SCALAR,LENGTH[,OFFSET])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4451 tell[(FILEHANDLE)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4452 telldir(DIRHANDLE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4453 time
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4454 times
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4455 tr/SEARCHLIST/REPLACEMENTLIST/cds
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4456 truncate(FILE|EXPR,LENGTH)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4457 umask[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4458 undef[(EXPR)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4459 unless (EXPR) { ... } [ else { ... } ] or EXPR unless EXPR
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4460 unlink(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4461 unpack(TEMPLATE,EXPR)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4462 unshift(ARRAY,LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4463 until (EXPR) { ... } or EXPR until EXPR
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4464 utime(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4465 values(ASSOC_ARRAY)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4466 vec(EXPR,OFFSET,BITS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4467 wait
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4468 waitpid(PID,FLAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4469 wantarray
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4470 warn(LIST)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4471 while (EXPR) { ... } or EXPR while EXPR
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4472 write[(EXPR|FILEHANDLE)]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4473 x Repeat string or array.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4474 x= Repetition assignment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4475 y/SEARCHLIST/REPLACEMENTLIST/
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4476 | Bitwise or.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4477 || Logical or.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4478 ~ Unary bitwise complement.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4479 #! OS interpreter indicator. If contains `perl', used for options, and -x.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4480 ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4481
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4482 (defun cperl-switch-to-doc-buffer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4483 "Go to the perl documentation buffer and insert the documentation."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4484 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4485 (let ((buf (get-buffer-create cperl-doc-buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4486 (if (interactive-p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4487 (switch-to-buffer-other-window buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4488 (set-buffer buf))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4489 (if (= (buffer-size) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4490 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4491 (insert (documentation-property 'cperl-short-docs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4492 'variable-documentation))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4493 (setq buffer-read-only t)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4494
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4495 (if (fboundp 'run-with-idle-timer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4496 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4497 (defvar cperl-help-shown nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4498 "Non-nil means that the help was already shown now.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4499
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4500 (defvar cperl-help-timer nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4501 "Non-nil means that the help was already shown now.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4502
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4503 (defun cperl-lazy-install ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4504 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4505 (make-variable-buffer-local 'cperl-help-shown)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4506 (if (cperl-val cperl-lazy-help-time)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4507 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4508 (add-hook 'post-command-hook 'cperl-lazy-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4509 (setq cperl-help-timer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4510 (run-with-idle-timer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4511 (cperl-val cperl-lazy-help-time 1000000 5)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4512 t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4513 'cperl-get-help-defer)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4514
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4515 (defun cperl-lazy-unstall ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4516 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4517 (remove-hook 'post-command-hook 'cperl-lazy-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4518 (cancel-timer cperl-help-timer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4519
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4520 (defun cperl-lazy-hook ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4521 (setq cperl-help-shown nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4522
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4523 (defun cperl-get-help-defer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4524 (if (not (eq major-mode 'perl-mode)) nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4525 (let ((cperl-message-on-help-error nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4526 (cperl-get-help)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4527 (setq cperl-help-shown t))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4528 (cperl-lazy-install)))