annotate lisp/modes/cperl-mode.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is not (yet) part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Corrections made by Ilya Zakharevich ilya@math.mps.ohio-state.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; XEmacs changes by Peter Arius arius@informatik.uni-erlangen.de
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; $Id: cperl-mode.el,v 1.1.1.1 1996/12/18 03:31:06 steve Exp $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; To use this mode put the following into your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; (autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; You can either fine-tune the bells and whistles of this mode or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; bulk enable them by putting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; (setq cperl-hairy t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; in your .emacs file. (Emacs rulers do not consider it politically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; correct to make whistles enabled by default.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; Additional useful commands to put into your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; (append '(("\\.[pP][Llm]$" . perl-mode)) auto-mode-alist ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; (setq interpreter-mode-alist (append interpreter-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; '(("miniperl" . perl-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; The mode information (on C-h m) provides customization help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; If you use font-lock feature of this mode, it is advisable to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; eather lazy-lock-mode or fast-lock-mode (available on ELisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; 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
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; Faces used now: three faces for first-class and second-class keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; and control flow words, one for each: comments, string, labels,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; functions definitions and packages, arrays, hashes, and variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; definitions. If you do not see all these faces, your font-lock does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; not define them, so you need to define them manually. Maybe you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; an obsolete font-lock from 19.28 or earlier. Upgrade.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; If you have grayscale monitor, and do not have the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; font-lock-display-type bound to 'grayscale, insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; (setq font-lock-display-type 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; to your .emacs file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;; This mode supports font-lock, imenu and mode-compile. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;;; hairy version font-lock is on, but you should activate imenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;; yourself (note that mode-compile is not standard yet). Well, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;; can use imenu from keyboard anyway (M-x imenu), but it is better
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;;; to bind it like that:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; (define-key global-map [M-S-down-mouse-3] 'imenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; In fact the version of font-lock that this version supports can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; much newer than the version you actually have. This means that a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; 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
83 ;;; since the coloring rules for this faces are not defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; Updates: ========================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; Made less hairy by default: parentheses not electric,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; linefeed not magic. Bug with abbrev-mode corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;; After 1.4:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; Better indentation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; subs inside braces should work now,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; Toplevel braces obey customization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; indent-for-comment knows about bad cases, cperl-indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; moves cursor to a correct place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; cperl-indent-exp written from the scratch! Slow... (quadratic!) :-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; (50 secs on DB::DB (sub of 430 lines), 486/66)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; Minor documentation fixes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; Imenu understands packages as prefixes (including nested).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; Hairy options can be switched off one-by-one by setting to null.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; Names of functions and variables changed to conform to `cperl-' style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;; After 1.5:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; Some bugs with indentation of labels (and embedded subs) corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; `cperl-indent-region' done (slow :-()).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; `cperl-fill-paragraph' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; Better package support for `imenu'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; Progress indicator for indentation (with `imenu' loaded).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; `Cperl-set' was busted, now setting the individual hairy option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; should be better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;;; After 1.6:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; `cperl-set-style' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; `cperl-check-syntax' done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; Menu done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; New config variables `cperl-close-paren-offset' and `cperl-comment-column'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; Bugs with `cperl-auto-newline' corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; `cperl-electric-lbrace' can work with `cperl-auto-newline' in situation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; like $hash{.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;; 1.7 XEmacs (arius@informatik.uni-erlangen.de):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; - use `next-command-event', if `next-command-events' does not exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; - use `find-face' as def. of `is-face'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; - corrected def. of `x-color-defined-p'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;; - added const defs for font-lock-comment-face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; font-lock-keyword-face and font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; - added def. of font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; - added (require 'easymenu) inside an `eval-when-compile'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; - replaced 4-argument `substitute-key-definition' with ordinary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; `define-key's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; - replaced `mark-active' in menu definition by `cperl-use-region-p'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; Todo (at least):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; - 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
134 ;;; for portable code?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; - should `cperl-mode' do a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; (if (featurep 'easymenu) (easy-menu-add cperl-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;; or should this be left to the user's `cperl-mode-hook'?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; Some bugs introduced by the above fix corrected (IZ ;-).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; Some bugs under XEmacs introduced by the correction corrected.
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 more can remain since there are two many different variants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; Please feedback!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; We do not support fontification of arrays and hashes under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; obsolete font-lock any more. Upgrade.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;;; after 1.8 Minor bug with parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;;; after 1.9 Improvements from Joe Marzot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;; after 1.10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;; Does not need easymenu to compile under XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;; `vc-insert-headers' should work better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; Should work with 19.29 and 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;; Small improvements to fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;; Expansion of keywords does not depend on C-? being backspace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; after 1.10+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; 19.29 and 19.12 supported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; `cperl-font-lock-enhanced' deprecated. Use font-lock-extra.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;; Support for font-lock-extra.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;;; After 1.11:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; Tools submenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; Support for perl5-info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;; `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
166 ;;; Imenu entries do not work with stock imenu.el. Patch sent to maintainers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; Fontifies `require a if b;', __DATA__.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;; Arglist for auto-fill-mode was incorrect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;;; After 1.12:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; `cperl-lineup-step' and `cperl-lineup' added: lineup constructions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; vertically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; `cperl-do-auto-fill' updated for 19.29 style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; `cperl-info-on-command' now has a default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; Workaround for broken C-h on XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;; VC strings escaped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; C-h f now may prompt for function name instead of going on,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; controlled by `cperl-info-on-command-no-prompt'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;;; After 1.13:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; Msb buffer list includes perl files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; Indent-for-comment uses indent-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; Can write tag files using etags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;;; After 1.14:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; Recognizes (tries to ;-) {...} which are not blocks during indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;; `cperl-close-paren-offset' affects ?\] too (and ?\} if not block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;; Bug with auto-filling comments started with "##" corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;;; Very slow now: on DB::DB 0.91, 486/66:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;;Function Name Call Count Elapsed Time Average Time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;======================================== ========== ============ ============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;;cperl-block-p 469 3.7799999999 0.0080597014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;;cperl-get-state 505 163.39000000 0.3235445544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;;cperl-comment-indent 12 0.0299999999 0.0024999999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;cperl-backward-to-noncomment 939 4.4599999999 0.0047497337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;;cperl-calculate-indent 505 172.22000000 0.3410297029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;cperl-indent-line 505 172.88000000 0.3423366336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;;cperl-use-region-p 40 0.0299999999 0.0007499999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;cperl-indent-exp 1 177.97000000 177.97000000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;;cperl-to-comment-or-eol 1453 3.9800000000 0.0027391603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;;cperl-backward-to-start-of-continued-exp 9 0.0300000000 0.0033333333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;cperl-indent-region 1 177.94000000 177.94000000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;;; After 1.15:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;; Takes into account white space after opening parentheses during indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;; May highlight pods and here-documents: see `cperl-pod-here-scan',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;; `cperl-pod-here-fontify', `cperl-pod-face'. Does not use this info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; for indentation so far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; Fontification updated to 19.30 style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;; The change 19.29->30 did not add all the required functionality,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;; but broke "font-lock-extra.el". Get "choose-color.el" from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;;; After 1.16:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;; else # comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;; recognized as a start of a block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;; Two different font-lock-levels provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; `cperl-pod-head-face' introduced. Used for highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;; `imenu' marks pods, +Packages moved to the head.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;;; After 1.17:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;; Scan for pods highlights here-docs too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;; 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
226 ;;; Only one here-doc-tag per line is supported, and one in comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; or a string may break fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; POD headers were supposed to fill one line only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;;; After 1.18:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; `font-lock-keywords' were set in 19.30 style _always_. Current scheme
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; may break under XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;; `cperl-calculate-indent' dis suppose that `parse-start' was defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; `fontified' tag is added to fontified text as well as `lazy-lock' (for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;; compatibility with older lazy-lock.el) (older one overfontifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; something nevertheless :-().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;; Will not indent something inside pod and here-documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; Fontifies the package name after import/no/bootstrap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;; Added new entry to menu with meta-info about the mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;;; After 1.19:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; Prefontification works much better with 19.29. Should be checked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;; with 19.30 as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;; Some misprints in docs corrected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; Now $a{-text} and -text => "blah" are fontified as strings too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; 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
247 ;;; pod sections which are broken because of whitespace before =blah
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;; - just observe the fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;;;; After 1.20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;; Anonymous subs are indented with respect to the level of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;; indentation of `sub' now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;; {} is recognized as hash after `bless' and `return'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;; Anonymous subs are split by `cperl-linefeed' as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; Electric parens embrace a region if present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;; To make `cperl-auto-newline' useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;; `cperl-auto-newline-after-colon' is introduced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;; `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
259 ;;; `cperl-electric-parens-string'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;; `cperl-toggle-auto-newline' introduced, put on C-c C-a.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;; `cperl-toggle-abbrev' introduced, put on C-c C-k.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;;; `cperl-toggle-electric' introduced, put on C-c C-e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;; Beginning-of-defun-regexp was not anchored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;;; After 1.21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;; Auto-newline grants `cperl-extra-newline-before-brace' if "{" is typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;; after ")".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;; {} is recognized as expression after `tr' and friends.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;; Works with XEmacs again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defvar cperl-extra-newline-before-brace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "*Non-nil means that if, elsif, while, until, else, for, foreach
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 and do constructs look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 instead of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 if () {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defvar cperl-indent-level 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "*Indentation of CPerl statements with respect to containing block.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defvar cperl-lineup-step nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "*`cperl-lineup' will always lineup at multiple of this number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 If `nil', the value of `cperl-indent-level' will be used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defvar cperl-brace-imaginary-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "*Imagined indentation of a Perl open brace that actually follows a statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 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
293 to the right of the start of its line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defvar cperl-brace-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 "*Extra indentation for braces, compared with other text in same context.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defvar cperl-label-offset -2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "*Offset of CPerl label lines relative to usual indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defvar cperl-min-label-indent 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 "*Minimal offset of CPerl label lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defvar cperl-continued-statement-offset 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "*Extra indent for lines not starting new statements.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defvar cperl-continued-brace-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "*Extra indent for substatements that start with open-braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 This is in addition to cperl-continued-statement-offset.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defvar cperl-close-paren-offset -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "*Extra indent for substatements that start with close-parenthesis.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defvar cperl-auto-newline nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "*Non-nil means automatically newline before and after braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 and after colons and semicolons, inserted in CPerl code. The following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 \\[cperl-electric-backspace] will remove the inserted whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 Insertion after colons requires both this variable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 `cperl-auto-newline-after-colon' set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defvar cperl-auto-newline-after-colon nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 "*Non-nil means automatically newline even after colons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 Subject to `cperl-auto-newline' setting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defvar cperl-tab-always-indent t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 "*Non-nil means TAB in CPerl mode should always reindent the current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 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
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defvar cperl-font-lock nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 "*Non-nil (and non-null) means CPerl buffers will use font-lock-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (defvar cperl-electric-lbrace-space nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "*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
329 Can be overwritten by `cperl-hairy' if nil.")
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-electric-parens-string "({[<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "*String of parentheses that should be electric in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defvar cperl-electric-parens nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 "*Non-nil (and non-null) means parentheses should be electric in CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (defvar cperl-electric-parens-mark (and window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (or (and ; Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (boundp 'transient-mark-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 transient-mark-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (and ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (boundp 'zmacs-regions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 zmacs-regions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "*Not-nil means that electric parens look for active mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 Default is yes if there is visual feedback on mark.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defvar cperl-electric-linefeed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "*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
350 In any case these two mean plain and hairy linefeeds together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defvar cperl-electric-keywords nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "*Not-nil (and non-null) means keywords are electric in CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defvar cperl-hairy nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "*Not-nil means all the bells and whistles are enabled in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defvar cperl-comment-column 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 "*Column to put comments in CPerl (use \\[cperl-indent]' to lineup with code).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defvar cperl-vc-header-alist '((SCCS "$sccs = '%W\%' ;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (RCS "$rcs = ' $Id\$ ' ;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "*What to use as `vc-header-alist' in CPerl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defvar cperl-info-on-command-no-prompt nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "*Not-nil (and non-null) means not to prompt on C-h f.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 The opposite behaviour is always available if prefixed with C-c.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Can be overwritten by `cperl-hairy' if nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defvar cperl-pod-face 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "*The result of evaluation of this expression is used for pod highlighting.")
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-pod-head-face 'font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "*The result of evaluation of this expression is used for pod highlighting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Font for POD headers.")
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-here-face 'font-lock-string-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "*The result of evaluation of this expression is used for here-docs highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defvar cperl-pod-here-fontify '(featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "*Not-nil after evaluation means to highlight pod and here-docs sections.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (defvar cperl-pod-here-scan t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 "*Not-nil means look for pod and here-docs sections during startup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 You can always make lookup from menu or using \\[cperl-find-pods-heres].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;;; Short extra-docs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defvar cperl-tips 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Get newest version of this package from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 Get support packages font-lock-extra.el, imenu-go.el from the same place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 \(Look for other files there too... ;-) Get a patch for imenu.el in 19.29.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 Note that for 19.30 you should use choose-color.el *instead* of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 font-lock-extra.el (and you will not get smart highlighting in C :-().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 Note that to enable Compile choices in the menu you need to install
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 mode-compile.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Get perl5-info from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 http://www.metronet.com:70/9/perlinfo/perl5/manual/perl5-info.tar.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 \(may be quite obsolete, but still useful).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 If you use imenu-go, run imenu on perl5-info buffer (you can do it from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 CPerl menu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 Before reporting (non-)problems look in the problem section on what I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 know about them.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (defvar cperl-problems 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "Emacs has a _very_ restricted syntax parsing engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 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
421 `non-problems' section if you want to volunteer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 CPerl mode tries to corrects some Emacs misunderstandings, however,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 for effeciency reasons the degree of correction is different for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 different operations. The partially corrected problems are: POD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 sections, here-documents, regexps. The operations are: highlighting,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 indentation, electric keywords, electric braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 This may be confusing, since the regexp s#//#/#\; may be highlighted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 as a comment, but it will recognized as a regexp by the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 code. Or the opposite case, when a pod section is highlighted, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 breaks the indentation of the following code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 The main trick (to make $ a \"backslash\") makes constructions like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ${aaa} look like unbalanced braces. The only trick I can think out is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 to insert it as $ {aaa} (legal in perl5, not in perl4).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Similar problems arise in regexps, when /(\\s|$)/ should be rewritten
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 as /($|\\s)/. Note that such a transpositinon is not always possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 :-(. " )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defvar cperl-non-problems 'please-ignore-this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 "As you know from `problems' section, Perl syntax too hard for CPerl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 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
446 \(and almost as readable) expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Try to help it: add comments with embedded quotes to fix CPerl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 misunderstandings about the end of quotation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 $a='500$'; # ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 You won't need it too often. The reason: $ \"quotes\" the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 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
455 Emacs parsing rules it does not consider tick after the dollar as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 closing one, but as a usual character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 Now the indentation code is pretty wise. The only drawback is that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 relies on Emacs parsing to find matching parentheses. And Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 *cannot* match parentheses in Perl 100% correctly. So
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 1 if s#//#/#;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 will not break indentation, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 1 if ( s#//#/# );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 will.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 If you still get wrong indentation in situation that you think the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 code should be able to parse, try:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 a) Check what Emacs thinks about balance of your parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 b) Supply the code to me (IZ).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 Pods are treated _very_ rudimentally. Here-documents are not treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 at all (except highlighting and inhibiting indentation). (This may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 change some time. RMS approved making syntax lookup recognize text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 attributes, but volonteers are needed to change Emacs C code.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 To speed up coloring the following compromises exist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 a) sub in $mypackage::sub may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 b) -z in [a-z] may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 c) if your regexp contains a keyword (like \"s\"), it may be highlighted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;;; Portability stuff:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defsubst cperl-xemacs-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (string-match "XEmacs\\|Lucid" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (defvar del-back-ch (car (append (where-is-internal 'delete-backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (where-is-internal 'backward-delete-char-untabify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 "Character generated by key bound to delete-backward-char.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (and (vectorp del-back-ch) (= (length del-back-ch) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (setq del-back-ch (aref del-back-ch 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (if (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; "Active regions" are on: use region only if active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; "Active regions" are off: use region unconditionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (defun cperl-use-region-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (if zmacs-regions (mark) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (defun cperl-mark-active () (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defun cperl-use-region-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (if transient-mark-mode mark-active t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (defun cperl-mark-active () mark-active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defsubst cperl-enable-font-lock ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (or (cperl-xemacs-p) window-system))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (if (boundp 'unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (if (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (defun cperl-putback-char (c) ; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (setq unread-command-events (list (character-to-event c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (defun cperl-putback-char (c) ; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (setq unread-command-events (list c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defun cperl-putback-char (c) ; XEmacs <= 19.11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (setq unread-command-event (character-to-event c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (or (fboundp 'uncomment-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defun uncomment-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (comment-region beg end -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defvar cperl-do-not-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (if (string< emacs-version "19.30")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 'fontified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 'lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "Text property which inhibits refontification.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;;; 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
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (append '(("\\.[pP][Llm]$" . perl-mode)) auto-mode-alist ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (and (boundp 'interpreter-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (setq interpreter-mode-alist (append interpreter-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 '(("miniperl" . perl-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (if (fboundp 'eval-when-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (require 'imenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;; macros instead of defsubsts don't work on Emacs, so we do the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;; expansion manually. Any other suggestions?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (if (or (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 window-system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (require 'font-lock))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (defvar cperl-mode-abbrev-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 "Abbrev table in use in Cperl-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (add-hook 'edit-var-mode-alist '(perl-mode (regexp . "^cperl-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defvar cperl-mode-map () "Keymap used in CPerl mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (if cperl-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (setq cperl-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (define-key cperl-mode-map "{" 'cperl-electric-lbrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (define-key cperl-mode-map "[" 'cperl-electric-paren)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (define-key cperl-mode-map "(" 'cperl-electric-paren)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (define-key cperl-mode-map "<" 'cperl-electric-paren)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (define-key cperl-mode-map "}" 'cperl-electric-brace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (define-key cperl-mode-map ";" 'cperl-electric-semi)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (define-key cperl-mode-map ":" 'cperl-electric-terminator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (define-key cperl-mode-map "\C-j" 'newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (define-key cperl-mode-map "\C-c\C-j" 'cperl-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (define-key cperl-mode-map "\C-c\C-a" 'cperl-toggle-auto-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (define-key cperl-mode-map "\C-c\C-k" 'cperl-toggle-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (define-key cperl-mode-map "\C-c\C-e" 'cperl-toggle-electric)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (define-key cperl-mode-map "\e\C-q" 'cperl-indent-exp) ; Usually not bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;;(define-key cperl-mode-map "\M-q" 'cperl-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;;(define-key cperl-mode-map "\e;" 'cperl-indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (define-key cperl-mode-map "\177" 'cperl-electric-backspace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (define-key cperl-mode-map "\t" 'cperl-indent-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; don't clobber the backspace binding:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (define-key cperl-mode-map [(control h) f] 'cperl-info-on-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (define-key cperl-mode-map "\C-hf" 'cperl-info-on-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (if (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; don't clobber the backspace binding:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (define-key cperl-mode-map [(control c) (control h) f]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 'cperl-info-on-current-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (define-key cperl-mode-map "\C-c\C-hf" 'cperl-info-on-current-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (if (and (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (<= emacs-minor-version 11) (<= emacs-major-version 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;; substitute-key-definition is usefulness-deenhanced...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (define-key cperl-mode-map "\M-q" 'cperl-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (define-key cperl-mode-map "\e;" 'cperl-indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (define-key cperl-mode-map "\e\C-\\" 'cperl-indent-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 'indent-sexp 'cperl-indent-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 'fill-paragraph 'cperl-fill-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 'indent-region 'cperl-indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 cperl-mode-map global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 'indent-for-comment 'cperl-indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 cperl-mode-map global-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (easy-menu-define cperl-menu cperl-mode-map "Menu for CPerl mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 '("Perl"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ["Beginning of function" beginning-of-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ["End of function" end-of-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ["Mark function" mark-defun t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ["Indent expression" cperl-indent-exp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ["Fill paragraph/comment" cperl-fill-paragraph t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ["Line up a construction" cperl-lineup (cperl-use-region-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ["Indent region" cperl-indent-region (cperl-use-region-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ["Comment region" comment-region (cperl-use-region-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ["Uncomment region" uncomment-region (cperl-use-region-p)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ["Run" mode-compile (fboundp 'mode-compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ["Kill" mode-compile-kill (and (fboundp 'mode-compile-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (get-buffer "*compilation*"))]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ["Next error" next-error (get-buffer "*compilation*")]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ["Check syntax" cperl-check-syntax (fboundp 'mode-compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ["Debugger" perldb t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ("Tools"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ["Imenu" imenu (fboundp 'imenu)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ["Imenu on info" cperl-imenu-on-info (featurep 'imenu)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ("Tags"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ["Create tags for current file" cperl-etags t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ["Add tags for current file" (cperl-etags t) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ["Create tags for Perl files in directory" (cperl-etags nil t) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ["Add tags for Perl files in directory" (cperl-etags t t) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ["Create tags for Perl files in (sub)directories"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (cperl-etags nil 'recursive) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ["Add tags for Perl files in (sub)directories"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (cperl-etags t 'recursive) t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ["Recalculate PODs" cperl-find-pods-heres t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ["Define word at point" imenu-go-find-at-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (fboundp 'imenu-go-find-at-position)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ["Help on function" cperl-info-on-command t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ["Help on function at point" cperl-info-on-current-command t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ("Toggle..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ["Auto newline" cperl-toggle-auto-newline t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ["Electric parens" cperl-toggle-electric t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ["Electric keywords" cperl-toggle-abbrev t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ("Indent styles..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ["GNU" (cperl-set-style "GNU") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ["C++" (cperl-set-style "C++") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ["FSF" (cperl-set-style "FSF") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ["BSD" (cperl-set-style "BSD") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ["Whitesmith" (cperl-set-style "Whitesmith") t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ("Micro-docs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ["Tips" (describe-variable 'cperl-tips) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ["Problems" (describe-variable 'cperl-problems) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ["Non-problems" (describe-variable 'cperl-non-problems) t]))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (autoload 'c-macro-expand "cmacexp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 "Display the result of expanding all C macros occurring in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 The expansion is entirely correct because it uses the C preprocessor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (defvar cperl-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 "Syntax table in use in Cperl-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (if cperl-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (setq cperl-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (modify-syntax-entry ?\\ "\\" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (modify-syntax-entry ?/ "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (modify-syntax-entry ?* "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (modify-syntax-entry ?+ "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (modify-syntax-entry ?- "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (modify-syntax-entry ?= "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (modify-syntax-entry ?% "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (modify-syntax-entry ?< "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (modify-syntax-entry ?> "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (modify-syntax-entry ?& "." cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (modify-syntax-entry ?$ "\\" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (modify-syntax-entry ?\n ">" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (modify-syntax-entry ?# "<" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (modify-syntax-entry ?' "\"" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (modify-syntax-entry ?` "\"" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (modify-syntax-entry ?_ "w" cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (modify-syntax-entry ?| "." cperl-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;; Make customization possible "in reverse"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ;;(defun cperl-set (symbol to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 ;; (or (eq (symbol-value symbol) 'null) (set symbol to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (defsubst cperl-val (symbol &optional default hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ((eq (symbol-value symbol) 'null) default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (cperl-hairy (or hairy t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (t (symbol-value symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;; provide an alias for working with emacs 19. the perl-mode that comes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;; with it is really bad, and this lets us seamlessly replace it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (fset 'perl-mode 'cperl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (defun cperl-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 "Major mode for editing Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 Expression and list commands understand all C brackets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Tab indents for Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 Paragraphs are separated by blank lines only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 Delete converts tabs to spaces as it moves back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 Various characters in Perl almost always come in pairs: {}, (), [],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 sometimes <>. When the user types the first, she gets the second as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 well, with optional special formatting done on {}. (Disabled by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 default.) You can always quote (with \\[quoted-insert]) the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 \"paren\" to avoid the expansion. The processing of < is special,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 since most the time you mean \"less\". Cperl mode tries to guess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 whether you want to type pair <>, and inserts is if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 appropriate. You can set `cperl-electric-parens-string' to the string that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 contains the parenths from the above list you want to be electrical.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 Electricity of parenths is controlled by `cperl-electric-parens'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 You may also set `cperl-electric-parens-mark' to have electric parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 look for active mark and \"embrace\" a region if possible.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 CPerl mode provides expansion of the Perl control constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 if, else, elsif, unless, while, until, for, and foreach.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 =========(Disabled by default, see `cperl-electric-keywords'.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 The user types the keyword immediately followed by a space, which causes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 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
737 likely to want to be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 eg. when the user types a space following \"if\" the following appears in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 the buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 if () { or if ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 } {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 and the cursor is between the parentheses. The user can then type some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 boolean expression within the parens. Having done that, typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 \\[cperl-linefeed] places you, appropriately indented on a new line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 between the braces. If CPerl decides that you want to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 \"English\" style construct like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 bite if angry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 it will not do any expansion. See also help on variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 `cperl-extra-newline-before-brace'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 \\[cperl-linefeed] is a convinience replacement for typing carriage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 return. It places you in the next line with proper indentation, or if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 you type it inside the inline block of control construct, like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 foreach (@lines) {print; print}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 and you are on a boundary of a statement inside braces, it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 transform the construct into a multiline and will place you into an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 apporpriately indented blank line. If you need a usual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 `newline-and-indent' behaviour, it is on \\[newline-and-indent],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 see documentation on `cperl-electric-linefeed'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 \\{cperl-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 Setting the variable `cperl-font-lock' to t switches on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 font-lock-mode, `cperl-electric-lbrace-space' to t switches on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 electric space between $ and {, `cperl-electric-parens-string' is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 string that contains parentheses that should be electric in CPerl (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 also `cperl-electric-parens-mark' and `cperl-electric-parens'),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 setting `cperl-electric-keywords' enables electric expansion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 control structures in CPerl. `cperl-electric-linefeed' governs which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 one of two linefeed behavior is preferable. You can enable all these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 options simultaneously (recommended mode of use) by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 `cperl-hairy' to t. In this case you can switch separate options off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 by setting them to `null'. Note that one may undo the extra whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 inserted by semis and braces in `auto-newline'-mode by consequent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 \\[cperl-electric-backspace].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 If your site has perl5 documentation in info format, you can use commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 \\[cperl-info-on-current-command] and \\[cperl-info-on-command] to access it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 These keys run commands `cperl-info-on-current-command' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 `cperl-info-on-command', which one is which is controlled by variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 `cperl-info-on-command-no-prompt' (in turn affected by `cperl-hairy').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 Variables `cperl-pod-here-scan', `cperl-pod-here-fontify',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 `cperl-pod-face', `cperl-pod-head-face' control processing of pod and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 here-docs sections. In a future version results of scan may be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 for indentation too, currently they are used for highlighting only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 Variables controlling indentation style:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 `cperl-tab-always-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 Non-nil means TAB in CPerl mode should always reindent the current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 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
793 `cperl-auto-newline'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 Non-nil means automatically newline before and after braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 and after colons and semicolons, inserted in Perl code. The following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 \\[cperl-electric-backspace] will remove the inserted whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 Insertion after colons requires both this variable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 `cperl-auto-newline-after-colon' set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 `cperl-auto-newline-after-colon'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 Non-nil means automatically newline even after colons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 Subject to `cperl-auto-newline' setting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 `cperl-indent-level'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 Indentation of Perl statements within surrounding block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 The surrounding block's indentation is the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 of the line on which the open-brace appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 `cperl-continued-statement-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 Extra indentation given to a substatement, such as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 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
809 `cperl-continued-brace-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 Extra indentation given to a brace that starts a substatement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 This is in addition to `cperl-continued-statement-offset'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 `cperl-brace-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 Extra indentation for line if it starts with an open brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 `cperl-brace-imaginary-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 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
816 this far to the right of the actual line indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 `cperl-label-offset'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Extra indentation for line that is a label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 `cperl-min-label-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 Minimal indentation for line that is a label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 Settings for K&R and BSD indentation styles are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 `cperl-indent-level' 5 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 `cperl-continued-statement-offset' 5 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 `cperl-brace-offset' -5 -8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 `cperl-label-offset' -5 -8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 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
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 Turning on CPerl mode calls the hooks in the variable `cperl-mode-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 with no args."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;;(if cperl-hairy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; (cperl-set 'cperl-font-lock cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; (cperl-set 'cperl-electric-lbrace-space cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;; (cperl-set 'cperl-electric-parens "{[(<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; (cperl-set 'cperl-electric-keywords cperl-hairy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;; (cperl-set 'cperl-electric-linefeed cperl-hairy)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (use-local-map cperl-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (if (cperl-val 'cperl-electric-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (local-set-key "\C-J" 'cperl-linefeed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (local-set-key "\C-C\C-J" 'newline-and-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (if (cperl-val 'cperl-info-on-command-no-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (if (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; don't clobber the backspace binding:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (local-set-key [(control h) f] 'cperl-info-on-current-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (local-set-key "\C-hf" 'cperl-info-on-current-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (if (cperl-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; don't clobber the backspace binding:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (local-set-key [(control c) (control h) f]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 'cperl-info-on-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (local-set-key "\C-c\C-hf" 'cperl-info-on-command))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (setq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (setq mode-name "CPerl")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (if (not cperl-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (let ((prev-a-c abbrevs-changed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (define-abbrev-table 'cperl-mode-abbrev-table '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ("if" "if" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ("elsif" "elsif" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ("while" "while" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ("until" "until" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ("unless" "unless" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ("else" "else" cperl-electric-else 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ("for" "for" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 ("foreach" "foreach" cperl-electric-keyword 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ("do" "do" cperl-electric-keyword 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (setq abbrevs-changed prev-a-c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (setq local-abbrev-table cperl-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (abbrev-mode (if (cperl-val 'cperl-electric-keywords) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (set-syntax-table cperl-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (setq paragraph-start (concat "^$\\|" page-delimiter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (setq paragraph-separate paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (make-local-variable 'paragraph-ignore-fill-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (setq paragraph-ignore-fill-prefix t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (make-local-variable 'indent-line-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (setq indent-line-function 'cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (setq require-final-newline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (setq comment-start "# ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (make-local-variable 'comment-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (setq comment-end "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (make-local-variable 'comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (setq comment-column cperl-comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (make-local-variable 'comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (setq comment-start-skip "#+ *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (make-local-variable 'defun-prompt-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (setq defun-prompt-regexp "^[ \t]*sub\\s +\\([^ \t\n{;]+\\)\\s *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (make-local-variable 'comment-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (setq comment-indent-function 'cperl-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (make-local-variable 'parse-sexp-ignore-comments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (setq parse-sexp-ignore-comments t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (make-local-variable 'indent-region-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (setq indent-region-function 'cperl-indent-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ;;(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
902 (make-local-variable 'imenu-create-index-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (setq imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (function imenu-example--create-perl-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (make-local-variable 'imenu-sort-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (setq imenu-sort-function nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (make-local-variable 'vc-header-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (setq vc-header-alist cperl-vc-header-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (setq font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (if (string< emacs-version "19.30")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 '(perl-font-lock-keywords-2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 '((perl-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 perl-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 perl-font-lock-keywords-2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (or (fboundp 'cperl-old-auto-fill-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (fset 'cperl-old-auto-fill-mode (symbol-function 'auto-fill-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (defun auto-fill-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (cperl-old-auto-fill-mode arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (and auto-fill-function (eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (setq auto-fill-function 'cperl-do-auto-fill)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (if (cperl-enable-font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (if (cperl-val 'cperl-font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (progn (or cperl-faces-init (cperl-init-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (font-lock-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (and (boundp 'msb-menu-cond)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (not cperl-msb-fixed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (cperl-msb-fix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (run-hooks 'cperl-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; After hooks since fontification will break this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (if cperl-pod-here-scan (cperl-find-pods-heres)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; Fix for msb.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (defvar cperl-msb-fixed nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (defun cperl-msb-fix ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;; Adds perl files to msb menu, supposes that msb is already loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (setq cperl-msb-fixed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (let* ((l (length msb-menu-cond))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (last (nth (1- l) msb-menu-cond))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (handle (1- (nth 1 last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (setcdr precdr (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 '(eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 "Perl Files (%d)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;; This is used by indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;; to decide how much to indent a comment in CPerl code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 ;; based on its context. Do fallback if comment is found wrong.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (defvar cperl-wrong-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (defun cperl-comment-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (let ((p (point)) (c (current-column)) was)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (if (looking-at "^#") 0 ; Existing comment at bol stays there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;; Wrong comment found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (setq was (cperl-to-comment-or-eol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (if (= (point) p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (max (1+ (current-column)) ; Else indent at comment column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (if was nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (insert comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (backward-char (length comment-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (setq cperl-wrong-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (indent-to comment-column 1) ; Indent minimum 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 c))))) ; except leave at least one space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;;;(defun cperl-comment-indent-fallback ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;;; "Is called if the standard comment-search procedure fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 ;;;Point is at start of real comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;;; (let ((c (current-column)) target cnt prevc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;;; (if (= c comment-column) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;;; (setq cnt (skip-chars-backward "[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;;; (setq target (max (1+ (setq prevc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ;;; (current-column))) ; Else indent at comment column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 ;;; comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 ;;; (if (= c comment-column) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ;;; (delete-backward-char cnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;;; (while (< prevc target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;;; (insert "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;;; (setq prevc (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;;; (if (> prevc target) (progn (delete-char -1) (setq prevc (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;;; (while (< prevc target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ;;; (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;;; (setq prevc (current-column)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (defun cperl-indent-for-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 "Substite for `indent-for-comment' in CPerl."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (let (cperl-wrong-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (if cperl-wrong-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (progn (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (forward-char (length comment-start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (defun cperl-electric-brace (arg &optional only-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 "Insert character and correct line's indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 If ONLY-BEFORE and `cperl-auto-newline', will insert newline before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 place (even in empty line), but not after. If after \")\" and the inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 char is \"{\", insert extra newline before only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 `cperl-extra-newline-before-brace'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (let (insertpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (if (and (not arg) ; No args, end (of empty line or auto)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (or (and (null only-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (bolp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (and (eq last-command-char ?\{) ; Do not insert newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; if after ")" and `cperl-extra-newline-before-brace'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;; is nil, do not insert extra newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (not cperl-extra-newline-before-brace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (eq (preceding-char) ?\))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (if cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (progn (cperl-indent-line) (newline) t) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (if cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (setq insertpos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (if (and cperl-auto-newline (null only-before))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (if insertpos (progn (goto-char insertpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (search-forward (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 1 last-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (setq insertpos (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (delete-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (if insertpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (goto-char insertpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (self-insert-command (prefix-numeric-value arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (self-insert-command (prefix-numeric-value arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (defun cperl-electric-lbrace (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 "Insert character, correct line's indentation, correct quoting by space."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (let (pos after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (cperl-auto-newline cperl-auto-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (other-end (if (and cperl-electric-parens-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (cperl-mark-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (> (mark) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (goto-char (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (and (cperl-val 'cperl-electric-lbrace-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (eq (preceding-char) ?$)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (skip-chars-backward "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (looking-at "\\(\\$\\$\\)*\\$\\([^\\$]\\|$\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (insert ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (if (cperl-after-expr-p nil "{};)") nil (setq cperl-auto-newline nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (cperl-electric-brace arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (and (cperl-val 'cperl-electric-parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (eq last-command-char ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (memq last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (append cperl-electric-parens-string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (or (if other-end (goto-char (marker-position other-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (setq last-command-char ?} pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (progn (cperl-electric-brace arg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (goto-char pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (defun cperl-electric-paren (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 "Insert a matching pair of parentheses."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (other-end (if (and cperl-electric-parens-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (cperl-mark-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (> (mark) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (goto-char (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (if (and (cperl-val 'cperl-electric-parens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (memq last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (append cperl-electric-parens-string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 ;;(not (save-excursion (search-backward "#" beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (if (eq last-command-char ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (cperl-after-expr-p nil "{};(,:=")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (if other-end (goto-char (marker-position other-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (insert (cdr (assoc last-command-char '((?{ .?})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (?[ . ?])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (?( . ?))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (?< . ?>)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (defun cperl-electric-keyword ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 "Insert a construction appropriate after a keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (dollar (eq (preceding-char) ?$)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (cperl-after-expr-p nil "{};:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (save-excursion (or (not (re-search-backward "^=" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (looking-at "=cut")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (and dollar (insert " $"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 ;;(insert " () {\n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (cperl-extra-newline-before-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (insert " ()\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (insert "{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (insert "\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (insert " () {\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (or (looking-at "[ \t]\\|$") (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (if dollar (progn (search-backward "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (search-backward ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (cperl-putback-char del-back-ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (defun cperl-electric-else ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 "Insert a construction appropriate after a keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (let ((beg (save-excursion (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (cperl-after-expr-p nil "{};:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 "[#\"'`]\\|\\<q\\(\\|[wqx]\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 beg t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (save-excursion (or (not (re-search-backward "^=" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (looking-at "=cut")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;;(insert " {\n\n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (cond
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 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (insert "{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (insert "\n\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (insert " {\n\n}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (or (looking-at "[ \t]\\|$") (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (cperl-putback-char del-back-ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (defun cperl-linefeed ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 "Go to end of line, open a new line and indent appropriately."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (let ((beg (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (end (save-excursion (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (pos (point)) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (if (and ; Check if we need to split:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 ; i.e., on a boundary and inside "{...}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (save-excursion (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (>= (point) pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (skip-chars-backward " \t" beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (looking-at "[;{]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (looking-at "[ \t]*}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (re-search-forward "\\=[ \t]*;" end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (eq (car (parse-partial-sexp pos end -1)) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (looking-at "[,; \t]*\\($\\|#\\)") ; Comma to allow anon subr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (setq start (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (<= start pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (or (memq (preceding-char) (append ";{" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (insert ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (or (looking-at "{[ \t]*$") ; If there is a statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 ; before, move it to separate line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (forward-line 1) ; We are on the target line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (or (looking-at "[ \t]*}[,; \t]*$") ; If there is a statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ; after, move it to separate line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (search-backward "}" beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (or (memq (preceding-char) (append ";{" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (insert ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (forward-line -1) ; We are on the line before target
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (end-of-line) ; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (if (not (looking-at "\n[ \t]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (cperl-indent-line)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (defun cperl-electric-semi (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 "Insert character and correct line's indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (if cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (cperl-electric-terminator arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (self-insert-command (prefix-numeric-value arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (defun cperl-electric-terminator (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 "Insert character and correct line's indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (let (insertpos (end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (auto (and cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (or (not (eq last-command-char ?:))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 cperl-auto-newline-after-colon))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (if (and (not arg) (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ;; Ignore in comment lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (= (following-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; Colon is special only after a label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;; So quickly rule out most other uses of colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 ;; and do no indentation for them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (and (eq last-command-char ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (progn (goto-char (- end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (not (looking-at ":"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (let ((pps (parse-partial-sexp (point) end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (if auto (setq insertpos (point-marker)))
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 (cperl-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (if auto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (cperl-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;; (if insertpos (progn (goto-char (marker-position insertpos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ;; (search-forward (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;; 1 last-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 ;; (setq insertpos (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 ;; (delete-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (if insertpos (goto-char (marker-position insertpos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (delete-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (if insertpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (goto-char insertpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (self-insert-command (prefix-numeric-value arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (self-insert-command (prefix-numeric-value arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (defun cperl-electric-backspace (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 "Backspace-untabify, or remove the whitespace inserted by an electric key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (if (and cperl-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (memq last-command '(cperl-electric-semi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 cperl-electric-terminator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 cperl-electric-lbrace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (memq (preceding-char) '(? ?\t ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (let (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (if (eq last-command 'cperl-electric-lbrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (skip-chars-forward " \t\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (delete-region (point) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (backward-delete-char-untabify arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (defun cperl-inside-parens-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (condition-case ()
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 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (progn (beginning-of-defun) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (= (char-after (or (scan-lists (point) -1 1) (point-min))) ?\()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (defun cperl-indent-command (&optional whole-exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 "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
1326 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
1327 Otherwise, indent the current line only if point is at the left margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 or in the line's indentation; otherwise insert a tab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 A numeric argument, regardless of its value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 means indent rigidly all the lines of the expression starting after point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 so that this line becomes properly indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 The relative indentation among the lines of the expression are preserved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (if whole-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 ;; If arg, always indent this line as Perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 ;; and shift remaining lines of expression the same amount.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (let ((shift-amt (cperl-indent-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (if cperl-tab-always-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (setq beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (if (> end beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (indent-code-rigidly beg end shift-amt "#")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (if (and (not cperl-tab-always-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (not (bolp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (insert-tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (cperl-indent-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (defun cperl-indent-line (&optional symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 "Indent current line as Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 Return the amount the indentation changed by."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (let (indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 beg shift-amt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (pos (- (point-max) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (setq indent (cperl-calculate-indent nil symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (cond ((eq indent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (setq indent (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;;((eq indent t) ; Never?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; (setq indent (cperl-calculate-indent-within-comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;;((looking-at "[ \t]*#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; (setq indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (if (listp indent) (setq indent (car indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (cond ((looking-at "[A-Za-z]+:[^:]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (and (> indent 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (setq indent (max cperl-min-label-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (+ indent cperl-label-offset)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 ((= (following-char) ?})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (setq indent (- indent cperl-indent-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ((memq (following-char) '(?\) ?\])) ; To line up with opening paren.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (setq indent (+ indent cperl-close-paren-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 ((= (following-char) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (setq indent (+ indent cperl-brace-offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (setq shift-amt (- indent (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (if (zerop shift-amt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (if (> (- (point-max) pos) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (goto-char (- (point-max) pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (indent-to indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 ;; If initial point was within line's indentation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 ;; position after the indentation. Else stay at same point in text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (if (> (- (point-max) pos) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (goto-char (- (point-max) pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 shift-amt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (defun cperl-after-label ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ;; Returns true if the point is after label. Does not do save-excursion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (and (eq (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (memq (char-syntax (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 '(?w ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (looking-at "[a-zA-Z_][a-zA-Z0-9_]*:"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (defun cperl-get-state (&optional parse-start start-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ;; returns list (START STATE DEPTH PRESTART), START is a good place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 ;; to start parsing, STATE is what is returned by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ;; `parse-partial-sexp'. DEPTH is true is we are immediately after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; end of block which contains START. PRESTART is the position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 ;; basing on which START was found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (let ((start-point (point)) depth state start prestart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (beginning-of-defun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (setq prestart (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (if start-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 ;; Try to go out, if sub is not on the outermost level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (while (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (setq start (point) parse-start start depth nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 state (parse-partial-sexp start start-point -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (if (> (car state) -1) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 ;; The current line could start like }}}, so the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 ;; corresponds to a different level than what we reached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (setq depth t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (beginning-of-line 2))) ; Go to the next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (if start (goto-char start))) ; Not at the start of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (if (< start start-point) (setq parse-start start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (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
1434 (list start state depth prestart))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (defun cperl-block-p () ; Do not C-M-q ! One string contains ";" !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; Positions is before ?\{. Checks whether it starts a block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;; No save-excursion!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (cperl-backward-to-noncomment (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;;(skip-chars-backward " \t\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (or (memq (preceding-char) (append ";){}$@&%\C-@" nil)) ; Or label! \C-@ at bobp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 ; Label may be mixed up with `$blah :'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (save-excursion (cperl-after-label))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (and (eq (char-syntax (preceding-char)) ?w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; Need take into account `bless', `return', `tr',...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (or (and (looking-at "\\sw+[ \t\n\f]*[{#]") ; Method call syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (not (looking-at "\\(bless\\|return\\|qw\\|tr\\|[smy]\\)\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (skip-chars-backward " \t\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (and (eq (char-syntax (preceding-char)) ?w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 "sub[ \t]+\\sw+[ \t\n\f]*[#{]")))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (defun cperl-calculate-indent (&optional parse-start symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 "Return appropriate indentation for current line as Perl code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 In usual case returns an integer: the column to indent to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 Returns nil if line starts inside a string, t if in a comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (if (memq (get-text-property (point) 'syntax-type) '(pod here-doc)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (let* ((indent-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (s-s (cperl-get-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (start (nth 0 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (state (nth 1 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (containing-sexp (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (char-after (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (start-indent (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (- (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (if (nth 2 s-s) cperl-indent-level 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 old-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 ;; (or parse-start (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; (setq parse-start (symbol-value symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ;; start-indent (nth 2 parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ;; parse-start (car parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 ;; (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 ;; (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 ;; (beginning-of-defun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ;; ;; Try to go out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 ;; (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ;; (setq start (point) parse-start start moved nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; state (parse-partial-sexp start indent-point -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ;; (if (> (car state) -1) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;; ;; The current line could start like }}}, so the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ;; ;; corresponds to a different level than what we reached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 ;; (setq moved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; (beginning-of-line 2))) ; Go to the next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;; (if start ; Not at the start of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; (setq start-indent (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ;; (if moved ; Should correct...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ;; (setq start-indent (- start-indent cperl-indent-level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; (setq start-indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; (if (< (point) indent-point) (setq parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; (or state (setq state (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;; (point) indent-point -1 nil start-state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 ;; (setq containing-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; (or (car (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;; (and (>= (nth 6 state) 0) old-containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;; old-containing-sexp nil start-state nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;;;; (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;;;; (setq parse-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;;;; (setq state (parse-partial-sexp (point) indent-point -1 nil start-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 ;;;; (setq containing-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;;;; (or (car (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;;;; (and (>= (nth 6 state) 0) old-containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ;;;; old-containing-sexp nil start-state nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 ;; (if symbol (set symbol (list indent-point state start-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ;; (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (cond ((or (nth 3 state) (nth 4 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 ;; return nil or t if should not change this line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (nth 4 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 ((null containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 ;; Line is at top level. May be data or function definition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ;; or may be function argument declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ;; Indent like the previous top level line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ;; unless that ends in a closeparen without semicolon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 ;; in which case this line is the first argument decl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (+ start-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (if (= (following-char) ?{) cperl-continued-brace-offset 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (cperl-backward-to-noncomment (or parse-start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;;(skip-chars-backward " \t\f\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 ;; Look at previous line that's at column 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; to determine whether we are in top-level decls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ;; or function's arg decls. Set basic-indent accordingly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Now add a little if this is a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (if (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (memq (preceding-char) (append " ;}" nil)) ; Was ?\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (memq char-after (append ")]}" nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 cperl-continued-statement-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ((/= (char-after containing-sexp) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 ;; line is expression, not statement:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ;; indent to just after the surrounding open,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ;; skip blanks if we do not close the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (or (memq char-after (append ")]}" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 ;; Containing-expr starts with \{. Check whether it is a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (not (cperl-block-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (or (eq char-after ?\})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (+ (current-column) ; Correct indentation of trailing ?\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (if (eq char-after ?\}) (+ cperl-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 cperl-close-paren-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 ;; Statement level. Is it a continuation or a new statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 ;; Find previous non-comment character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (cperl-backward-to-noncomment containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 ;; Back up over label lines, since they don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 ;; affect whether our line is a continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (while (or (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (and (eq (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (or;;(eq (char-after (- (point) 2)) ?\') ; ????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (memq (char-syntax (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 '(?w ?_)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (if (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ;; Will go to beginning of line, essentially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;; Will ignore embedded sexpr XXXX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (cperl-backward-to-start-of-continued-exp containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (cperl-backward-to-noncomment containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 ;; Now we get the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (if (not (memq (preceding-char) (append ", ;}{" '(nil)))) ; Was ?\,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 ;; This line is continuation of preceding line's statement;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;; indent `cperl-continued-statement-offset' more than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 ;; previous line of the statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (cperl-backward-to-start-of-continued-exp containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (+ (if (memq char-after (append "}])" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 0 ; Closing parenth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (if (eq char-after ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 cperl-continued-brace-offset 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ;; This line starts a new statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 ;; Is line first statement after an open-brace?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; If no, find that first statement and indent like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 ;; it. If the first statement begins with label, do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 ;; not belive when the indentation of the label is too
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 ;; small.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (setq old-indent (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (let ((colon-line-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (while (progn (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (looking-at "#\\|[a-zA-Z0-9_$]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 ;; Skip over comments and labels following openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (cond ((= (following-char) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; label:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (setq colon-line-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (search-forward ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 ;; The first following code counts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 ;; if it is before the line we want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (and (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (if (> colon-line-end (point)) ; After label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (if (> (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ;; Do not belive: `max' is involved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (+ old-indent cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (current-column)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 ;; If no previous statement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 ;; indent it relative to line brace is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ;; For open brace in column zero, don't let statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 ;; start there too. If cperl-indent-level is zero,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 ;; For open-braces not the first thing in a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;; add in cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ;; If first thing on a line: ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (+ (if (and (bolp) (zerop cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (+ cperl-brace-offset cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 cperl-indent-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;; Move back over whitespace before the openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 ;; If openbrace is not first nonwhite thing on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 ;; add the cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (if (bolp) 0 cperl-brace-imaginary-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 ;; If the openbrace is preceded by a parenthesized exp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 ;; move to the beginning of that;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 ;; possibly a different line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (if (eq (preceding-char) ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ;; In the case it starts a subroutine, indent with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; respect to `sub', not with respect to the the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 ;; first thing on the line, say in the case of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ;; anonymous sub in a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (if (and (eq (preceding-char) ?b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (looking-at "sub\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (setq old-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (nth 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (save-excursion (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (progn (goto-char (1+ old-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 ;; Get initial indentation of the line we are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 ;; If line starts with label, calculate label indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (if (> (current-indentation) cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (cperl-calculate-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (if (and parse-start (<= parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (current-indentation)))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (defvar cperl-indent-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 '((string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (comment nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (toplevel 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (toplevel-after-parenth 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (toplevel-continued 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (expression 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 "Alist of indentation rules for CPerl mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 The values mean:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 nil: do not indent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 number: add this amount of indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (defun cperl-where-am-i (&optional parse-start start-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 ;; Unfinished
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 "Return a list of lists ((TYPE POS)...) of good points before the point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 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
1696 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (let* ((start-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (s-s (cperl-get-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (start (nth 0 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (state (nth 1 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (prestart (nth 3 s-s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (containing-sexp (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (res (list (list 'parse-start start) (list 'parse-prestart prestart))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (cond ((nth 3 state) ; In string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (setq res (cons (list 'string nil (nth 3 state)) res))) ; What started string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 ((nth 4 state) ; In comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (setq res (cons '(comment) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 ((null containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ;; Line is at top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 ;; Indent like the previous top level line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; unless that ends in a closeparen without semicolon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 ;; in which case this line is the first argument decl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (cperl-backward-to-noncomment (or parse-start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ;;(skip-chars-backward " \t\f\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ((or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (memq (preceding-char) (append ";}" nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (setq res (cons (list 'toplevel start) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ((eq (preceding-char) ?\) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (setq res (cons (list 'toplevel-after-parenth start) res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (setq res (cons (list 'toplevel-continued start) res)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 ((/= (char-after containing-sexp) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 ;; line is expression, not statement:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 ;; indent to just after the surrounding open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 ;; skip blanks if we do not close the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (setq res (cons (list 'expression-blanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (or (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (cons (list 'expression containing-sexp) res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ;; Containing-expr starts with \{. Check whether it is a hash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (not (cperl-block-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (setq res (cons (list 'expression-blanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (or (looking-at "[ \t]*\\(#\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (cons (list 'expression containing-sexp) res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; Statement level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (setq res (cons (list 'in-block containing-sexp) res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ;; Is it a continuation or a new statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; Find previous non-comment character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (cperl-backward-to-noncomment containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ;; Back up over label lines, since they don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 ;; affect whether our line is a continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ;; Back up comma-delimited lines too ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (while (or (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (save-excursion (cperl-after-label)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (if (eq (preceding-char) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;; Will go to beginning of line, essentially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 ;; Will ignore embedded sexpr XXXX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (cperl-backward-to-start-of-continued-exp containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (cperl-backward-to-noncomment containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ;; Now we get the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (if (not (memq (preceding-char) (append ";}{" '(nil)))) ; Was ?\,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ;; This line is continuation of preceding line's statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (list (list 'statement-continued containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ;; This line starts a new statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 ;; Is line first statement after an open-brace?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; If no, find that first statement and indent like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; it. If the first statement begins with label, do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ;; not belive when the indentation of the label is too
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ;; small.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (let ((colon-line-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (while (progn (skip-chars-forward " \t\n" start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (and (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 "#\\|[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ;; Skip over comments and labels following openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (cond ((= (following-char) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;;(forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; label:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (setq colon-line-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (search-forward ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 ;; Now at the point, after label, or at start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 ;; of first statement in the block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (and (< (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (if (> colon-line-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 ;; Before statement after label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (if (> (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (list (list 'label-in-block (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ;; Do not belive: `max' is involved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (list 'label-in-block-min-indent (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ;; Before statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (list 'statement-in-block (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ;; If no previous statement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ;; indent it relative to line brace is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 ;; For open brace in column zero, don't let statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ;; start there too. If cperl-indent-level is zero,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 ;; For open-braces not the first thing in a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ;; add in cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; If first thing on a line: ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (+ (if (and (bolp) (zerop cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (+ cperl-brace-offset cperl-continued-statement-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 cperl-indent-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; Move back over whitespace before the openbrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 ;; If openbrace is not first nonwhite thing on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 ;; add the cperl-brace-imaginary-offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (if (bolp) 0 cperl-brace-imaginary-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; If the openbrace is preceded by a parenthesized exp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;; move to the beginning of that;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 ;; possibly a different line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (if (eq (preceding-char) ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 ;; Get initial indentation of the line we are on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 ;; If line starts with label, calculate label indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_]*:[^:]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (if (> (current-indentation) cperl-min-label-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (- (current-indentation) cperl-label-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (cperl-calculate-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (if (and parse-start (<= parse-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 parse-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (current-indentation))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 res)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (defun cperl-calculate-indent-within-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 "Return the indentation amount for line, assuming that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 the current line is to be regarded as part of a block comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (let (end star-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (and (= (following-char) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (setq end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (defun cperl-to-comment-or-eol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 "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
1859 Returns true if comment is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (let (state stop-in cpoint (lim (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (if (re-search-forward "\\=[ \t]*\\(#\\|$\\)" lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (if (eq (preceding-char) ?\#) (progn (backward-char 1) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (while (not stop-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (setq state (parse-partial-sexp (point) lim nil nil nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ; stop at comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 ;; If fails (beginning-of-line inside sexp), then contains not-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ;; Do simplified processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 ;;(if (re-search-forward "[^$]#" lim 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ;; (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 ;; (skip-chars-backward " \t\n\f" lim))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ;; (goto-char lim)) ; No `#' at all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 ;;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (if (nth 4 state) ; After `#';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 ; (nth 2 state) can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 ; beginning of m,s,qq and so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ; on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (if (nth 2 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (setq cpoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (goto-char (nth 2 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 ((looking-at "\\(s\\|tr\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 lim 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (setq stop-in t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 ((looking-at "\\(m\\|q\\([qxw]\\)?\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 lim 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (setq stop-in t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (t ; It was fair comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (setq stop-in t) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (goto-char (1- cpoint)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (setq stop-in t) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (setq stop-in t)) ; Finish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (nth 4 state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (defun cperl-find-pods-heres (&optional min max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 "Scans the buffer for POD sections and here-documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 If `cperl-pod-here-fontify' is not-nil after evaluation, will fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 the sections using `cperl-pod-head-face', `cperl-pod-face',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 `cperl-here-face'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (or min (setq min (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (or max (setq max (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (let (face head-face here-face b e bb tag err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (cperl-pod-here-fontify (eval cperl-pod-here-fontify))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (case-fold-search nil) (inhibit-read-only t) (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (modified (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (message "Scanning for pods and here-docs...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (if cperl-pod-here-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (setq face (eval cperl-pod-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 head-face (eval cperl-pod-head-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 here-face (eval cperl-here-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (remove-text-properties min max '(syntax-type t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 ;; Need to remove face as well...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (goto-char min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (while (re-search-forward "\\(\\`\n?\\|\n\n\\)=" max t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (if (looking-at "\n*cut\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (message "=cut is not preceeded by a pod section")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (setq err (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (setq b (point) bb b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (or (re-search-forward "\n\n=cut\\>" max 'toend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (message "Cannot find the end of a pod section"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (beginning-of-line 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (setq e (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (put-text-property b e 'in-pod t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (goto-char b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (while (re-search-forward "\n\n[ \t]" e t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (put-text-property b (point) 'syntax-type 'pod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (put-text-property (max (point-min) (1- b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (point) cperl-do-not-fontify t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (if cperl-pod-here-fontify (put-text-property b (point) 'face face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (re-search-forward "\n\n[^ \t\f]" e 'toend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (setq b (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (put-text-property (point) e 'syntax-type 'pod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (put-text-property (max (point-min) (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 e cperl-do-not-fontify t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (if cperl-pod-here-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (progn (put-text-property (point) e 'face face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (goto-char bb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 ;; One paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 "\n\n=[a-zA-Z0-9]+\\>[ \t]*\\(\\(\n?[^\n]\\)+\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 e 'toend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (put-text-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (match-beginning 1) (match-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 'face head-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (goto-char e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (goto-char min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 "<<\\(\\([\"'`]\\)?\\)\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 max t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (setq tag (buffer-substring (match-beginning 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (if cperl-pod-here-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (put-text-property (match-beginning 3) (match-end 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 'face font-lock-reference-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (forward-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (setq b (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (and (re-search-forward (concat "^" tag "$") max 'toend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (if cperl-pod-here-fontify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (put-text-property (match-beginning 0) (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 'face font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (put-text-property (max (point-min) (1- b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (min (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (1+ (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 cperl-do-not-fontify t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (put-text-property b (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 'face here-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (put-text-property b (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 'syntax-type 'here-doc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (if err (goto-char err)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (message "Scan for pods and here-docs completed.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (not modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (set-buffer-modified-p nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (defun cperl-backward-to-noncomment (lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 ;; Stops at lim or after non-whitespace that is not in comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (let (stop p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (while (and (not stop) (> (point) (or lim 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (skip-chars-backward " \t\n\f" lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (if (< p (point)) (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (setq stop t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (defun cperl-after-expr-p (&optional lim chars test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 "Returns true if the position is good for start of expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 TEST is the expression to evaluate at the found position. If absent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 CHARS is a string that contains good characters to have before us."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (let (stop p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (while (and (not stop) (> (point) (or lim 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (skip-chars-backward " \t\n\f" lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (if (looking-at "^[ \t]*\\(#\\|$\\)") nil ; Only comment, skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 ;; Else: last iteration (What to do with labels?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (if (< p (point)) (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (setq stop t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (if test (eval test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (memq (following-char) (append (or chars "{};") nil))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (defun cperl-backward-to-start-of-continued-exp (lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (if (memq (preceding-char) (append ")]}\"'`" nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (if (<= (point) lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (goto-char (1+ lim)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (defvar innerloop-done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (defvar last-depth nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (defun cperl-indent-exp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 "Simple variant of indentation of continued-sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 Should be slow. Will not indent comment if it starts at `comment-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 or looks like continuation of the comment on the previous line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (let ((tmp-end (progn (end-of-line) (point))) top done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (while (null done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (setq top (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (while (= (nth 0 (parse-partial-sexp (point) tmp-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 -1)) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (setq top (point))) ; Get the outermost parenths in line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (goto-char top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (while (< (point) tmp-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (parse-partial-sexp (point) tmp-end nil t) ; To start-sexp or eol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (or (eolp) (forward-sexp 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (if (> (point) tmp-end) (progn (end-of-line) (setq tmp-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (setq done t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (goto-char tmp-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (setq tmp-end (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (cperl-indent-region (point) tmp-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (defun cperl-indent-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 "Simple variant of indentation of region in CPerl mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 Should be slow. Will not indent comment if it starts at `comment-indent'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 or looks like continuation of the comment on the previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 Indents all the lines whose first character is between START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 inclusive."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (let (st comm indent-info old-comm-indent new-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (pm 0) (imenu-scanning-message "Indenting... (%3d%%)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (setq old-comm-indent (and (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 new-comm-indent old-comm-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (or (bolp) (beginning-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (or (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (message "Indenting... For feedback load `imenu'..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (while (and (<= (point) end) (not (eobp))) ; bol to check start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (and (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (imenu-progress-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 pm (/ (* 100 (- (point) start)) (- end start -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (setq st (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 indent-info nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 ) ; Believe indentation of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (if (and (setq comm (looking-at "[ \t]*#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (or (eq (current-indentation) (or old-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (setq old-comm-indent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (if (and old-comm-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (= (current-indentation) old-comm-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (let ((comment-column new-comm-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (indent-for-comment)))
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 (cperl-indent-line 'indent-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (or comm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (if (setq old-comm-indent (and (cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (progn (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (skip-chars-backward "#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (setq new-comm-indent (current-column))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (beginning-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (if (fboundp 'imenu-progress-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (imenu-progress-message pm 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (message nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (defun cperl-slash-is-regexp (&optional pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (goto-char (if pos pos (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (not (memq (get-text-property (point) 'face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 '(font-lock-string-face font-lock-comment-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (cperl-after-expr-p nil nil '
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (or (looking-at "[^]a-zA-Z0-9_)}]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (eq (get-text-property (point) 'face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 'font-lock-keyword-face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 ;; Stolen from lisp-mode with a lot of improvements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (defun cperl-fill-paragraph (&optional justify iteration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 "Like \\[fill-paragraph], but handle CPerl comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 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
2130 block of it that point is in, preserving the comment's initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 indentation and initial hashes. Behaves usually outside of comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ;; Non-nil if the current line contains a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 has-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 ;; If has-comment, the appropriate fill-prefix for the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 comment-fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 ;; Line that contains code and comment (or nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 c spaces len dc (comment-column comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 ;; Figure out what kind of comment we are looking at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 ;; A line with nothing but a comment on it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 ((looking-at "[ \t]*#[# \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (setq has-comment t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 comment-fill-prefix (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 ;; A line with some code, followed by a comment? Remember that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 ;; semi which starts the comment shouldn't be part of a string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 ;; character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 ((cperl-to-comment-or-eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (setq has-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (looking-at "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (setq start (point) c (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 comment-fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (concat (make-string (current-column) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (buffer-substring (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 spaces (progn (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (buffer-substring (point) start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 dc (- c (current-column)) len (- start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 start (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (delete-char len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (insert (make-string dc ?-)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (if (not has-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (fill-paragraph justify) ; Do the usual thing outside of comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 ;; Narrow to include only the comment, and then fill the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 ;; Find the first line we should include in the region to fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (if start (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (while (and (zerop (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ;; We may have gone to far. Go forward again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (or (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 ;; Find the beginning of the first line past the region to fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (while (progn (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 ;; Remove existing hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (while (progn (forward-line 1) (< (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (and (looking-at "#+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (delete-char (- (match-end 0) (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 ;; Lines with only hashes on them can be paragraph boundaries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (paragraph-separate (concat paragraph-start "\\|^[ \t#]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (fill-prefix comment-fill-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (fill-paragraph justify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (if (and start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (if (> dc 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (progn (delete-char dc) (insert spaces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (if (or (= (current-column) c) iteration) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (setq comment-column c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (indent-for-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 ;; Repeat once more, flagging as iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 (cperl-fill-paragraph justify t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (defun cperl-do-auto-fill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 ;; Break out if the line is short enough
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (if (> (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 (let ((c (save-excursion (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (cperl-to-comment-or-eol) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (s (memq (following-char) '(?\ ?\t))) marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (if (>= c (point)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (setq marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (cperl-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (goto-char marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 ;; Is not enough, sometimes marker is a start of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 (if (bolp) (progn (re-search-forward "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 (goto-char (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ;; Following space could have gone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (if (or (not s) (memq (following-char) '(?\ ?\t))) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ;; Previous space could have gone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (or (memq (preceding-char) '(?\ ?\t)) (insert " "))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (defvar imenu-example--function-name-regexp-perl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 "^\\([ \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
2236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (defun imenu-example--create-perl-index (&optional regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 packages ends-ranges p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (prev-pos 0) char fchar index index1 name (end-range 0) package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (imenu-progress-message prev-pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 ;; Search for the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (or regexp imenu-example--function-name-regexp-perl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (imenu-progress-message prev-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ;;(backward-up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ((match-beginning 2) ; package or sub
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (goto-char (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (setq fchar (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (setq char (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 (while (and ends-ranges (>= p (car ends-ranges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ;; delete obsolete entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (setq ends-ranges (cdr ends-ranges) packages (cdr packages)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (setq package (or (car packages) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 end-range (or (car ends-ranges) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (if (eq fchar ?p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (setq name (buffer-substring (match-beginning 3) (match-end 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 package (concat name "::")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 name (concat "package " name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 end-range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (parse-partial-sexp (point) (point-max) -1) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ends-ranges (cons end-range ends-ranges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 packages (cons package packages))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ;; Skip this function name if it is a prototype declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 (if (and (eq fchar ?s) (eq char ?\;)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (if (eq fchar ?p) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (setq name (buffer-substring (match-beginning 3) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 (if (or (> p end-range) (string-match "[:']" name)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 (setq name (concat package name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 (setq index (imenu-example--name-and-position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (setcar index name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (if (eq fchar ?p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 (push index index-pack-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (push index index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 (push index index-unsorted-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (t ; Pod section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ;; (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 (setq index (imenu-example--name-and-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 name (buffer-substring (match-beginning 5) (match-end 5)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (if (eq (char-after (match-beginning 4)) ?2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 (setq name (concat " " name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (setcar index name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 (setq index1 (cons (concat "=" name) (cdr index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 (push index index-pod-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 (push index1 index-unsorted-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (imenu-progress-message prev-pos 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (setq index-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 (if (default-value 'imenu-sort-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 (sort index-alist (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (nreverse index-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 (and index-pod-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (push (cons (imenu-create-submenu-name "+POD headers+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (nreverse index-pod-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (and index-pack-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (push (cons (imenu-create-submenu-name "+Packages+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (nreverse index-pack-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (and (or index-pack-alist index-pod-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 (default-value 'imenu-sort-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 index-unsorted-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (push (cons (imenu-create-submenu-name "+Unsorted List+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (nreverse index-unsorted-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (defvar cperl-compilation-error-regexp-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 ;; 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
2321 '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 2 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 "Alist that specifies how to match errors in perl output.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (if (fboundp 'eval-after-load)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (eval-after-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 "mode-compile"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 '(setq perl-compilation-error-regexp-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 cperl-compilation-error-regexp-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (defvar cperl-faces-init nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (defun cperl-windowed-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 "Initialization under windowed version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (add-hook 'font-lock-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (if (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (eq major-mode 'cperl-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (or cperl-faces-init (cperl-init-faces))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (defvar perl-font-lock-keywords-1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 "Additional expressions to highlight in Perl mode. Minimal set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 (defvar perl-font-lock-keywords nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 "Additional expressions to highlight in Perl mode. Default set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 (defvar perl-font-lock-keywords-2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 "Additional expressions to highlight in Perl mode. Maximal set")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (defun cperl-init-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (require 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (and (fboundp 'font-lock-fontify-anchored-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (message "You have an obsolete package `font-lock-extra'. Install `choose-color'."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (let (t-font-lock-keywords t-font-lock-keywords-1 font-lock-anchored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;;(defvar cperl-font-lock-enhanced nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;; "Set to be non-nil if font-lock allows active highlights.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (if (fboundp 'font-lock-fontify-anchored-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (setq font-lock-anchored t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 "\\(^\\|[^$@%&\\]\\)\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 '("if" "until" "while" "elsif" "else" "unless" "for"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 "foreach" "continue" "exit" "die" "last" "goto" "next"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 "redo" "return" "local" "exec" "sub" "do" "dump" "use"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 "require" "package" "eval" "my" "BEGIN" "END")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 "\\|") ; Flow control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 "\\)\\>") 2) ; was "\\)[ \n\t;():,\|&]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 ; In what follows we use `type' style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 ; for overwritable buildins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 "\\(^\\|[^$@%&\\]\\)\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 ;; "CORE" "__FILE__" "__LINE__" "abs" "accept" "alarm" "and" "atan2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 ;; "bind" "binmode" "bless" "caller" "chdir" "chmod" "chown" "chr"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 ;; "chroot" "close" "closedir" "cmp" "connect" "continue" "cos"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 ;; "crypt" "dbmclose" "dbmopen" "die" "dump" "endgrent" "endhostent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 ;; "endnetent" "endprotoent" "endpwent" "endservent" "eof" "eq" "exec"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ;; "exit" "exp" "fcntl" "fileno" "flock" "fork" "formline" "ge" "getc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 ;; "getgrent" "getgrgid" "getgrnam" "gethostbyaddr" "gethostbyname"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 ;; "gethostent" "getlogin" "getnetbyaddr" "getnetbyname" "getnetent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 ;; "getpeername" "getpgrp" "getppid" "getpriority" "getprotobyname"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ;; "getprotobynumber" "getprotoent" "getpwent" "getpwnam" "getpwuid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 ;; "getservbyname" "getservbyport" "getservent" "getsockname"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 ;; "getsockopt" "glob" "gmtime" "gt" "hex" "index" "int" "ioctl"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;; "join" "kill" "lc" "lcfirst" "le" "length" "link" "listen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 ;; "localtime" "log" "lstat" "lt" "mkdir" "msgctl" "msgget" "msgrcv"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 ;; "msgsnd" "ne" "not" "oct" "open" "opendir" "or" "ord" "pack" "pipe"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 ;; "quotemeta" "rand" "read" "readdir" "readline" "readlink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 ;; "readpipe" "recv" "ref" "rename" "require" "reset" "reverse"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 ;; "rewinddir" "rindex" "rmdir" "seek" "seekdir" "select" "semctl"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ;; "semget" "semop" "send" "setgrent" "sethostent" "setnetent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 ;; "setpgrp" "setpriority" "setprotoent" "setpwent" "setservent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 ;; "setsockopt" "shmctl" "shmget" "shmread" "shmwrite" "shutdown"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 ;; "sin" "sleep" "socket" "socketpair" "sprintf" "sqrt" "srand" "stat"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 ;; "substr" "symlink" "syscall" "sysread" "system" "syswrite" "tell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 ;; "telldir" "time" "times" "truncate" "uc" "ucfirst" "umask" "unlink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 ;; "unpack" "utime" "values" "vec" "wait" "waitpid" "wantarray" "warn"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 ;; "write" "x" "xor"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 "a\\(bs\\|ccept\\|tan2\\|larm\\|nd\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 "b\\(in\\(d\\|mode\\)\\|less\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 "c\\(h\\(r\\(\\|oot\\)\\|dir\\|mod\\|own\\)\\|aller\\|rypt\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 "lose\\(\\|dir\\)\\|mp\\|o\\(s\\|n\\(tinue\\|nect\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 "CORE\\|d\\(ie\\|bm\\(close\\|open\\)\\|ump\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 "e\\(x\\(p\\|it\\|ec\\)\\|q\\|nd\\(p\\(rotoent\\|went\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 "hostent\\|servent\\|netent\\|grent\\)\\|of\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 "f\\(ileno\\|cntl\\|lock\\|or\\(k\\|mline\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 "g\\(t\\|lob\\|mtime\\|e\\(\\|t\\(p\\(pid\\|r\\(iority\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 "oto\\(byn\\(ame\\|umber\\)\\|ent\\)\\)\\|eername\\|w"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 "\\(uid\\|ent\\|nam\\)\\|grp\\)\\|host\\(by\\(addr\\|name\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 "ent\\)\\|s\\(erv\\(by\\(port\\|name\\)\\|ent\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 "ock\\(name\\|opt\\)\\)\\|c\\|login\\|net\\(by\\(addr\\|name\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 "ent\\)\\|gr\\(ent\\|nam\\|gid\\)\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 "hex\\|i\\(n\\(t\\|dex\\)\\|octl\\)\\|join\\|kill\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 "l\\(i\\(sten\\|nk\\)\\|stat\\|c\\(\\|first\\)\\|t\\|e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 "\\(\\|ngth\\)\\|o\\(caltime\\|g\\)\\)\\|m\\(sg\\(rcv\\|snd\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 "ctl\\|get\\)\\|kdir\\)\\|n\\(e\\|ot\\)\\|o\\(pen\\(\\|dir\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 "r\\(\\|d\\)\\|ct\\)\\|p\\(ipe\\|ack\\)\\|quotemeta\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 "r\\(index\\|and\\|mdir\\|e\\(quire\\|ad\\(pipe\\|\\|lin"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 "\\(k\\|e\\)\\|dir\\)\\|set\\|cv\\|verse\\|f\\|winddir\\|name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 "\\)\\)\\|s\\(printf\\|qrt\\|rand\\|tat\\|ubstr\\|e\\(t\\(p\\(r"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 "\\(iority\\|otoent\\)\\|went\\|grp\\)\\|hostent\\|s\\(ervent\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 "ockopt\\)\\|netent\\|grent\\)\\|ek\\(\\|dir\\)\\|lect\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 "m\\(ctl\\|op\\|get\\)\\|nd\\)\\|h\\(utdown\\|m\\(read\\|ctl\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 "write\\|get\\)\\)\\|y\\(s\\(read\\|call\\|tem\\|write\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 "mlink\\)\\|in\\|leep\\|ocket\\(pair\\|\\)\\)\\|t\\(runcate\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 "ell\\(\\|dir\\)\\|ime\\(\\|s\\)\\)\\|u\\(c\\(\\|first\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 "time\\|mask\\|n\\(pack\\|link\\)\\)\\|v\\(alues\\|ec\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 "w\\(a\\(rn\\|it\\(pid\\|\\)\\|ntarray\\)\\|rite\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 "x\\(\\|or\\)\\|__\\(FILE__\\|LINE__\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 "\\)\\>") 2 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 ;; In what follows we use `other' style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 ;; for nonoverwritable buildins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 ;; Somehow 's', 'm' are not autogenerated???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 "\\(^\\|[^$@%&\\]\\)\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 ;; "AUTOLOAD" "BEGIN" "DESTROY" "END" "__END__" "chomp" "chop"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 ;; "defined" "delete" "do" "each" "else" "elsif" "eval" "exists" "for"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 ;; "foreach" "format" "goto" "grep" "if" "keys" "last" "local" "map"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 ;; "my" "next" "no" "package" "pop" "pos" "print" "printf" "push" "q"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 ;; "qq" "qw" "qx" "redo" "return" "scalar" "shift" "sort" "splice"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 ;; "split" "study" "sub" "tie" "tr" "undef" "unless" "unshift" "untie"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 ;; "until" "use" "while" "y"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 "AUTOLOAD\\|BEGIN\\|cho\\(p\\|mp\\)\\|d\\(e\\(fined\\|lete\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 "o\\)\\|DESTROY\\|e\\(ach\\|val\\|xists\\|ls\\(e\\|if\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 "END\\|for\\(\\|each\\|mat\\)\\|g\\(rep\\|oto\\)\\|if\\|keys\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 "l\\(ast\\|ocal\\)\\|m\\(ap\\|y\\)\\|n\\(ext\\|o\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 "p\\(ackage\\|rint\\(\\|f\\)\\|ush\\|o\\(p\\|s\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 "q\\(\\|q\\|w\\|x\\)\\|re\\(turn\\|do\\)\\|s\\(pli\\(ce\\|t\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 "calar\\|tudy\\|ub\\|hift\\|ort\\)\\|t\\(r\\|ie\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 "u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 "while\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 "\\|[sm]" ; Added manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 "\\)\\>") 2 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 ;; (mapconcat 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 ;; "#include" "#define" "#undef")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 ;; "\\|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 '("-[rwxoRWXOezsfdlpSbctugkTBMAC]\\>\\([ \t]+_\\>\\)?" 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 font-lock-function-name-face) ; Not very good, triggers at "[a-z]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 '("\\<sub[ \t]+\\([^ \t{;]+\\)[ \t]*[{\n]" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 '("\\<\\(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
2474 2 font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (cond ((featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (2 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (0 '(restart 2 t)))) ; To highlight $a{bc}{ef}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (font-lock-anchored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (2 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 (1 font-lock-string-face t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (t '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 2 font-lock-string-face t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 '("[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 '("^[ \t]*\\([a-zA-Z0-9_]+[ \t]*:\\)[ \t]*\\($\\|{\\|\\<\\(until\\|while\\|for\\(each\\)?\\|do\\)\\>\\)" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 font-lock-reference-face) ; labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 '("\\<\\(continue\\|next\\|last\\|redo\\|goto\\)\\>[ \t]+\\([a-zA-Z0-9_:]+\\)" ; labels as targets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 2 font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (cond ((featurep 'font-lock-extra)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (3 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (4 '(another 4 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (1 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (2 '(restart 2 nil) nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 nil t))) ; local variables, multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (font-lock-anchored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (3 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (1 font-lock-variable-name-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (t '("^[ \t]*\\(my\\|local\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 3 font-lock-variable-name-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 '("\\<for\\(each\\)?[ \t]*\\(\\$[a-zA-Z_][a-zA-Z_0-9]*\\)[ \t]*("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 2 font-lock-variable-name-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 t-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (and (fboundp 'turn-on-font-lock) ; Check for newer font-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (not (cperl-xemacs-p)) ; not yet as of XEmacs 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 '(("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (if (= (- (match-end 2) (match-beginning 2)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (if (eq (char-after (match-beginning 3)) ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 font-lock-emphasized-face) ; arrays and hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 font-lock-variable-name-face) ; Just to put something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ("\\(\\([@%]\\|\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (if (eq (char-after (match-beginning 2)) ?%)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 t) ; arrays and hashes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 ;;; Too much noise from \s* @s[ and friends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;;(3 font-lock-function-name-face t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 ;;(4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 ;; (if (cperl-slash-is-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;; font-lock-function-name-face 'default) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (setq perl-font-lock-keywords-1 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 perl-font-lock-keywords perl-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 perl-font-lock-keywords-2 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 t-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 t-font-lock-keywords-1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (if (fboundp 'ps-print-buffer) (cperl-ps-print-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (if (or (featurep 'choose-color) (featurep 'font-lock-extra))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (font-lock-require-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ;; Color-light Color-dark Gray-light Gray-dark Mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (list 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 ["Firebrick" "OrangeRed" "DimGray" "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (list 'font-lock-string-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 ["RosyBrown" "LightSalmon" "Gray50" "LightGray"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 (list 'font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 ["Purple" "LightSteelBlue" "DimGray" "Gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (list 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 "Blue" "LightSkyBlue" "Gray50" "LightGray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (cdr (assq 'background-color ; if mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (frame-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 nil nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (cdr (assq 'foreground-color ; if mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 (frame-parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (list 'font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 ["DarkGoldenrod" "LightGoldenrod" "DimGray" "Gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 (list 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 ["DarkOliveGreen" "PaleGreen" "DimGray" "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (list 'font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ["CadetBlue" "Aquamarine" "Gray50" "LightGray"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (list 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 ["chartreuse3" ("orchid1" "orange")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 [nil nil "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 [nil nil nil t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 [nil nil t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 [nil nil t t t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (list 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 ["blue" "yellow" nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 ["lightyellow2" ("navy" "os2blue" "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (list 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 ["red" "red" nil "Gray80"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 ["lightyellow2" ("navy" "os2blue" "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 "gray90"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 (defvar cperl-guessed-background nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 "Display characteristics as guessed by cperl.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (or (fboundp 'x-color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (defalias 'x-color-defined-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (cond ((fboundp 'color-defined-p) 'color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 ;; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 ((fboundp 'valid-color-name-p) 'valid-color-name-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 ;; XEmacs 19.11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (t 'x-valid-color-name-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (defvar font-lock-reference-face 'font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (defvar font-lock-variable-name-face 'font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (or (boundp 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 "Face to use for data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (or (boundp 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 (defconst font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 "Face to use for data types from another group.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 (if (not (cperl-xemacs-p)) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (or (boundp 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 (defconst font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 'font-lock-comment-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 "Face to use for comments.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 (or (boundp 'font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (defconst font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 'font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 "Face to use for keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (or (boundp 'font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 (defconst font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 "Face to use for function names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 ;;(if (featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 (if (face-equal font-lock-type-face font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 "Face to use for basic data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 ;;; (if (fboundp 'eval-after-load)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 ;;; (eval-after-load "font-lock"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 ;;; '(if (face-equal font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 ;;; font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 ;;; (defconst font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 ;;; 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 ;;; "Face to use for basic data types.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 ;;; ))) ; This does not work :-( Why?!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 ;;; ; Workaround: added to font-lock-m-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 ;;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (or (boundp 'font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (defconst font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 "Face to use for another type of emphasizing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 (or (boundp 'font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 (defconst font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 "Face to use for emphasizing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 ;; Here we try to guess background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 (let ((background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 (if (boundp 'font-lock-background-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 font-lock-background-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 'light))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 (face-list (and (fboundp 'face-list) (face-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 is-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 (fset 'is-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 (cond ((fboundp 'find-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 (symbol-function 'find-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 (face-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (function (lambda (face) (member face face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 (function (lambda (face) (boundp face))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 (defvar cperl-guessed-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 (if (and (boundp 'font-lock-display-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 (eq font-lock-display-type 'grayscale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 'gray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 background)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 "Background as guessed by CPerl mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 (if (is-face 'font-lock-type-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 (copy-face 'default 'font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 (set-face-foreground 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (if (x-color-defined-p "seagreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 "seagreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 "sea green")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (set-face-foreground 'font-lock-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (if (x-color-defined-p "os2pink")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 "os2pink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 "pink")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 (set-face-background 'font-lock-type-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 (if (is-face 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (copy-face 'font-lock-type-face 'font-lock-other-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (set-face-foreground 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 (if (x-color-defined-p "chartreuse3")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 "chartreuse3"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 "chartreuse")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (set-face-foreground 'font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 (if (x-color-defined-p "orchid1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 "orchid1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 "orange")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (if (is-face 'font-lock-other-emphasized-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (copy-face 'bold-italic 'font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (set-face-background 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 (if (x-color-defined-p "lightyellow2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 "lightyellow2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 (if (x-color-defined-p "lightyellow")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 "lightyellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 "light yellow"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (set-face-background 'font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (if (x-color-defined-p "navy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 (if (x-color-defined-p "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 "darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 "dark green"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (t (set-face-background 'font-lock-other-emphasized-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 (if (is-face 'font-lock-emphasized-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (copy-face 'bold 'font-lock-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 ((eq background 'light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (set-face-background 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 (if (x-color-defined-p "lightyellow2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 "lightyellow2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 "lightyellow")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 ((eq background 'dark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 (set-face-background 'font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (if (x-color-defined-p "navy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 (if (x-color-defined-p "darkgreen")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 "darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 "dark green"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 (t (set-face-background 'font-lock-emphasized-face "gray90"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (if (is-face 'font-lock-variable-name-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 (copy-face 'italic 'font-lock-variable-name-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 (if (is-face 'font-lock-reference-face) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 (copy-face 'italic 'font-lock-reference-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 (setq cperl-faces-init t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 (defun cperl-ps-print-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 "Initialization of `ps-print' components for faces used in CPerl."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 ;; Guard against old versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 (defvar ps-underlined-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 (defvar ps-bold-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 (defvar ps-italic-faces nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 (setq ps-bold-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 (append '(font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 font-lock-keyword-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 font-lock-variable-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 ps-bold-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 (setq ps-italic-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (append '(font-lock-other-type-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 font-lock-reference-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 font-lock-other-emphasized-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 ps-italic-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (setq ps-underlined-faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 (append '(font-lock-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 font-lock-other-emphasized-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 font-lock-other-type-face font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 ps-underlined-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 (cons 'font-lock-type-face ps-underlined-faces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (if (cperl-enable-font-lock) (cperl-windowed-init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 (defun cperl-set-style (style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 "Set CPerl-mode variables to use one of several different indentation styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 The arguments are a string representing the desired style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 Available styles are GNU, K&R, BSD and Whitesmith."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (let ((list (mapcar (function (lambda (elt) (list (car elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 c-style-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 (list (completing-read "Enter style: " list nil 'insist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 (let ((style (cdr (assoc style c-style-alist))) setting str sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 (while style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 (setq setting (car style) style (cdr style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 (setq str (symbol-name (car setting)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (and (string-match "^c-" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 (setq str (concat "cperl-" (substring str 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 (setq sym (intern-soft str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 (set sym (cdr setting))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 (defun cperl-check-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 (require 'mode-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (let ((perl-dbg-flags "-wc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (mode-compile)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (defun cperl-info-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 ;; Returns buffer with documentation. Creats if missing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 (let ((info (get-buffer "*info-perl*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 (if info info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 ;; Get Info running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 (require 'info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 (info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 (Info-find-node "perl5" "perlfunc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 (set-buffer "*info*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 (rename-buffer "*info-perl*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 (defun cperl-word-at-point (&optional p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 ;; Returns the word at point or at P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (if p (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (require 'etags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 (funcall (or (and (boundp 'find-tag-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 find-tag-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (get major-mode 'find-tag-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 ;; XEmacs 19.12 has `find-tag-default-hook'; it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 ;; automatically used within `find-tag-default':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 'find-tag-default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 (defun cperl-info-on-command (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 "Shows documentation for Perl command in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (let* ((default (cperl-word-at-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (read (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (format "Find doc for Perl function (default %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 (list (if (equal read "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 read))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 (let ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 (cmd-desc (concat "^" (regexp-quote command) "[^a-zA-Z_0-9]")) ; "tr///"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (if (string-match "^-[a-zA-Z]$" command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (setq cmd-desc "^-X[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (set-buffer (cperl-info-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 (re-search-forward "^-X[ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (if (re-search-forward cmd-desc nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 (setq pos (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 (pop-to-buffer (cperl-info-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 (set-window-start (selected-window) pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 (message "No entry for %s found." command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 (pop-to-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 (defun cperl-info-on-current-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 "Shows documentation for Perl command at point in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 (cperl-info-on-command (cperl-word-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 (defun cperl-imenu-info-imenu-search ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (if (looking-at "^-X[ \t\n]") nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 "^\n\\([-a-zA-Z]+\\)[ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (defun cperl-imenu-info-imenu-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 (defun cperl-imenu-on-info ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 (let* ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 imenu-prev-index-position-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 imenu-extract-index-name-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 (index-item (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 (set-buffer (cperl-info-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 (setq imenu-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 'imenu-default-create-index-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 imenu-prev-index-position-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 'cperl-imenu-info-imenu-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 imenu-extract-index-name-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 'cperl-imenu-info-imenu-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 (imenu-choose-buffer-index)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 (and index-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (pop-to-buffer "*info-perl*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 ((markerp (cdr index-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (goto-char (marker-position (cdr index-item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 (goto-char (cdr index-item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (set-window-start (selected-window) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (pop-to-buffer buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 (defun cperl-lineup (beg end &optional step minshift)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 "Lineup construction in a region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 Beginning of region should be at the start of a construction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 All first occurences of this construction in the lines that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 partially contained in the region are lined up at the same column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 MINSHIFT is the minimal amount of space to insert before the construction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 STEP is the tabwidth to position constructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 If STEP is `nil', `cperl-lineup-step' will be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 \(or `cperl-indent-level', if `cperl-lineup-step' is `nil').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 Will not move the position at the start to the left."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (let (search col tcol seen b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 (setq end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 (skip-chars-forward " \t\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (setq beg (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 (indent-region beg end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 (setq col (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 (if (looking-at "\\sw")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (if (looking-at "\\<\\sw+\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 (setq search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (concat "\\<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 (match-end 0))) "\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (error "Cannot line up in a middle of the word"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 (if (looking-at "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 (error "Cannot line up end of line"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (setq search (regexp-quote (char-to-string (following-char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (setq step (or step cperl-lineup-step cperl-indent-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 (or minshift (setq minshift 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (re-search-forward search end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (goto-char (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 (setq tcol (current-column) seen t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (if (> tcol col) (setq col tcol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 (or seen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 (error "The construction to line up occured only once"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 (setq col (+ col minshift))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (if (/= (% col step) 0) (setq step (* step (1+ (/ col step)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 (setq e (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 (delete-region (point) e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 (indent-to-column col); (make-string (- col (current-column)) ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 (re-search-forward search end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 (goto-char (match-beginning 0)))))))) ; No body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 (defun cperl-etags (&optional add all files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 "Run etags with appropriate options for Perl files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 If optional argument ALL is `recursive', will process Perl files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 in subdirectories too."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 (let ((cmd "etags")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 (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
2989 res)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 (if add (setq args (cons "-a" args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 (or files (setq files (list buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 ((eq all 'recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 ;;(error "Not implemented: recursive")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 (setq args (append (list "-e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 "sub wanted {push @ARGV, $File::Find::name if /\\.[Pp][Llm]$/}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 use File::Find;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 find(\\&wanted, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 exec @ARGV;"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 cmd) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 cmd "perl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 ;;(error "Not implemented: all")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 (setq args (append (list "-e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 "push @ARGV, <*.PL *.pl *.pm>;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 exec @ARGV;"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 cmd) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 cmd "perl"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (setq args (append args files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 (setq res (apply 'call-process cmd nil nil nil args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 (or (eq res 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 (message "etags returned \"%s\"" res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 (defun cperl-toggle-auto-newline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 "Toggle the state of `cperl-auto-newline'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 (setq cperl-auto-newline (not cperl-auto-newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (message "Newlines will %sbe auto-inserted now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 (if cperl-auto-newline "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 (defun cperl-toggle-abbrev ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 "Toggle the state of automatic keyword expansion in CPerl mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (abbrev-mode (if abbrev-mode 0 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (message "Perl control structure will %sbe auto-inserted now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 (if abbrev-mode "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 (defun cperl-toggle-electric ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 "Toggle the state of parentheses doubling in CPerl mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (setq cperl-electric-parens (if (cperl-val 'cperl-electric-parens) 'null t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 (message "Parentheses will %sbe auto-doubled now."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 (if (cperl-val 'cperl-electric-parens) "" "not ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036